diff --git a/build.gradle.kts b/build.gradle.kts index e5332fa73de..714562f2803 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -292,6 +292,8 @@ val ignoreTestFailures by extra(project.findProperty("ignoreTestFailures")?.toSt allprojects { + configurations.maybeCreate("embedded") + jvmTarget = defaultJvmTarget if (defaultJavaHome != null) { javaHome = defaultJavaHome diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index 500b99fec75..387e9fc958f 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -73,6 +73,12 @@ fun Project.runtimeJar(task: T, body: T.() -> Unit = {}): T { removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask) } return task.apply { + configurations.findByName("embedded")?.let { embedded -> + dependsOn(embedded) + from { + embedded.map(::zipTree) + } + } setupPublicJar(project.the().archivesBaseName) setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE) body() diff --git a/buildSrc/src/main/kotlin/configurations.kt b/buildSrc/src/main/kotlin/configurations.kt new file mode 100644 index 00000000000..f3cb1d362ca --- /dev/null +++ b/buildSrc/src/main/kotlin/configurations.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +import org.gradle.api.Action +import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.ExternalModuleDependency +import org.gradle.api.artifacts.ModuleDependency +import org.gradle.api.artifacts.dsl.DependencyHandler +import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo +import org.gradle.kotlin.dsl.accessors.runtime.addExternalModuleDependencyTo +import org.gradle.kotlin.dsl.add + +fun DependencyHandler.embedded(dependencyNotation: Any): Dependency? = + add("embedded", dependencyNotation) + +fun DependencyHandler.embedded( + dependencyNotation: String, + dependencyConfiguration: Action +): ExternalModuleDependency = + addDependencyTo(this, "embedded", dependencyNotation, dependencyConfiguration) + +fun DependencyHandler.embedded( + group: String, + name: String, + version: String? = null, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +): ExternalModuleDependency = addExternalModuleDependencyTo( + this, "embedded", group, name, version, configuration, classifier, ext, dependencyConfiguration +) + +fun DependencyHandler.embedded( + dependency: T, + dependencyConfiguration: T.() -> Unit +): T = add("embedded", dependency, dependencyConfiguration) diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index b27e5c86483..0e953993959 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -135,7 +135,7 @@ val compilerManifestClassPath get() = "annotations-13.0.jar kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar" object EmbeddedComponents { - val CONFIGURATION_NAME = "embeddedComponents" + val CONFIGURATION_NAME = "embedded" } fun AbstractCopyTask.fromEmbeddedComponents() { diff --git a/buildSrc/src/main/kotlin/pill/kotlinPluginArtifact.kt b/buildSrc/src/main/kotlin/pill/kotlinPluginArtifact.kt index c62dc7f9c3b..7581c97fe5c 100644 --- a/buildSrc/src/main/kotlin/pill/kotlinPluginArtifact.kt +++ b/buildSrc/src/main/kotlin/pill/kotlinPluginArtifact.kt @@ -131,7 +131,7 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile { kotlinPluginJar.add(FileCopy(File(rootProject.projectDir, "resources/kotlinManifest.properties"))) - for (jarFile in sourcePath.project.configurations.getByName("embedded").resolve()) { + for (jarFile in sourcePath.project.configurations.getByName(EmbeddedComponents.CONFIGURATION_NAME).resolve()) { kotlinPluginJar.add(ExtractedDirectory(jarFile)) } diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index 9fea8b3a03c..63c6e1637f8 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -13,7 +13,7 @@ import java.io.File class PillConfigurablePlugin : Plugin { override fun apply(project: Project) { - project.configurations.create(EmbeddedComponents.CONFIGURATION_NAME) + project.configurations.maybeCreate(EmbeddedComponents.CONFIGURATION_NAME) project.extensions.create("pill", PillExtension::class.java) } } diff --git a/compiler/daemon/daemon-client/build.gradle.kts b/compiler/daemon/daemon-client/build.gradle.kts index 2e1ff61682b..3bc66359eee 100644 --- a/compiler/daemon/daemon-client/build.gradle.kts +++ b/compiler/daemon/daemon-client/build.gradle.kts @@ -29,10 +29,10 @@ dependencies { compileOnly(commonDep("net.rubygrapefruit", "native-platform")) compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) } - embeddedComponents(project(":compiler:daemon-common")) { isTransitive = false } - embeddedComponents(commonDep("net.rubygrapefruit", "native-platform")) + embedded(project(":compiler:daemon-common")) { isTransitive = false } + embedded(commonDep("net.rubygrapefruit", "native-platform")) nativePlatformVariants.forEach { - embeddedComponents(commonDep("net.rubygrapefruit", "native-platform", "-$it")) + embedded(commonDep("net.rubygrapefruit", "native-platform", "-$it")) } } @@ -47,7 +47,6 @@ noDefaultJar() runtimeJar(task("shadowJar")) { from(mainSourceSet.output) - fromEmbeddedComponents() } sourcesJar() diff --git a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts index ebf8dc7dde4..02057ced375 100644 --- a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { robolectricClasspath("org.robolectric:android-all:4.4_r1-robolectric-1") robolectricClasspath(project(":kotlin-android-extensions-runtime")) { isTransitive = false } - embeddedComponents(project(":kotlin-android-extensions-runtime")) { isTransitive = false } + embedded(project(":kotlin-android-extensions-runtime")) { isTransitive = false } } sourceSets { @@ -42,9 +42,7 @@ sourceSets { "test" { projectDefault() } } -runtimeJar { - fromEmbeddedComponents() -} +runtimeJar() dist() diff --git a/plugins/imports-dumper/build.gradle.kts b/plugins/imports-dumper/build.gradle.kts index 3b776353a68..cbb99fcb0ff 100644 --- a/plugins/imports-dumper/build.gradle.kts +++ b/plugins/imports-dumper/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { testCompile(projectTests(":compiler:tests-common")) - embeddedComponents("org.jetbrains.kotlinx", "kotlinx-serialization-runtime", kotlinxSerializationVersion) { isTransitive = false } + embedded("org.jetbrains.kotlinx", "kotlinx-serialization-runtime", kotlinxSerializationVersion) { isTransitive = false } } sourceSets { @@ -34,8 +34,6 @@ projectTest { dependsOn(":dist") } -runtimeJar { - fromEmbeddedComponents() -} +runtimeJar() dist() \ No newline at end of file diff --git a/plugins/kapt3/kapt3-compiler/build.gradle.kts b/plugins/kapt3/kapt3-compiler/build.gradle.kts index 77768587aca..00327977323 100644 --- a/plugins/kapt3/kapt3-compiler/build.gradle.kts +++ b/plugins/kapt3/kapt3-compiler/build.gradle.kts @@ -33,9 +33,9 @@ dependencies { testCompile(commonDep("junit:junit")) testCompile(project(":kotlin-annotation-processing-runtime")) - embeddedComponents(project(":kotlin-annotation-processing-runtime")) { isTransitive = false } - embeddedComponents(project(":kotlin-annotation-processing-cli")) { isTransitive = false } - embeddedComponents(project(":kotlin-annotation-processing-base")) { isTransitive = false } + embedded(project(":kotlin-annotation-processing-runtime")) { isTransitive = false } + embedded(project(":kotlin-annotation-processing-cli")) { isTransitive = false } + embedded(project(":kotlin-annotation-processing-base")) { isTransitive = false } } sourceSets { @@ -52,9 +52,7 @@ projectTest { publish() -runtimeJar { - fromEmbeddedComponents() -} +runtimeJar() sourcesJar() javadocJar() diff --git a/prepare/idea-plugin/build.gradle.kts b/prepare/idea-plugin/build.gradle.kts index e7399233dee..39c38f260e9 100644 --- a/prepare/idea-plugin/build.gradle.kts +++ b/prepare/idea-plugin/build.gradle.kts @@ -97,7 +97,6 @@ val projectsToShadow by extra(listOf( emptyArray() )) -val embedded by configurations.creating // PILL: used in pill importer val libraries by configurations.creating val jpsPlugin by configurations.creating @@ -137,12 +136,7 @@ dependencies { } val jar = runtimeJar { - dependsOn(embedded) from("$rootDir/resources/kotlinManifest.properties") - from { - embedded.files.map(::zipTree) - } - archiveName = "kotlin-plugin.jar" } diff --git a/prepare/jps-plugin/build.gradle.kts b/prepare/jps-plugin/build.gradle.kts index 1159b602db8..3f76b7999dd 100644 --- a/prepare/jps-plugin/build.gradle.kts +++ b/prepare/jps-plugin/build.gradle.kts @@ -22,15 +22,14 @@ val projectsToShadow = listOf( dependencies { projectsToShadow.forEach { - embeddedComponents(project(it)) { isTransitive = false } + embedded(project(it)) { isTransitive = false } } - embeddedComponents(projectRuntimeJar(":kotlin-daemon-client")) + embedded(projectRuntimeJar(":kotlin-daemon-client")) } runtimeJar { manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.runner.Main" manifest.attributes["Class-Path"] = "kotlin-stdlib.jar" from(files("$rootDir/resources/kotlinManifest.properties")) - fromEmbeddedComponents() }