diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 963e804ec71..6b442e7626c 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,4 +1,3 @@ -extra["versions.shadow"] = "5.2.0" extra["versions.native-platform"] = "0.14" buildscript { @@ -98,7 +97,7 @@ dependencies { implementation("net.rubygrapefruit:native-platform-windows-i386:${property("versions.native-platform")}") implementation("com.jakewharton.dex:dex-method-list:3.0.0") - implementation("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}") + implementation("com.github.jengelman.gradle.plugins:shadow:${rootProject.extra["versions.shadow"]}") implementation("org.jetbrains.intellij.deps:asm-all:7.0.1") implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.5") diff --git a/buildSrc/src/main/kotlin/pill/JpsCompatiblePlugin.kt b/buildSrc/src/main/kotlin/pill/JpsCompatiblePlugin.kt new file mode 100644 index 00000000000..d9a0137b0bc --- /dev/null +++ b/buildSrc/src/main/kotlin/pill/JpsCompatiblePlugin.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("PackageDirectoryMismatch") +package org.jetbrains.kotlin.pill + +import org.gradle.api.Plugin +import org.gradle.api.Project + +@Suppress("unused") +class JpsCompatiblePlugin : Plugin { + override fun apply(project: Project) { + project.configurations.maybeCreate(EmbeddedComponents.CONFIGURATION_NAME) + project.extensions.create("pill", PillExtension::class.java) + + // 'jpsTest' does not require the 'tests-jar' artifact + project.configurations.create("jpsTest") + + if (project == project.rootProject) { + project.tasks.create("pill") { + dependsOn(":pill:pill-importer:pill") + + if (System.getProperty("pill.android.tests", "false") == "true") { + TaskUtils.useAndroidSdk(this) + TaskUtils.useAndroidJar(this) + } + } + + project.tasks.create("unpill") { + dependsOn(":pill:pill-importer:unpill") + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/pill/extension.kt b/buildSrc/src/main/kotlin/pill/PillExtension.kt similarity index 89% rename from buildSrc/src/main/kotlin/pill/extension.kt rename to buildSrc/src/main/kotlin/pill/PillExtension.kt index 5306c632088..65992c518c7 100644 --- a/buildSrc/src/main/kotlin/pill/extension.kt +++ b/buildSrc/src/main/kotlin/pill/PillExtension.kt @@ -42,4 +42,10 @@ open class PillExtension { fun Project.excludedDirs(vararg dirs: String) { excludedDirs = excludedDirs + dirs.map { File(projectDir, it) } } + + @Suppress("unused") + fun serialize() = mapOf( + "variant" to variant.name, + "excludedDirs" to excludedDirs + ) } \ No newline at end of file diff --git a/gradle/versions.properties b/gradle/versions.properties index 458dac2e781..17f047ad41f 100644 --- a/gradle/versions.properties +++ b/gradle/versions.properties @@ -14,3 +14,4 @@ versions.jar.picocontainer=1.2 versions.jar.serviceMessages=2019.1.4 ignore.jar.snappy-in-java=true versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.191 b/gradle/versions.properties.191 index 28d373d2ac8..ba2adacdb18 100644 --- a/gradle/versions.properties.191 +++ b/gradle/versions.properties.191 @@ -14,3 +14,4 @@ versions.jar.oro=2.0.8 versions.jar.picocontainer=1.2 ignore.jar.snappy-in-java=true versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.192 b/gradle/versions.properties.192 index 562adb50368..41c81e8bccc 100644 --- a/gradle/versions.properties.192 +++ b/gradle/versions.properties.192 @@ -13,3 +13,4 @@ versions.jar.oro=2.0.8 versions.jar.picocontainer=1.2 ignore.jar.snappy-in-java=true versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.201 b/gradle/versions.properties.201 index 71df43c5754..5431d965680 100644 --- a/gradle/versions.properties.201 +++ b/gradle/versions.properties.201 @@ -14,3 +14,4 @@ versions.jar.picocontainer=1.2 versions.jar.serviceMessages=2019.1.4 ignore.jar.snappy-in-java=true versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.as35 b/gradle/versions.properties.as35 index 79d2bdbe3f6..8a76e186b9d 100644 --- a/gradle/versions.properties.as35 +++ b/gradle/versions.properties.as35 @@ -17,3 +17,4 @@ ignore.jar.common=true ignore.jar.lombok-ast=true versions.jar.asm-all=7.0 versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.as36 b/gradle/versions.properties.as36 index 6641a87e58f..c122788cad6 100644 --- a/gradle/versions.properties.as36 +++ b/gradle/versions.properties.as36 @@ -16,4 +16,5 @@ versions.jar.picocontainer=1.2 ignore.jar.snappy-in-java=true ignore.jar.common=true ignore.jar.lombok-ast=true -versions.gradle-api=4.5.1 \ No newline at end of file +versions.gradle-api=4.5.1 +versions.shadow=5.2.0 \ No newline at end of file diff --git a/gradle/versions.properties.as40 b/gradle/versions.properties.as40 index ab336150b38..63d9590d614 100644 --- a/gradle/versions.properties.as40 +++ b/gradle/versions.properties.as40 @@ -16,5 +16,6 @@ versions.jar.picocontainer=1.2 versions.jar.serviceMessages=2019.1.4 ignore.jar.snappy-in-java=true versions.gradle-api=4.5.1 +versions.shadow=5.2.0 ignore.jar.common=true ignore.jar.lombok-ast=true \ No newline at end of file diff --git a/plugins/pill/pill-importer/build.gradle.kts b/plugins/pill/pill-importer/build.gradle.kts new file mode 100644 index 00000000000..5d8d2e7ade9 --- /dev/null +++ b/plugins/pill/pill-importer/build.gradle.kts @@ -0,0 +1,49 @@ +import org.jetbrains.kotlin.pill.PillExtension +import java.lang.reflect.Modifier +import java.net.URLClassLoader + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +pill { + variant = PillExtension.Variant.FULL +} + +dependencies { + compileOnly(kotlin("stdlib", embeddedKotlinVersion)) + compileOnly(gradleApi()) + compileOnly(gradleKotlinDsl()) + compileOnly("com.github.jengelman.gradle.plugins:shadow:${rootProject.extra["versions.shadow"]}") +} + +sourceSets { + "main" { projectDefault() } + "test" { } +} + +fun runPillTask(taskName: String) { + val jarFile = configurations.archives.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 = IntellijRootUtils.getIntellijRootDir(project) + val resourcesDir = File(project.projectDir, "resources") + runMethod.invoke(null, project.rootProject, taskName, platformDir, resourcesDir, EmbeddedComponents.CONFIGURATION_NAME) +} + +val jar: Jar by tasks + +val pill by tasks.creating { + dependsOn(jar) + doLast { runPillTask("pill") } +} + +val unpill by tasks.creating { + dependsOn(jar) + doLast { runPillTask("unpill") } +} \ No newline at end of file diff --git a/buildSrc/src/main/resources/runConfigurations/Pill_All_Compiler_Tests.xml b/plugins/pill/pill-importer/resources/runConfigurations/Pill_All_Compiler_Tests.xml similarity index 100% rename from buildSrc/src/main/resources/runConfigurations/Pill_All_Compiler_Tests.xml rename to plugins/pill/pill-importer/resources/runConfigurations/Pill_All_Compiler_Tests.xml diff --git a/buildSrc/src/main/resources/runConfigurations/Pill_All_IDEA_Plugin_Tests.xml b/plugins/pill/pill-importer/resources/runConfigurations/Pill_All_IDEA_Plugin_Tests.xml similarity index 100% rename from buildSrc/src/main/resources/runConfigurations/Pill_All_IDEA_Plugin_Tests.xml rename to plugins/pill/pill-importer/resources/runConfigurations/Pill_All_IDEA_Plugin_Tests.xml diff --git a/buildSrc/src/main/resources/runConfigurations/Pill_Compiler_Tests.xml b/plugins/pill/pill-importer/resources/runConfigurations/Pill_Compiler_Tests.xml similarity index 100% rename from buildSrc/src/main/resources/runConfigurations/Pill_Compiler_Tests.xml rename to plugins/pill/pill-importer/resources/runConfigurations/Pill_Compiler_Tests.xml diff --git a/buildSrc/src/main/resources/runConfigurations/Pill_Generate_All_Tests.xml b/plugins/pill/pill-importer/resources/runConfigurations/Pill_Generate_All_Tests.xml similarity index 100% rename from buildSrc/src/main/resources/runConfigurations/Pill_Generate_All_Tests.xml rename to plugins/pill/pill-importer/resources/runConfigurations/Pill_Generate_All_Tests.xml diff --git a/buildSrc/src/main/resources/runConfigurations/Pill_IDEA.xml b/plugins/pill/pill-importer/resources/runConfigurations/Pill_IDEA.xml similarity index 98% rename from buildSrc/src/main/resources/runConfigurations/Pill_IDEA.xml rename to plugins/pill/pill-importer/resources/runConfigurations/Pill_IDEA.xml index 446c208cd3f..0cf6d85cdb1 100644 --- a/buildSrc/src/main/resources/runConfigurations/Pill_IDEA.xml +++ b/plugins/pill/pill-importer/resources/runConfigurations/Pill_IDEA.xml @@ -2,7 +2,7 @@