-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathbuild.gradle.kts
55 lines (44 loc) · 1.62 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.lang.reflect.Modifier
import java.net.URLClassLoader
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins {
kotlin("jvm")
id("jps-compatible")
}
repositories {
gradlePluginPortal()
}
dependencies {
compileOnly(kotlin("stdlib", embeddedKotlinVersion))
compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
compileOnly(libs.shadow.gradlePlugin)
compileOnly(libs.jdom2)
}
sourceSets {
"main" { projectDefault() }
"test" { }
}
fun runPillTask(taskName: String) {
val jarFile = configurations.archives.get().artifacts.single { it.type == "jar" }.file
val cl = URLClassLoader(arrayOf(jarFile.toURI().toURL()), (object {}).javaClass.classLoader)
val pillImporterClass = Class.forName("org.jetbrains.kotlin.pill.PillImporter", true, cl)
val runMethod = pillImporterClass.declaredMethods.single { it.name == "run" }
require(Modifier.isStatic(runMethod.modifiers))
val platformDir = rootProject.ideaHomePathForTests().get().asFile
val resourcesDir = File(project.projectDir, "resources")
runMethod.invoke(null, project.rootProject, taskName, platformDir, resourcesDir)
}
val jar: Jar by tasks
val pill by tasks.creating {
notCompatibleWithConfigurationCache("The task requires the complete Gradle project model")
dependsOn(jar)
dependsOn(":createIdeaHomeForTests")
doLast { runPillTask("pill") }
}
val unpill by tasks.creating {
notCompatibleWithConfigurationCache("The task requires the complete Gradle project model")
dependsOn(jar)
doLast { runPillTask("unpill") }
}