diff --git a/ant/build.gradle.kts b/ant/build.gradle.kts index 924cd0611c6..637e2f5e6c8 100644 --- a/ant/build.gradle.kts +++ b/ant/build.gradle.kts @@ -6,7 +6,7 @@ apply { plugin("kotlin") } dependencies { compile(commonDep("org.apache.ant", "ant")) compile(project(":kotlin-preloader")) - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) } sourceSets { diff --git a/build-common/build.gradle.kts b/build-common/build.gradle.kts index 0ee18f183f5..60575808bd4 100644 --- a/build-common/build.gradle.kts +++ b/build-common/build.gradle.kts @@ -13,8 +13,8 @@ dependencies { testCompile(commonDep("junit:junit")) testCompile(project(":compiler.tests-common")) testCompile(protobufFull()) - testRuntime(project(":kotlin-stdlib")) - testRuntime(project(":kotlin-reflect")) + testRuntime(projectDist(":kotlin-stdlib")) + testRuntime(projectDist(":kotlin-reflect")) } sourceSets { diff --git a/buildSrc/src/main/kotlin/CommonUtil.kt b/buildSrc/src/main/kotlin/CommonUtil.kt index e19edd6d10f..6f38351c4d8 100644 --- a/buildSrc/src/main/kotlin/CommonUtil.kt +++ b/buildSrc/src/main/kotlin/CommonUtil.kt @@ -13,7 +13,10 @@ inline fun Project.task(noinline configuration: T.() -> Unit) fun AbstractTask.dependsOnTaskIfExists(task: String) { - project.tasks.firstOrNull { it.name == task }?.let { dependsOn(it) } + val thisTask = this + project.afterEvaluate { + project.tasks.firstOrNull { it.name == task }?.let { thisTask.dependsOn(it) } + } } fun AbstractTask.dependsOnTaskIfExistsRec(task: String, project: Project? = null) { diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index 7ea1b963c26..52e14e43c47 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -8,10 +8,11 @@ import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ConfigurationContainer import org.gradle.api.artifacts.Dependency import org.gradle.api.file.DuplicatesStrategy +import org.gradle.api.plugins.BasePluginConvention import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.jvm.tasks.Jar - +import java.io.File fun Project.testsJar(body: Jar.() -> Unit = {}): Jar { val testsJarCfg = configurations.getOrCreate("tests-jar").extendsFrom(configurations["testCompile"]) @@ -93,7 +94,7 @@ fun Project.publish(body: Upload.() -> Unit = {}): Upload { } } -fun Project.ideaPlugin(subdir: String = "lib", body: Copy.() -> Unit) { +fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit) { task("idea-plugin") { body() into(File(rootProject.extra["ideaPluginDir"].toString(), subdir).path) @@ -105,19 +106,27 @@ fun Project.ideaPlugin(subdir: String = "lib") = ideaPlugin(subdir) { fromRuntimeJarIfExists(this) } +fun Project.dist(targetDir: File? = null, + targetName: String? = null, + fromTask: Task? = null, + body: AbstractCopyTask.() -> Unit = {}): AbstractCopyTask { + val distJarCfg = configurations.getOrCreate("distJar") + val distLibDir: File by rootProject.extra + val distJarName = targetName ?: (the().archivesBaseName + ".jar") -fun Project.dist(body: Copy.() -> Unit) { - task("dist") { + return task("dist") { body() - rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "") - into(rootProject.extra["distLibDir"].toString()) + when { + fromTask != null -> from(fromTask) + else -> project.fromRuntimeJarIfExists(this) + } + rename(".*", distJarName) +// rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "") + into(targetDir ?: distLibDir) + project.addArtifact(distJarCfg, this, File(targetDir ?: distLibDir, distJarName)) } } -fun Project.dist() = dist { - fromRuntimeJarIfExists(this) -} - private fun Project.fromRuntimeJarIfExists(task: T) { if (extra.has("runtimeJarTask")) { task.from(extra["runtimeJarTask"] as Task) diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index 17ed1cd6dbf..57d0597e800 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -51,6 +51,7 @@ fun DependencyHandler.projectDep(name: String): Dependency = project(name, confi fun DependencyHandler.projectDepIntransitive(name: String): Dependency = project(name, configuration = "default").apply { isTransitive = false } +fun DependencyHandler.projectDist(name: String): Dependency = project(name, configuration = "distJar").apply { isTransitive = false } fun DependencyHandler.projectTests(name: String): Dependency = project(name, configuration = "tests-jar").apply { isTransitive = false } fun DependencyHandler.projectRuntimeJar(name: String): Dependency = project(name, configuration = "runtimeJar") fun DependencyHandler.projectArchives(name: String): Dependency = project(name, configuration = "archives") diff --git a/compiler.tests-common/build.gradle.kts b/compiler.tests-common/build.gradle.kts index 03dda408b8d..a487fbf3103 100644 --- a/compiler.tests-common/build.gradle.kts +++ b/compiler.tests-common/build.gradle.kts @@ -23,7 +23,7 @@ dependencies { compile(project(":js:js.translator")) compile(project(":android-extensions-compiler")) compile(project(":kotlin-test:kotlin-test-jvm")) - compile(commonDep("junit")) + compile(commonDep("junit:junit")) compile(ideaSdkCoreDeps("intellij-core")) compile(ideaSdkDeps("openapi", "idea", "idea_rt")) compile(preloadedDeps("dx", subdir = "android-5.0/lib")) diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 4cbb61d7cfe..5594c26b8f4 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -9,34 +9,55 @@ jvmTarget = "1.6" val compilerModules: Array by rootProject.extra val otherCompilerModules = compilerModules.filter { it != path } +val depDistProjects = listOf( + ":kotlin-script-runtime", + ":kotlin-stdlib", + ":kotlin-reflect", + ":kotlin-test:kotlin-test-jvm") + +// TODO: it seems incomplete, find and add missing dependencies +val testDistProjects = listOf( + "", // for root project + ":prepare:mock-runtime-for-test", + ":kotlin-compiler", + ":kotlin-runtime", + ":kotlin-script-runtime", + ":kotlin-stdlib", + ":kotlin-stdlib-jre7", + ":kotlin-stdlib-jre8", + ":kotlin-stdlib-js", + ":kotlin-reflect", + ":kotlin-test:kotlin-test-jvm", + ":kotlin-test:kotlin-test-junit", + ":kotlin-test:kotlin-test-js", + ":kotlin-daemon-client", + ":android-extensions-compiler", + ":kotlin-ant") + dependencies { - testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) - testCompile(project(":kotlin-test:kotlin-test-junit")) - testCompile(project(":compiler.tests-common")) - testCompileOnly(project(":compiler:ir.ir2cfg")) - testCompileOnly(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward - testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all", "commons-httpclient-3.1-patched")) - // deps below are test runtime deps, but made test compile to split compilation and running to reduce mem req - testCompile(project(":kotlin-stdlib")) - testCompile(project(":kotlin-script-runtime")) - testCompile(project(":kotlin-runtime")) - testCompile(project(":kotlin-reflect")) - testCompile(project(":android-extensions-compiler")) - testCompile(project(":kotlin-ant")) - otherCompilerModules.forEach { - testCompile(project(it)) + depDistProjects.forEach { + testCompile(projectDist(it)) } + testCompile(commonDep("junit:junit")) + testCompileOnly(projectDist(":kotlin-test:kotlin-test-jvm")) + testCompileOnly(projectDist(":kotlin-test:kotlin-test-junit")) + testCompile(project(":compiler.tests-common")) + testCompile(project(":compiler:ir.ir2cfg")) + testCompile(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward + otherCompilerModules.forEach { + testCompileOnly(project(it)) + } + testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all", "commons-httpclient-3.1-patched")) testRuntime(ideaSdkCoreDeps("*.jar")) testRuntime(ideaSdkDeps("*.jar")) -// testRuntime(project(":kotlin-compiler", configuration = "default")) } sourceSets { "main" {} "test" { projectDefault() - java.srcDir("tests-ir-jvm/tests") + // not yet ready +// java.srcDir("tests-ir-jvm/tests") } } @@ -52,22 +73,6 @@ jar.apply { testsJar {} -// TODO: it seems incomlete, find and add missing dependencies -val testDistProjects = listOf( - ":prepare:mock-runtime-for-test", - ":kotlin-compiler", - ":kotlin-runtime", - ":kotlin-script-runtime", - ":kotlin-stdlib", - ":kotlin-stdlib-jre7", - ":kotlin-stdlib-jre8", - ":kotlin-stdlib-js", - ":kotlin-reflect", - ":kotlin-test:kotlin-test-jvm", - ":kotlin-test:kotlin-test-junit", - ":kotlin-test:kotlin-test-js", - ":kotlin-daemon-client") - projectTest { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir diff --git a/compiler/cli/cli-runner/build.gradle.kts b/compiler/cli/cli-runner/build.gradle.kts index bf20aa440b3..a2f74f3e0f9 100644 --- a/compiler/cli/cli-runner/build.gradle.kts +++ b/compiler/cli/cli-runner/build.gradle.kts @@ -6,7 +6,7 @@ apply { plugin("kotlin") } jvmTarget = "1.6" dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) } sourceSets { diff --git a/compiler/container/build.gradle.kts b/compiler/container/build.gradle.kts index 455268c7c13..ab4ea654fd7 100644 --- a/compiler/container/build.gradle.kts +++ b/compiler/container/build.gradle.kts @@ -7,8 +7,9 @@ dependencies { compile(project(":core:util.runtime")) compile(commonDep("javax.inject")) compile(ideaSdkCoreDeps("intellij-core")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) testRuntime(ideaSdkCoreDeps("trove4j", "intellij-core")) } diff --git a/compiler/frontend.script/build.gradle.kts b/compiler/frontend.script/build.gradle.kts index cb8923d78b3..33a6fa60115 100644 --- a/compiler/frontend.script/build.gradle.kts +++ b/compiler/frontend.script/build.gradle.kts @@ -6,7 +6,7 @@ jvmTarget = "1.6" dependencies { compile(project(":compiler:util")) compile(project(":compiler:frontend")) - compile(project(":kotlin-reflect")) + compile(projectDist(":kotlin-reflect")) compile(preloadedDeps("kotlinx-coroutines-core")) } diff --git a/compiler/frontend/build.gradle.kts b/compiler/frontend/build.gradle.kts index f2cdcd5997b..8c1b56580d6 100644 --- a/compiler/frontend/build.gradle.kts +++ b/compiler/frontend/build.gradle.kts @@ -8,7 +8,7 @@ dependencies { compile(project(":compiler:util")) compile(project(":compiler:container")) compile(project(":compiler:resolution")) - compile(project(":kotlin-script-runtime")) + compile(projectDist(":kotlin-script-runtime")) compile(commonDep("io.javaslang","javaslang")) } diff --git a/compiler/incremental-compilation-impl/build.gradle.kts b/compiler/incremental-compilation-impl/build.gradle.kts index dc1e0fb212f..46d30d46866 100644 --- a/compiler/incremental-compilation-impl/build.gradle.kts +++ b/compiler/incremental-compilation-impl/build.gradle.kts @@ -10,8 +10,9 @@ dependencies { compile(project(":compiler:frontend.java")) compile(project(":compiler:cli")) compile(project(":kotlin-build-common")) - testCompile(project(":kotlin-test:kotlin-test-junit")) - testCompile(project(":kotlin-stdlib")) + testCompile(commonDep("junit:junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testCompile(projectDist(":kotlin-stdlib")) testCompile(projectTests(":kotlin-build-common")) } diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index e9b623f2b17..8e60b6f565b 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -344,9 +344,9 @@ public class KotlinTestUtils { @NotNull public static String getHomeDirectory() { - File resourceRoot = PathUtil.getResourcePathForClass(KotlinTestUtils.class); - // TODO: very fragile logic, consider more robust home dir detection - return FileUtil.toSystemIndependentName(resourceRoot.getParentFile().getParentFile().getParentFile().getParent()); + String userDir = System.getProperty("user.dir"); + File dir = new File(userDir == null ? "." : userDir); + return FileUtil.toCanonicalPath(dir.getAbsolutePath()); } public static File findMockJdkRtJar() { diff --git a/compiler/tests-java8/build.gradle.kts b/compiler/tests-java8/build.gradle.kts index 68cd0ee39a0..88460c242d1 100644 --- a/compiler/tests-java8/build.gradle.kts +++ b/compiler/tests-java8/build.gradle.kts @@ -4,8 +4,8 @@ apply { plugin("kotlin") } dependencies { testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) - testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) testCompile(project(":compiler.tests-common")) testCompile(project(":core")) testCompile(project(":compiler:util")) @@ -16,12 +16,12 @@ dependencies { testCompile(project(":compiler:serialization")) testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all")) // deps below are test runtime deps, but made test compile to split compilation and running to reduce mem req - testCompile(project(":kotlin-stdlib")) - testCompile(project(":kotlin-script-runtime")) - testCompile(project(":kotlin-runtime")) - testCompile(project(":kotlin-reflect")) + testCompile(projectDist(":kotlin-stdlib")) + testCompile(projectDist(":kotlin-script-runtime")) + testCompile(projectDist(":kotlin-runtime")) + testCompile(projectDist(":kotlin-reflect")) testCompile(projectTests(":compiler")) - testRuntime(project(":kotlin-preloader")) + testRuntime(projectDist(":kotlin-preloader")) testRuntime(ideaSdkCoreDeps("*.jar")) testRuntime(ideaSdkDeps("*.jar")) } diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerApiTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerApiTest.kt index fad9e58344b..ca7395417af 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerApiTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerApiTest.kt @@ -206,6 +206,10 @@ class TestMessageCollector : MessageCollector { } override fun hasErrors(): Boolean = messages.any { it.severity == CompilerMessageSeverity.EXCEPTION || it.severity == CompilerMessageSeverity.ERROR } + + override fun toString(): String { + return messages.joinToString("\n") { "${it.severity}: ${it.message}${it.location?.let{" at $it"} ?: ""}" } + } } fun TestMessageCollector.assertHasMessage(msg: String, desiredSeverity: CompilerMessageSeverity? = null) { diff --git a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt index f7fadd386f3..99aec173a81 100644 --- a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt @@ -61,8 +61,9 @@ import kotlin.script.templates.standard.ScriptTemplateWithArgs class ScriptTemplateTest { @Test fun testScriptWithParam() { - val aClass = compileScript("fib.kts", ScriptWithIntParam::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithIntParam::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -71,8 +72,9 @@ class ScriptTemplateTest { @Test fun testScriptWithClassParameter() { - val aClass = compileScript("fib_cp.kts", ScriptWithClassParam::class, null, runIsolated = false) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib_cp.kts", ScriptWithClassParam::class, null, runIsolated = false, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(TestParamClass::class.java).newInstance(TestParamClass(4)) } @@ -81,8 +83,9 @@ class ScriptTemplateTest { @Test fun testScriptWithBaseClassWithParam() { - val aClass = compileScript("fib_dsl.kts", ScriptWithBaseClass::class, null, runIsolated = false) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib_dsl.kts", ScriptWithBaseClass::class, null, runIsolated = false, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE, Integer.TYPE).newInstance(4, 1) } @@ -93,8 +96,9 @@ class ScriptTemplateTest { fun testScriptWithDependsAnn() { Assert.assertNull(compileScript("fib_ext_ann.kts", ScriptWithIntParamAndDummyResolver::class, null, includeKotlinRuntime = false)) - val aClass = compileScript("fib_ext_ann.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib_ext_ann.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -112,8 +116,9 @@ class ScriptTemplateTest { System.setErr(savedErr) } - val aClass = compileScript("fib_ext_ann2.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib_ext_ann2.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -122,8 +127,9 @@ class ScriptTemplateTest { @Test fun testScriptWithoutParams() { - val aClass = compileScript("without_params.kts", ScriptWithoutParams::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("without_params.kts", ScriptWithoutParams::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -132,8 +138,9 @@ class ScriptTemplateTest { @Test fun testScriptWithOverriddenParam() { - val aClass = compileScript("overridden_parameter.kts", ScriptBaseClassWithOverriddenProperty::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("overridden_parameter.kts", ScriptBaseClassWithOverriddenProperty::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -142,8 +149,9 @@ class ScriptTemplateTest { @Test fun testScriptWithArrayParam() { - val aClass = compileScript("array_parameter.kts", ScriptWithArrayParam::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("array_parameter.kts", ScriptWithArrayParam::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Array::class.java).newInstance(arrayOf("one", "two")) }.let { @@ -153,8 +161,9 @@ class ScriptTemplateTest { @Test fun testScriptWithNullableParam() { - val aClass = compileScript("nullable_parameter.kts", ScriptWithNullableParam::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("nullable_parameter.kts", ScriptWithNullableParam::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Int::class.javaObjectType).newInstance(null) }.let { @@ -164,8 +173,9 @@ class ScriptTemplateTest { @Test fun testScriptVarianceParams() { - val aClass = compileScript("variance_parameters.kts", ScriptVarianceParams::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("variance_parameters.kts", ScriptVarianceParams::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Array::class.java, Array::class.java).newInstance(arrayOf("one"), arrayOf(1, 2)) }.let { @@ -175,8 +185,9 @@ class ScriptTemplateTest { @Test fun testScriptWithNullableProjection() { - val aClass = compileScript("nullable_projection.kts", ScriptWithNullableProjection::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("nullable_projection.kts", ScriptWithNullableProjection::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Array::class.java).newInstance(arrayOf(null)) }.let { @@ -186,8 +197,9 @@ class ScriptTemplateTest { @Test fun testScriptWithArray2DParam() { - val aClass = compileScript("array2d_param.kts", ScriptWithArray2DParam::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("array2d_param.kts", ScriptWithArray2DParam::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Array>::class.java).newInstance(arrayOf(arrayOf("one"), arrayOf("two"))) }.let { @@ -197,8 +209,9 @@ class ScriptTemplateTest { @Test fun testScriptWithStandardTemplate() { - val aClass = compileScript("fib_std.kts", ScriptTemplateWithArgs::class, runIsolated = false) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib_std.kts", ScriptTemplateWithArgs::class, runIsolated = false, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Array::class.java).newInstance(arrayOf("4", "other")) }.let { @@ -208,8 +221,9 @@ class ScriptTemplateTest { @Test fun testScriptWithPackage() { - val aClass = compileScript("fib.pkg.kts", ScriptWithIntParam::class) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.pkg.kts", ScriptWithIntParam::class, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) }.let { @@ -219,8 +233,9 @@ class ScriptTemplateTest { @Test fun testScriptWithScriptDefinition() { - val aClass = compileScript("fib.kts", ScriptWithIntParam::class) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithIntParam::class, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) }.let { @@ -230,8 +245,9 @@ class ScriptTemplateTest { @Test fun testScriptWithParamConversion() { - val aClass = compileScript("fib.kts", ScriptWithIntParam::class) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithIntParam::class, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) captureOut { val anObj = tryConstructClassFromStringArgs(aClass!!, listOf("4")) Assert.assertNotNull(anObj) @@ -253,8 +269,9 @@ class ScriptTemplateTest { @Test fun testAsyncResolver() { - val aClass = compileScript("fib.kts", ScriptWithAsyncResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithAsyncResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) } @@ -263,32 +280,37 @@ class ScriptTemplateTest { @Test fun testAcceptedAnnotationsSync() { - val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsSyncResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsSyncResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) } @Test fun testAcceptedAnnotationsAsync() { - val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsAsyncResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsAsyncResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) } @Test fun testAcceptedAnnotationsLegacy() { - val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsLegacyResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("acceptedAnnotations.kts", ScriptWithAcceptedAnnotationsLegacyResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) } @Test fun testSeveralConstructors() { - val aClass = compileScript("fib.kts", ScriptWithSeveralConstructorsResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithSeveralConstructorsResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) } @Test fun testConstructorWithDefaultArgs() { - val aClass = compileScript("fib.kts", ScriptWithDefaultArgsResolver::class, null) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("fib.kts", ScriptWithDefaultArgsResolver::class, null, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) } @Test @@ -301,8 +323,9 @@ class ScriptTemplateTest { @Test fun testSmokeScriptException() { - val aClass = compileScript("smoke_exception.kts", ScriptWithArrayParam::class) - Assert.assertNotNull(aClass) + val messageCollector = TestMessageCollector() + val aClass = compileScript("smoke_exception.kts", ScriptWithArrayParam::class, messageCollector = messageCollector) + Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) var exceptionThrown = false try { tryConstructClassFromStringArgs(aClass!!, emptyList()) @@ -349,7 +372,12 @@ class ScriptTemplateTest { ): Class<*>? { val rootDisposable = Disposer.newDisposable() try { - val configuration = KotlinTestUtils.newConfiguration(if (includeKotlinRuntime) ConfigurationKind.ALL else ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK) + val additionalClasspath = System.getProperty("kotlin.test.script.classpath")?.split(File.pathSeparator) + ?.map{ File(it) }.orEmpty().toTypedArray() + val configuration = KotlinTestUtils.newConfiguration( + if (includeKotlinRuntime) ConfigurationKind.ALL else ConfigurationKind.JDK_ONLY, + TestJdkKind.FULL_JDK, + *additionalClasspath) configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector) configuration.addKotlinSourceRoot(scriptPath) configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, scriptDefinition) diff --git a/compiler/util/build.gradle.kts b/compiler/util/build.gradle.kts index f3efb33bdb6..ab80675dff5 100644 --- a/compiler/util/build.gradle.kts +++ b/compiler/util/build.gradle.kts @@ -1,6 +1,8 @@ apply { plugin("kotlin") } +jvmTarget = "1.6" + dependencies { compile(project(":core")) compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) diff --git a/core/util.runtime/build.gradle.kts b/core/util.runtime/build.gradle.kts index ad5a5cb9430..a46670ea353 100644 --- a/core/util.runtime/build.gradle.kts +++ b/core/util.runtime/build.gradle.kts @@ -8,7 +8,7 @@ jvmTarget = "1.6" dependencies { compile(project(":core:builtins")) - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) } sourceSets { diff --git a/eval4j/build.gradle.kts b/eval4j/build.gradle.kts index a1b3c4e164f..15d4a181c23 100644 --- a/eval4j/build.gradle.kts +++ b/eval4j/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) - compile(project(":kotlin-reflect")) + compile(projectDist(":kotlin-stdlib")) + compile(projectDist(":kotlin-reflect")) compile(project(":compiler:backend")) compile(ideaSdkDeps("asm-all")) // compile(files(PathUtil.getJdkClassesRootsFromCurrentJre())) // TODO: make this one work instead of the nex one, since it contains more universal logic compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) - testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testCompile(commonDep("junit:junit")) } sourceSets { diff --git a/generators/build.gradle.kts b/generators/build.gradle.kts index 664428c9ee8..d04f348895d 100644 --- a/generators/build.gradle.kts +++ b/generators/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { compile(project(":js:js.ast")) compile(project(":js:js.frontend")) compile(project(":idea:idea-test-framework")) - compile(project(":kotlin-test:kotlin-test-jvm")) + compile(projectDist(":kotlin-test:kotlin-test-jvm")) compile(projectTests(":kotlin-build-common")) compile(projectTests(":compiler")) compile(projectTests(":compiler:tests-java8")) diff --git a/gradle/project-schema.json b/gradle/project-schema.json index e1c128db2fc..ab6e7a4bdfd 100644 --- a/gradle/project-schema.json +++ b/gradle/project-schema.json @@ -26,6 +26,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -397,6 +398,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -436,6 +438,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -508,6 +511,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -580,6 +584,7 @@ "archives", "compilerJar", "default", + "distJar", "fatJar", "fatJarContents", "fatSourcesJarContents", @@ -664,6 +669,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -708,6 +714,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptAgp25", @@ -749,6 +756,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -876,6 +884,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -915,6 +924,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -952,6 +962,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -989,6 +1000,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1032,6 +1044,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1069,6 +1082,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1107,6 +1121,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1146,6 +1161,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1183,6 +1199,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1261,6 +1278,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1312,6 +1330,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptAnnotations", @@ -1353,6 +1372,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "runtime", "runtimeClasspath", @@ -1388,6 +1408,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1426,6 +1447,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -1471,6 +1493,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "merger", "nodeDist", @@ -1751,6 +1774,41 @@ "reporting": "org.gradle.api.reporting.ReportingExtension" } }, + ":compiler:conditional-preprocessor": { + "conventions": { + "base": "org.gradle.api.plugins.BasePluginConvention", + "java": "org.gradle.api.plugins.JavaPluginConvention" + }, + "configurations": [ + "apiElements", + "archives", + "compile", + "compileClasspath", + "compileOnly", + "default", + "implementation", + "kapt", + "kaptTest", + "runtime", + "runtimeClasspath", + "runtimeElements", + "runtimeOnly", + "testCompile", + "testCompileClasspath", + "testCompileOnly", + "testImplementation", + "testRuntime", + "testRuntimeClasspath", + "testRuntimeOnly" + ], + "extensions": { + "ext": "org.gradle.api.plugins.ExtraPropertiesExtension", + "kotlin": "org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension", + "kapt": "org.jetbrains.kotlin.gradle.plugin.KaptExtension", + "defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet", + "reporting": "org.gradle.api.reporting.ReportingExtension" + } + }, ":compiler:container": { "conventions": { "base": "org.gradle.api.plugins.BasePluginConvention", @@ -1787,6 +1845,41 @@ "reporting": "org.gradle.api.reporting.ReportingExtension" } }, + ":compiler:daemon": { + "conventions": { + "base": "org.gradle.api.plugins.BasePluginConvention", + "java": "org.gradle.api.plugins.JavaPluginConvention" + }, + "configurations": [ + "apiElements", + "archives", + "compile", + "compileClasspath", + "compileOnly", + "default", + "implementation", + "kapt", + "kaptTest", + "runtime", + "runtimeClasspath", + "runtimeElements", + "runtimeOnly", + "testCompile", + "testCompileClasspath", + "testCompileOnly", + "testImplementation", + "testRuntime", + "testRuntimeClasspath", + "testRuntimeOnly" + ], + "extensions": { + "ext": "org.gradle.api.plugins.ExtraPropertiesExtension", + "kotlin": "org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension", + "kapt": "org.jetbrains.kotlin.gradle.plugin.KaptExtension", + "defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet", + "reporting": "org.gradle.api.reporting.ReportingExtension" + } + }, ":compiler:daemon-common": { "conventions": { "base": "org.gradle.api.plugins.BasePluginConvention", @@ -3083,6 +3176,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "runtime", "runtimeClasspath", @@ -3118,6 +3212,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implement", "implementation", "runtime", @@ -3154,6 +3249,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", @@ -3192,6 +3288,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implement", "implementation", "kapt", @@ -3720,6 +3817,7 @@ "compileClasspath", "compileOnly", "default", + "distJar", "implementation", "kapt", "kaptTest", diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 6da54c39927..65aa4fcb3b1 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -2,11 +2,11 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":core")) compile(project(":compiler:backend")) compile(project(":compiler:cli-common")) - compile(project(":kotlin-daemon-client")) + compile(projectDist(":kotlin-daemon-client")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) compile(project(":compiler:frontend.script")) @@ -45,10 +45,11 @@ dependencies { compile(preloadedDeps("markdown", "kotlinx-coroutines-core")) - testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) testCompile(project(":compiler:cli")) testCompile(project(":compiler.tests-common")) testCompile(project(":idea:idea-test-framework")) { isTransitive = false } + testCompile(commonDep("junit:junit")) testCompileOnly(ideaPluginDeps("gradle-base-services", "gradle-tooling-extension-impl", "gradle-wrapper", plugin = "gradle")) testCompileOnly(ideaPluginDeps("Groovy", plugin = "Groovy")) diff --git a/idea/idea-android/build.gradle.kts b/idea/idea-android/build.gradle.kts index a740046465c..fa33f79ed69 100644 --- a/idea/idea-android/build.gradle.kts +++ b/idea/idea-android/build.gradle.kts @@ -2,7 +2,7 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-reflect")) + compile(projectDist(":kotlin-reflect")) compile(project(":compiler:util")) compile(project(":compiler:light-classes")) compile(project(":compiler:frontend")) @@ -15,13 +15,14 @@ dependencies { compile(ideaPluginDeps("android", "android-common", "sdklib", "sdk-common", "layoutlib-api", plugin = "android")) compile(preloadedDeps("dx", subdir = "android-5.0/lib")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(project(":compiler.tests-common")) testCompile(project(":idea:idea-test-framework")) { isTransitive = false } testCompile(project(":plugins:lint")) { isTransitive = false } testCompile(projectTests(":idea")) testCompile(ideaPluginDeps("properties", plugin = "properties")) testCompile(ideaSdkDeps("gson")) + testCompile(commonDep("junit:junit")) testRuntime(project(":plugins:android-extensions-idea")) testRuntime(project(":plugins:sam-with-receiver-ide")) diff --git a/idea/idea-core/build.gradle.kts b/idea/idea-core/build.gradle.kts index 8ee0d7ee4f3..8978a0079df 100644 --- a/idea/idea-core/build.gradle.kts +++ b/idea/idea-core/build.gradle.kts @@ -1,7 +1,7 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":core")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) diff --git a/idea/idea-jps-common/build.gradle.kts b/idea/idea-jps-common/build.gradle.kts index ab1719ae365..bb73a4bdde6 100644 --- a/idea/idea-jps-common/build.gradle.kts +++ b/idea/idea-jps-common/build.gradle.kts @@ -2,7 +2,7 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":compiler:util")) compile(project(":compiler:cli-common")) compile(project(":compiler:frontend.java")) diff --git a/idea/kotlin-gradle-tooling/build.gradle.kts b/idea/kotlin-gradle-tooling/build.gradle.kts index faa89b23792..2d452504f39 100644 --- a/idea/kotlin-gradle-tooling/build.gradle.kts +++ b/idea/kotlin-gradle-tooling/build.gradle.kts @@ -4,7 +4,7 @@ description = "Kotlin Gradle Tooling support" apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":compiler:cli-common")) compile(ideaSdkDeps("gradle-tooling-api", "gradle-tooling-extension-api", diff --git a/j2k/build.gradle.kts b/j2k/build.gradle.kts index 1f1262b08bd..c90ba793fba 100644 --- a/j2k/build.gradle.kts +++ b/j2k/build.gradle.kts @@ -6,7 +6,7 @@ apply { plugin("kotlin") } //} dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) compile(project(":compiler:light-classes")) @@ -15,30 +15,30 @@ dependencies { testCompile(project(":idea")) testCompile(project(":idea:idea-test-framework")) testCompile(project(":compiler:light-classes")) - testCompile(project(":kotlin-test:kotlin-test-junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testCompile(commonDep("junit:junit")) testCompile(project(":compiler.tests-common")) -// testRuntime(project(":idea:idea-android")) -// testRuntime(project(":plugins:android-extensions-idea")) -// testRuntime(project(":plugins:sam-with-receiver-ide")) -// testRuntime(project(":plugins:allopen-ide")) -// testRuntime(project(":plugins:noarg-ide")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:android-extensions-idea")) + testRuntime(project(":plugins:sam-with-receiver-ide")) + testRuntime(project(":plugins:allopen-ide")) + testRuntime(project(":plugins:noarg-ide")) testRuntime(ideaSdkDeps("*.jar")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "junit")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "testng")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "properties")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "gradle")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "maven")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "android")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "junit")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "IntelliLang")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "testng")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "copyright")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "properties")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "java-i18n")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) -// testRuntime(ideaPluginDeps("*.jar", plugin = "java-decompiler")) + testRuntime(ideaPluginDeps("*.jar", plugin = "properties")) + testRuntime(ideaPluginDeps("*.jar", plugin = "gradle")) + testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy")) + testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) + testRuntime(ideaPluginDeps("*.jar", plugin = "maven")) + testRuntime(ideaPluginDeps("*.jar", plugin = "android")) + testRuntime(ideaPluginDeps("*.jar", plugin = "junit")) + testRuntime(ideaPluginDeps("*.jar", plugin = "testng")) + testRuntime(ideaPluginDeps("*.jar", plugin = "IntelliLang")) + testRuntime(ideaPluginDeps("*.jar", plugin = "testng")) + testRuntime(ideaPluginDeps("*.jar", plugin = "copyright")) + testRuntime(ideaPluginDeps("*.jar", plugin = "properties")) + testRuntime(ideaPluginDeps("*.jar", plugin = "java-i18n")) + testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) + testRuntime(ideaPluginDeps("*.jar", plugin = "java-decompiler")) } sourceSets { diff --git a/jps-plugin/build.gradle.kts b/jps-plugin/build.gradle.kts index 36043244ed9..9261fc7ebc4 100644 --- a/jps-plugin/build.gradle.kts +++ b/jps-plugin/build.gradle.kts @@ -7,9 +7,9 @@ dependencies { compile(project(":core")) compile(project(":compiler:compiler-runner")) compile(project(":compiler:daemon-common")) - compile(project(":kotlin-daemon-client")) + compile(projectDist(":kotlin-daemon-client")) compile(project(":compiler:frontend.java")) - compile(project(":kotlin-preloader")) + compile(projectDist(":kotlin-preloader")) compile(project(":idea:idea-jps-common")) compile(ideaSdkDeps("jps-builders", "jps-builders-6", subdir = "jps")) testCompile(project(":compiler.tests-common")) @@ -17,7 +17,7 @@ dependencies { testCompile(projectTests(":compiler:incremental-compilation-impl")) testCompileOnly(ideaSdkDeps("jps-build-test", subdir = "jps/test")) testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(projectTests(":kotlin-build-common")) compilerModules.forEach { testRuntime(project(it)) diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 70d19c15453..820cb837e1d 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -10,9 +10,10 @@ dependencies { testCompile(project(":js:js.serializer")) testCompile(project(":js:js.dce")) testCompile(ideaSdkDeps("openapi", "idea")) - testRuntime(project(":kotlin-stdlib")) + testRuntime(projectDist(":kotlin-stdlib")) testRuntime(project(":compiler:backend-common")) testRuntime(ideaSdkDeps("*.jar")) + testRuntime(commonDep("org.fusesource.jansi", "jansi")) } sourceSets { @@ -20,14 +21,22 @@ sourceSets { "test" { projectDefault() } } -val test: Test by tasks -test.apply { - dependsOnTaskIfExistsRec("dist", project = rootProject) - dependsOn(":prepare:mock-runtime-for-test:dist") +val testDistProjects = listOf( + "", // for root project + ":prepare:mock-runtime-for-test", + ":kotlin-compiler", + ":kotlin-runtime", + ":kotlin-script-runtime", + ":kotlin-stdlib", + ":kotlin-stdlib-js", + ":kotlin-test:kotlin-test-jvm", + ":kotlin-test:kotlin-test-junit", + ":kotlin-daemon-client", + ":kotlin-ant") + +projectTest { + dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } testsJar {} diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index 04406cd9a6a..2bbfed19208 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -131,9 +131,18 @@ ext.configurePublishing = { Project project -> } } + configurations { + distJar + } + task dist(type: Copy, dependsOn: assemble) { rename "-${java.util.regex.Pattern.quote(version)}", '' into distLibDir + afterEvaluate { + project.artifacts { + distJar file: file("$distLibDir${File.separator}${archivesBaseName}.jar"), builtBy: "dist" + } + } } uploadArchives { diff --git a/libraries/examples/annotation-processor-example/build.gradle.kts b/libraries/examples/annotation-processor-example/build.gradle.kts index 0c7ce281bb4..99262df6d1d 100644 --- a/libraries/examples/annotation-processor-example/build.gradle.kts +++ b/libraries/examples/annotation-processor-example/build.gradle.kts @@ -3,7 +3,7 @@ description = "Simple Annotation Processor for testing kapt" apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) } sourceSets { diff --git a/libraries/examples/kotlin-gradle-subplugin-example/build.gradle b/libraries/examples/kotlin-gradle-subplugin-example/build.gradle index 6b104ca99a4..0128ab8d891 100644 --- a/libraries/examples/kotlin-gradle-subplugin-example/build.gradle +++ b/libraries/examples/kotlin-gradle-subplugin-example/build.gradle @@ -14,7 +14,7 @@ dependencies { compile project(':kotlin-test::kotlin-test-junit') - compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compileOnly project(path: ":kotlin-stdlib", configuration: "distJar") compileOnly project(':compiler') compileOnly project(':compiler:plugin-api') compileOnly project(':compiler:cli-common') diff --git a/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts b/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts index bc3bf61b571..f21ecf49421 100644 --- a/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts +++ b/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts @@ -4,13 +4,14 @@ description = "Sample Kotlin JSR 223 scripting jar with daemon (out-of-process) apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) - compile(project(":kotlin-script-runtime")) + compile(projectDist(":kotlin-stdlib")) + compile(projectDist(":kotlin-script-runtime")) compile(projectRuntimeJar(":kotlin-compiler")) compile(project(":kotlin-script-util")) compile(projectRuntimeJar(":kotlin-daemon-client")) - testCompile(project(":kotlin-test:kotlin-test-junit")) - testRuntime(project(":kotlin-reflect")) + testCompile(commonDep("junit:junit")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testRuntime(projectDist(":kotlin-reflect")) } projectTest() diff --git a/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts b/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts index 47b45cf2559..80323292fe2 100644 --- a/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts +++ b/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts @@ -4,12 +4,13 @@ description = "Sample Kotlin JSR 223 scripting jar with local (in-process) compi apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) - compile(project(":kotlin-script-runtime")) + compile(projectDist(":kotlin-stdlib")) + compile(projectDist(":kotlin-script-runtime")) compile(projectRuntimeJar(":kotlin-compiler")) compile(project(":kotlin-script-util")) - testCompile(project(":kotlin-test:kotlin-test-junit")) - testRuntime(project(":kotlin-reflect")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testCompile(commonDep("junit:junit")) + testRuntime(projectDist(":kotlin-reflect")) } projectTest() diff --git a/libraries/tools/kotlin-annotation-processing/build.gradle.kts b/libraries/tools/kotlin-annotation-processing/build.gradle.kts index d9752a09763..f317e7fe13a 100644 --- a/libraries/tools/kotlin-annotation-processing/build.gradle.kts +++ b/libraries/tools/kotlin-annotation-processing/build.gradle.kts @@ -5,7 +5,7 @@ dependencies { compile(project(":plugins:kapt3")) compileOnly("org.jetbrains.kotlin:gradle-api:1.6") compileOnly("com.android.tools.build:gradle:1.1.0") - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) testCompile(commonDep("junit:junit")) } diff --git a/libraries/tools/kotlin-script-util/build.gradle.kts b/libraries/tools/kotlin-script-util/build.gradle.kts index f18e8045996..e923e516d7c 100644 --- a/libraries/tools/kotlin-script-util/build.gradle.kts +++ b/libraries/tools/kotlin-script-util/build.gradle.kts @@ -4,15 +4,16 @@ description = "Kotlin scripting support utilities" apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) - compile(project(":kotlin-script-runtime")) + compile(projectDist(":kotlin-stdlib")) + compile(projectDist(":kotlin-script-runtime")) compile(projectRuntimeJar(":kotlin-compiler")) compile(projectRuntimeJar(":kotlin-daemon-client")) compileOnly("com.jcabi:jcabi-aether:0.10.1") compileOnly("org.sonatype.aether:aether-api:1.13.1") compileOnly("org.apache.maven:maven-core:3.0.3") - testCompile(project(":kotlin-test:kotlin-test-junit")) - testRuntime(project(":kotlin-reflect")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testRuntime(projectDist(":kotlin-reflect")) + testCompile(commonDep("junit:junit")) testRuntime("com.jcabi:jcabi-aether:0.10.1") testRuntime("org.sonatype.aether:aether-api:1.13.1") testRuntime("org.apache.maven:maven-core:3.0.3") diff --git a/plugins/allopen/allopen-cli/build.gradle.kts b/plugins/allopen/allopen-cli/build.gradle.kts index 5108286b0cc..a93c077ae06 100644 --- a/plugins/allopen/allopen-cli/build.gradle.kts +++ b/plugins/allopen/allopen-cli/build.gradle.kts @@ -7,8 +7,8 @@ dependencies { compileOnly(ideaSdkCoreDeps("intellij-core")) compileOnly(project(":compiler:plugin-api")) compileOnly(project(":compiler:frontend")) - runtime(project(":kotlin-compiler", configuration = "runtimeJar")) - runtime(project(":kotlin-stdlib")) + runtime(projectDist(":kotlin-compiler")) + runtime(projectDist(":kotlin-stdlib")) } sourceSets { @@ -20,10 +20,7 @@ val jar = runtimeJar { from(fileTree("$projectDir/src")) { include("META-INF/**") } } -dist { - from(jar) - rename("^kotlin-", "") -} +dist(targetName = the().archivesBaseName.removePrefix("kotlin-") + ".jar") ideaPlugin { from(jar) diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index 58bcc77bfaa..f6d1fa03c95 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -17,7 +17,8 @@ dependencies { testCompile(project(":idea:idea-test-framework")) { isTransitive = false } testCompile(projectTests(":idea")) testCompile(projectTests(":idea:idea-android")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) + testCompile(commonDep("junit:junit")) testRuntime(project(":plugins:android-extensions-jps")) testRuntime(project(":plugins:sam-with-receiver-ide")) testRuntime(project(":plugins:noarg-ide")) diff --git a/plugins/noarg/noarg-cli/build.gradle.kts b/plugins/noarg/noarg-cli/build.gradle.kts index aed5d1df32a..b27006fa48b 100644 --- a/plugins/noarg/noarg-cli/build.gradle.kts +++ b/plugins/noarg/noarg-cli/build.gradle.kts @@ -9,8 +9,8 @@ dependencies { compileOnly(project(":compiler:backend")) compileOnly(project(":compiler:util")) compileOnly(project(":compiler:plugin-api")) - runtime(project(":kotlin-compiler", configuration = "runtimeJar")) - runtime(project(":kotlin-stdlib")) + runtime(projectDist(":kotlin-compiler")) + runtime(projectDist(":kotlin-stdlib")) } sourceSets { @@ -22,10 +22,7 @@ val jar = runtimeJar { from(fileTree("$projectDir/src")) { include("META-INF/**") } } -dist { - from(jar) - rename("^kotlin-", "") -} +dist(targetName = the().archivesBaseName.removePrefix("kotlin-") + ".jar") ideaPlugin { from(jar) diff --git a/plugins/plugins-tests/build.gradle.kts b/plugins/plugins-tests/build.gradle.kts index a93463e216a..aa182c20bb8 100644 --- a/plugins/plugins-tests/build.gradle.kts +++ b/plugins/plugins-tests/build.gradle.kts @@ -18,8 +18,9 @@ dependencies { testCompile(project(":idea:idea-android")) { isTransitive = false } testCompile(project(":plugins:lint")) { isTransitive = false } testCompile(project(":plugins:uast-kotlin")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(projectTests(":jps-plugin")) + testCompile(commonDep("junit:junit")) testCompileOnly(ideaSdkDeps("jps-builders")) testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test")) testCompile(ideaPluginDeps("*.jar", plugin = "android", subdir = "lib/jps")) @@ -37,12 +38,8 @@ sourceSets { testsJar {} -val test: Test by tasks -test.apply { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } 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 a51b281f26c..ae839c8cfd0 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,8 +7,8 @@ dependencies { compileOnly(project(":compiler:frontend")) compileOnly(project(":compiler:frontend.java")) compileOnly(project(":compiler:plugin-api")) - runtime(project(":kotlin-compiler", configuration = "runtimeJar")) - runtime(project(":kotlin-stdlib")) + runtime(projectDist(":kotlin-compiler")) + runtime(projectDist(":kotlin-stdlib")) } sourceSets { @@ -24,10 +24,7 @@ javadocJar() publish() -dist { - from(jar) - rename("^kotlin-", "") -} +dist(targetName = the().archivesBaseName.removePrefix("kotlin-") + ".jar") ideaPlugin { from(jar) diff --git a/plugins/uast-kotlin-idea/build.gradle.kts b/plugins/uast-kotlin-idea/build.gradle.kts index 377dd1cdfd2..6dd212a35c7 100644 --- a/plugins/uast-kotlin-idea/build.gradle.kts +++ b/plugins/uast-kotlin-idea/build.gradle.kts @@ -2,7 +2,7 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":core:util.runtime")) compile(project(":compiler:backend")) compile(project(":compiler:frontend.java")) diff --git a/plugins/uast-kotlin/build.gradle.kts b/plugins/uast-kotlin/build.gradle.kts index 97e478a232d..21f1701be12 100644 --- a/plugins/uast-kotlin/build.gradle.kts +++ b/plugins/uast-kotlin/build.gradle.kts @@ -2,14 +2,14 @@ apply { plugin("kotlin") } dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) compile(project(":core:util.runtime")) compile(project(":compiler:backend")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) compile(project(":compiler:light-classes")) compileOnly(ideaSdkDeps("openapi", "idea")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(project(":compiler.tests-common")) testCompile(commonDep("junit:junit")) testCompile(project(":compiler:util")) diff --git a/prepare/compiler-client-embeddable/build.gradle.kts b/prepare/compiler-client-embeddable/build.gradle.kts index 5777687ad07..6945105c6d2 100644 --- a/prepare/compiler-client-embeddable/build.gradle.kts +++ b/prepare/compiler-client-embeddable/build.gradle.kts @@ -35,11 +35,11 @@ dependencies { testCompile(project(it)) } testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) - testCompile(project(":kotlin-test:kotlin-test-junit")) - testRuntimeCompilerJar(project(":kotlin-compiler", configuration = "runtimeJar")) - testStdlibJar(project(":kotlin-stdlib", configuration = "mainJar")) - testScriptRuntimeJar(project(":kotlin-script-runtime", configuration = "mainJar")) + testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) + testCompile(projectDist(":kotlin-test:kotlin-test-junit")) + testRuntimeCompilerJar(projectDist(":kotlin-compiler")) + testStdlibJar(projectDist(":kotlin-stdlib")) + testScriptRuntimeJar(projectDist(":kotlin-script-runtime")) } sourceSets { diff --git a/prepare/compiler-embeddable/build.gradle.kts b/prepare/compiler-embeddable/build.gradle.kts index 0e3246d40b3..4874fcd0763 100644 --- a/prepare/compiler-embeddable/build.gradle.kts +++ b/prepare/compiler-embeddable/build.gradle.kts @@ -30,7 +30,7 @@ val packagesToRelocate = "org.fusesource") dependencies { - compilerJar(project(":kotlin-compiler", configuration = "runtimeJar")) + compilerJar(projectDist(":kotlin-compiler")) } runtimeJar(task("embeddable")) { diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 08636dc5862..55cd8514d8e 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -88,9 +88,9 @@ dependencies { proguardLibraryJars(files(firstFromJavaHomeThatExists("lib/rt.jar", "../Classes/classes.jar"), firstFromJavaHomeThatExists("lib/jsse.jar", "../Classes/jsse.jar"), firstFromJavaHomeThatExists("../lib/tools.jar", "../Classes/tools.jar"))) - proguardLibraryJars(project(":kotlin-stdlib", configuration = "mainJar")) - proguardLibraryJars(project(":kotlin-script-runtime", configuration = "mainJar")) - proguardLibraryJars(project(":kotlin-reflect", configuration = "mainJar")) + proguardLibraryJars(projectDist(":kotlin-stdlib")) + proguardLibraryJars(projectDist(":kotlin-script-runtime")) + proguardLibraryJars(projectDist(":kotlin-reflect")) proguardLibraryJars(preloadedDeps("kotlinx-coroutines-core")) } @@ -98,7 +98,6 @@ val packCompiler by task { configurations = listOf(fatJar) duplicatesStrategy = DuplicatesStrategy.EXCLUDE destinationDir = File(buildDir, "libs") -// baseName = compilerBaseName dependsOn(protobufFullTask) setupPublicJar("before-proguard", "") @@ -130,14 +129,9 @@ val proguard by task { printconfiguration("$buildDir/compiler.pro.dump") } -dist { - if (shrink) { - from(proguard) - } else { - from(packCompiler) - } - rename(".*", compilerBaseName + ".jar") -} +dist(targetName = compilerBaseName + ".jar", + fromTask = if (shrink) proguard + else packCompiler) runtimeJarArtifactBy(proguard, proguard.outputs.files.singleFile) { name = compilerBaseName diff --git a/prepare/kotlin-plugin/build.gradle.kts b/prepare/kotlin-plugin/build.gradle.kts index 2938789f776..60cb2634115 100644 --- a/prepare/kotlin-plugin/build.gradle.kts +++ b/prepare/kotlin-plugin/build.gradle.kts @@ -56,7 +56,7 @@ val sideJars by configurations.creating dependencies { packedJars(commonDep("com.github.spullara.cli-parser", "cli-parser")) packedJars(preloadedDeps("protobuf-${rootProject.extra["versions.protobuf-java"]}")) - sideJars(project(":kotlin-script-runtime")) + sideJars(projectDist(":kotlin-script-runtime")) sideJars(commonDep("io.javaslang", "javaslang")) sideJars(commonDep("javax.inject")) sideJars(preloadedDeps("markdown", "kotlinx-coroutines-core", "kotlinx-coroutines-jdk8")) diff --git a/prepare/mock-runtime-for-test/build.gradle.kts b/prepare/mock-runtime-for-test/build.gradle.kts index 7542c1cfd73..58310129454 100644 --- a/prepare/mock-runtime-for-test/build.gradle.kts +++ b/prepare/mock-runtime-for-test/build.gradle.kts @@ -7,7 +7,7 @@ jvmTarget = "1.6" javaHome = rootProject.extra["JDK_16"] as String dependencies { - compile(project(":kotlin-stdlib")) + compile(projectDist(":kotlin-stdlib")) } sourceSets { @@ -34,12 +34,8 @@ tasks.withType { val jar = runtimeJar { from(fileTree("${rootProject.extra["distDir"]}/builtins")) { include("kotlin/**") } - archiveName = "kotlin-mock-runtime-for-test.jar" } -task("dist") { - from(jar) - into(rootProject.extra["distDir"].toString()) - rename("-${Regex.escape(rootProject.extra["build.number"].toString())}", "") -} +val distDir: String by rootProject.extra +dist(targetName = "kotlin-mock-runtime-for-test.jar", targetDir = File(distDir))