diff --git a/build.gradle.kts b/build.gradle.kts index 9dc27bdc6a6..dfb00b00c91 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -200,6 +200,12 @@ fun Project.allprojectsRecursive(body: Project.() -> Unit) { this.subprojects { allprojectsRecursive(body) } } +fun Task.listConfigurationContents(configName: String) { + doFirst { + println("$configName configuration files:\n${project.configurations[configName].allArtifacts.files.files.joinToString("\n ", " ")}") + } +} + val defaultJvmTarget = "1.8" val defaultJavaHome = jdkPath(defaultJvmTarget!!) @@ -243,11 +249,11 @@ allprojects { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } - task("printArchives") { - doFirst { - println("Archives configuration files:\n${configurations["archives"].allArtifacts.files.files.joinToString("\n ", " ")}") - } - } + task("listArchives") { listConfigurationContents("archives") } + + task("listRuntimeJar") { listConfigurationContents("runtimeJar") } + + task("listDistJar") { listConfigurationContents("distJar") } afterEvaluate { logger.info("configuring project $name to compile to the target jvm version $jvmTarget using jdk: $javaHome") diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index 7287e534a2c..3aa5b22d464 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -142,7 +142,9 @@ fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit } fun Project.ideaPlugin(subdir: String = "lib"): Copy = ideaPlugin(subdir) { - fromRuntimeJarIfExists(this) + runtimeJarTaskIfExists()?.let { + from(it) + } } fun Project.dist(targetDir: File? = null, @@ -155,27 +157,22 @@ fun Project.dist(targetDir: File? = null, return task("dist") { body() - when { - fromTask != null -> from(fromTask) - else -> project.fromRuntimeJarIfExists(this) + (fromTask ?: runtimeJarTaskIfExists())?.let { + from(it) + if (targetName != null) { + rename(it.outputs.files.singleFile.name, targetName) + } } - rename(".*", distJarName) -// rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "") + rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "") into(targetDir ?: distLibDir) project.addArtifact(distJarCfg, this, File(targetDir ?: distLibDir, distJarName)) } } -private fun Project.fromRuntimeJarIfExists(task: T) { - if (extra.has("runtimeJarTask")) { - task.from(extra["runtimeJarTask"] as Task) - } - else { - tasks.findByName("jar")?.let { - task.from(it) - } - } -} +private fun Project.runtimeJarTaskIfExists(): Task? = + if (extra.has("runtimeJarTask")) extra["runtimeJarTask"] as Task + else tasks.findByName("jar") + fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name) diff --git a/compiler/tests-java8/build.gradle.kts b/compiler/tests-java8/build.gradle.kts index bb1fc01c9f4..9cb903a996c 100644 --- a/compiler/tests-java8/build.gradle.kts +++ b/compiler/tests-java8/build.gradle.kts @@ -20,7 +20,7 @@ dependencies { testCompile(projectDist(":kotlin-script-runtime")) testCompile(projectDist(":kotlin-reflect")) testCompile(projectTests(":compiler")) - testRuntime(projectDist(":kotlin-preloader")) + testRuntime(projectRuntimeJar(":kotlin-preloader")) testRuntime(ideaSdkCoreDeps("*.jar")) testRuntime(ideaSdkDeps("*.jar")) } diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index bc4ee573e33..687ee201c71 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -8,7 +8,7 @@ dependencies { compile(project(":core")) compile(project(":compiler:backend")) compile(project(":compiler:cli-common")) - compile(projectDist(":kotlin-daemon-client")) + compile(projectRuntimeJar(":kotlin-daemon-client")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) compile(project(":compiler:frontend.script")) diff --git a/jps-plugin/build.gradle.kts b/jps-plugin/build.gradle.kts index 03ce628e181..f6234121184 100644 --- a/jps-plugin/build.gradle.kts +++ b/jps-plugin/build.gradle.kts @@ -7,9 +7,9 @@ dependencies { compile(project(":core")) compile(project(":kotlin-compiler-runner")) compile(project(":compiler:daemon-common")) - compile(projectDist(":kotlin-daemon-client")) + compile(projectRuntimeJar(":kotlin-daemon-client")) compile(project(":compiler:frontend.java")) - compile(projectDist(":kotlin-preloader")) + compile(projectRuntimeJar(":kotlin-preloader")) compile(project(":idea:idea-jps-common")) compile(ideaSdkDeps("jps-builders", "jps-builders-6", subdir = "jps")) testCompile(project(":compiler.tests-common")) diff --git a/plugins/allopen/allopen-cli/build.gradle.kts b/plugins/allopen/allopen-cli/build.gradle.kts index a93c077ae06..b0ae4ebf181 100644 --- a/plugins/allopen/allopen-cli/build.gradle.kts +++ b/plugins/allopen/allopen-cli/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { compileOnly(ideaSdkCoreDeps("intellij-core")) compileOnly(project(":compiler:plugin-api")) compileOnly(project(":compiler:frontend")) - runtime(projectDist(":kotlin-compiler")) + runtime(projectRuntimeJar(":kotlin-compiler")) runtime(projectDist(":kotlin-stdlib")) } diff --git a/plugins/noarg/noarg-cli/build.gradle.kts b/plugins/noarg/noarg-cli/build.gradle.kts index b27006fa48b..29112600f5a 100644 --- a/plugins/noarg/noarg-cli/build.gradle.kts +++ b/plugins/noarg/noarg-cli/build.gradle.kts @@ -9,7 +9,7 @@ dependencies { compileOnly(project(":compiler:backend")) compileOnly(project(":compiler:util")) compileOnly(project(":compiler:plugin-api")) - runtime(projectDist(":kotlin-compiler")) + runtime(projectRuntimeJar(":kotlin-compiler")) runtime(projectDist(":kotlin-stdlib")) } diff --git a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts index ae839c8cfd0..3c11a4c8923 100644 --- a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts +++ b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { compileOnly(project(":compiler:frontend")) compileOnly(project(":compiler:frontend.java")) compileOnly(project(":compiler:plugin-api")) - runtime(projectDist(":kotlin-compiler")) + runtime(projectRuntimeJar(":kotlin-compiler")) runtime(projectDist(":kotlin-stdlib")) } @@ -24,7 +24,9 @@ javadocJar() publish() -dist(targetName = the().archivesBaseName.removePrefix("kotlin-") + ".jar") +dist { + rename("kotlin-", "") +} ideaPlugin { from(jar) diff --git a/prepare/compiler-embeddable/build.gradle.kts b/prepare/compiler-embeddable/build.gradle.kts index 3e8bb9e5e66..1e74df62d30 100644 --- a/prepare/compiler-embeddable/build.gradle.kts +++ b/prepare/compiler-embeddable/build.gradle.kts @@ -37,7 +37,7 @@ val packagesToRelocate = dependencies { val compile by configurations - compilerJar(projectDist(":kotlin-compiler")) + compilerJar(projectRuntimeJar(":kotlin-compiler")) compile(project(":kotlin-stdlib")) compile(project(":kotlin-script-runtime")) diff --git a/ultimate/build.gradle.kts b/ultimate/build.gradle.kts index 82c5f9f78dd..48e14d6f0cb 100644 --- a/ultimate/build.gradle.kts +++ b/ultimate/build.gradle.kts @@ -66,7 +66,7 @@ dependencies { testCompile(ideaUltimateSdkDeps("gson")) testCompile(preloadedDeps("kotlinx-coroutines-core")) - testRuntime(projectDist(":kotlin-compiler")) + testRuntime(projectRuntimeJar(":kotlin-compiler")) testRuntime(project(":plugins:android-extensions-ide")) { isTransitive = false } testRuntime(project(":plugins:android-extensions-compiler")) { isTransitive = false } testRuntime(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false }