From 3e46c5918770ee558ba031a2741aa40f562902cf Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Tue, 22 Aug 2017 16:23:42 +0200 Subject: [PATCH] Clean unused dependencies, minor refactorings --- .idea/.name | 2 +- build.gradle.kts | 17 +-- compiler/build.gradle.kts | 2 - compiler/cli/cli-runner/build.gradle.kts | 2 - compiler/preloader/build.gradle.kts | 2 - core/build.gradle.kts | 1 - core/builtins/build.gradle.kts | 1 - core/reflection.jvm/build.gradle.kts | 1 - core/script.runtime/build.gradle.kts | 24 ---- eval4j/build.gradle.kts | 2 +- gradle/project-schema.json | 109 +++++---------- idea/kotlin-gradle-tooling/build.gradle.kts | 10 +- plugins/allopen/allopen-cli/build.gradle.kts | 2 - plugins/allopen/allopen-ide/build.gradle.kts | 11 +- .../android-extensions-idea/build.gradle.kts | 14 +- plugins/noarg/noarg-ide/build.gradle.kts | 10 +- .../sam-with-receiver-cli/build.gradle.kts | 2 - .../sam-with-receiver-ide/build.gradle.kts | 11 +- plugins/uast-kotlin-idea/build.gradle.kts | 1 - prepare/android-lint/build.gradle.kts | 24 ++-- .../build.gradle.kts | 1 - prepare/compiler/build.gradle.kts | 13 +- prepare/formatter/build.gradle.kts | 5 +- prepare/ide-lazy-resolver/build.gradle.kts | 5 +- prepare/kotlin-plugin/build.gradle.kts | 12 +- .../mock-runtime-for-test/build.gradle.kts | 29 ++-- prepare/reflect/build.gradle.kts | 131 ------------------ prepare/runtime/build.gradle.kts | 39 ------ settings.gradle | 4 +- 29 files changed, 90 insertions(+), 397 deletions(-) delete mode 100644 core/script.runtime/build.gradle.kts delete mode 100644 prepare/reflect/build.gradle.kts delete mode 100644 prepare/runtime/build.gradle.kts diff --git a/.idea/.name b/.idea/.name index c163a967b87..3e7d3e5d71f 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -kotlin \ No newline at end of file +kotlin gradle \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 0208c9770e6..4bcbeaff98f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,6 @@ import org.gradle.api.Project import java.util.* import java.io.File import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.java import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile @@ -31,8 +30,6 @@ buildscript { } plugins { -// java // so we can benefit from the `java()` accessor below -// kotlin("jvm") `build-scan` } @@ -85,11 +82,6 @@ extra["JDK_16"] = jdkPath("1.6") extra["JDK_17"] = jdkPath("1.7") extra["JDK_18"] = jdkPath("1.8") -extra["compilerBaseName"] = "kotlin-compiler" -extra["embeddableCompilerBaseName"] = "kotlin-compiler-embeddable" - -extra["buildLocalRepoPath"] = File(commonBuildDir, "repo") - extra["versions.protobuf-java"] = "2.6.1" extra["versions.javax.inject"] = "1" extra["versions.jsr305"] = "1.3.9" @@ -158,10 +150,6 @@ tasks.matching { task -> // dependsOn(tasks.getByName(importedAntTasksPrefix + "update")) //} -//val prepareBootstrapTask = task("prepareBootstrap") { -// dependsOn(bootstrapCfg, scriptCompileCfg, scriptRuntimeCfg) -//} - fun Project.allprojectsRecursive(body: Project.() -> Unit) { this.body() this.subprojects { allprojectsRecursive(body) } @@ -187,12 +175,11 @@ allprojects { configureJvmProject(javaHome!!, jvmTarget!!) tasks.withType { - kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name) -// kotlinOptions.jvmTarget = "1.8" + kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package") } tasks.withType { - kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name) + kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package") } tasks.withType { diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 394c7cd49b7..d93a8760eb5 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -37,8 +37,6 @@ dependencies { testRuntime(ideaSdkCoreDeps("*.jar")) testRuntime(ideaSdkDeps("*.jar")) // testRuntime(project(":kotlin-compiler", configuration = "default")) - - buildVersion() } sourceSets { diff --git a/compiler/cli/cli-runner/build.gradle.kts b/compiler/cli/cli-runner/build.gradle.kts index d9db3f741e1..bf20aa440b3 100644 --- a/compiler/cli/cli-runner/build.gradle.kts +++ b/compiler/cli/cli-runner/build.gradle.kts @@ -6,9 +6,7 @@ apply { plugin("kotlin") } jvmTarget = "1.6" dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) - buildVersion() } sourceSets { diff --git a/compiler/preloader/build.gradle.kts b/compiler/preloader/build.gradle.kts index 1079bf7962f..18d886319a7 100644 --- a/compiler/preloader/build.gradle.kts +++ b/compiler/preloader/build.gradle.kts @@ -6,9 +6,7 @@ apply { plugin("kotlin") } jvmTarget = "1.6" dependencies { - val compile by configurations compile(ideaSdkDeps("asm-all")) - buildVersion() } sourceSets { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 522d80f1fc4..3927f29b7f8 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,7 +7,6 @@ apply { plugin("kotlin") } jvmTarget = "1.6" dependencies { - val compile by configurations compile(project(":core:builtins")) compile(project("util.runtime")) compile(protobufLite()) diff --git a/core/builtins/build.gradle.kts b/core/builtins/build.gradle.kts index ddb9f27b2ee..e2ea4075680 100644 --- a/core/builtins/build.gradle.kts +++ b/core/builtins/build.gradle.kts @@ -17,7 +17,6 @@ val builtinsSerialized = File(rootProject.extra["distDir"].toString(), "builtins val builtins by configurations.creating dependencies { - val compile by configurations compile(protobufLite()) compile(files(builtinsSerialized)) } diff --git a/core/reflection.jvm/build.gradle.kts b/core/reflection.jvm/build.gradle.kts index 22218634aec..ebda78a2640 100644 --- a/core/reflection.jvm/build.gradle.kts +++ b/core/reflection.jvm/build.gradle.kts @@ -22,7 +22,6 @@ apply { jvmTarget = "1.6" dependencies { - val compile by configurations compile(project(":core:builtins")) compile(project(":core")) compile(protobufLite()) diff --git a/core/script.runtime/build.gradle.kts b/core/script.runtime/build.gradle.kts deleted file mode 100644 index cd80316909d..00000000000 --- a/core/script.runtime/build.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ - -import org.gradle.jvm.tasks.Jar - -apply { plugin("kotlin") } - -jvmTarget = "1.6" - -dependencies { - val compile by configurations - compile(project(":core:builtins")) - compile(project(":kotlin-stdlib")) - buildVersion() -} - -sourceSets { - "main" { projectDefault() } - "test" {} -} - -tasks.withType { - setupRuntimeJar("Kotlin Script Runtime") - archiveName = "kotlin-script-runtime.jar" -} - diff --git a/eval4j/build.gradle.kts b/eval4j/build.gradle.kts index 8aa0569e7c4..a1b3c4e164f 100644 --- a/eval4j/build.gradle.kts +++ b/eval4j/build.gradle.kts @@ -1,3 +1,4 @@ + apply { plugin("kotlin") } dependencies { @@ -8,7 +9,6 @@ dependencies { // 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")) - buildVersion() } sourceSets { diff --git a/gradle/project-schema.json b/gradle/project-schema.json index 113b2f66611..e1c128db2fc 100644 --- a/gradle/project-schema.json +++ b/gradle/project-schema.json @@ -50,6 +50,23 @@ "reporting": "org.gradle.api.reporting.ReportingExtension" } }, + ":android-lint": { + "conventions": { + "base": "org.gradle.api.plugins.BasePluginConvention", + "java": "org.gradle.api.plugins.JavaPluginConvention" + }, + "configurations": [ + "archives", + "buildVersion", + "default", + "runtimeJar" + ], + "extensions": { + "ext": "org.gradle.api.plugins.ExtraPropertiesExtension", + "defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet", + "reporting": "org.gradle.api.reporting.ReportingExtension" + } + }, ":compiler": { "conventions": { "base": "org.gradle.api.plugins.BasePluginConvention", @@ -58,7 +75,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -176,7 +192,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -932,7 +947,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "buildVersion", "compile", "compileClasspath", @@ -1013,7 +1027,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "buildVersion", "compile", "compileClasspath", @@ -2339,42 +2352,6 @@ "shadow": "com.github.jengelman.gradle.plugins.shadow.ShadowExtension" } }, - ":core:script.runtime": { - "conventions": { - "base": "org.gradle.api.plugins.BasePluginConvention", - "java": "org.gradle.api.plugins.JavaPluginConvention" - }, - "configurations": [ - "apiElements", - "archives", - "build-version", - "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" - } - }, ":core:util.runtime": { "conventions": { "base": "org.gradle.api.plugins.BasePluginConvention", @@ -2783,7 +2760,7 @@ "configurations": [ "apiElements", "archives", - "build-version", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -2794,6 +2771,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3248,6 +3226,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3258,6 +3237,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3283,6 +3263,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3293,6 +3274,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3460,6 +3442,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3470,6 +3453,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3531,6 +3515,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3541,6 +3526,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3602,7 +3588,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -3630,37 +3615,6 @@ "reporting": "org.gradle.api.reporting.ReportingExtension" } }, - ":prepare:android-lint": { - "conventions": { - "base": "org.gradle.api.plugins.BasePluginConvention", - "java": "org.gradle.api.plugins.JavaPluginConvention" - }, - "configurations": [ - "apiElements", - "archives", - "compile", - "compileClasspath", - "compileOnly", - "default", - "implementation", - "runtime", - "runtimeClasspath", - "runtimeElements", - "runtimeOnly", - "testCompile", - "testCompileClasspath", - "testCompileOnly", - "testImplementation", - "testRuntime", - "testRuntimeClasspath", - "testRuntimeOnly" - ], - "extensions": { - "ext": "org.gradle.api.plugins.ExtraPropertiesExtension", - "defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet", - "reporting": "org.gradle.api.reporting.ReportingExtension" - } - }, ":prepare:build.version": { "conventions": { @@ -3680,6 +3634,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3688,6 +3643,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3711,6 +3667,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3719,6 +3676,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", @@ -3739,7 +3697,10 @@ }, "configurations": [ + "archives", + "buildVersion", "packedJars", + "runtimeJar", "sideJars" ], "extensions": { @@ -3754,6 +3715,7 @@ "configurations": [ "apiElements", "archives", + "buildVersion", "compile", "compileClasspath", "compileOnly", @@ -3764,6 +3726,7 @@ "runtime", "runtimeClasspath", "runtimeElements", + "runtimeJar", "runtimeOnly", "testCompile", "testCompileClasspath", diff --git a/idea/kotlin-gradle-tooling/build.gradle.kts b/idea/kotlin-gradle-tooling/build.gradle.kts index d8d6c556a3e..faa89b23792 100644 --- a/idea/kotlin-gradle-tooling/build.gradle.kts +++ b/idea/kotlin-gradle-tooling/build.gradle.kts @@ -1,10 +1,9 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin Gradle Tooling support" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) compile(project(":compiler:cli-common")) compile(ideaSdkDeps("gradle-tooling-api", @@ -13,7 +12,6 @@ dependencies { "gradle-core", "gradle-base-services-groovy", subdir = "plugins/gradle/lib")) - buildVersion() } sourceSets { @@ -21,8 +19,6 @@ sourceSets { "test" {} } -val jar: Jar by tasks +runtimeJar() -ideaPlugin { - from(jar) -} +ideaPlugin() diff --git a/plugins/allopen/allopen-cli/build.gradle.kts b/plugins/allopen/allopen-cli/build.gradle.kts index d86d8d86f4d..5108286b0cc 100644 --- a/plugins/allopen/allopen-cli/build.gradle.kts +++ b/plugins/allopen/allopen-cli/build.gradle.kts @@ -4,8 +4,6 @@ description = "Kotlin AllOpen Compiler Plugin" apply { plugin("kotlin") } dependencies { - val compileOnly by configurations - val runtime by configurations compileOnly(ideaSdkCoreDeps("intellij-core")) compileOnly(project(":compiler:plugin-api")) compileOnly(project(":compiler:frontend")) diff --git a/plugins/allopen/allopen-ide/build.gradle.kts b/plugins/allopen/allopen-ide/build.gradle.kts index 23677c7d130..58124f0097f 100644 --- a/plugins/allopen/allopen-ide/build.gradle.kts +++ b/plugins/allopen/allopen-ide/build.gradle.kts @@ -1,9 +1,9 @@ -import org.gradle.jvm.tasks.Jar + +description = "Kotlin AllOpen IDEA Plugin" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-allopen-compiler-plugin")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) @@ -22,10 +22,7 @@ sourceSets { "test" {} } +runtimeJar() -val jar: Jar by tasks - -ideaPlugin { - from(jar) -} +ideaPlugin() diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index b2de849fe55..58bcc77bfaa 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -1,15 +1,9 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin Android Extensions IDEA" apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations - compile(project(":compiler:util")) compile(project(":compiler:light-classes")) compile(project(":idea:idea-core")) @@ -54,8 +48,6 @@ projectTest { workingDir = rootDir } -val jar: Jar by tasks +runtimeJar() -ideaPlugin { - from(jar) -} +ideaPlugin() diff --git a/plugins/noarg/noarg-ide/build.gradle.kts b/plugins/noarg/noarg-ide/build.gradle.kts index 341ee5a2f73..093d5707169 100644 --- a/plugins/noarg/noarg-ide/build.gradle.kts +++ b/plugins/noarg/noarg-ide/build.gradle.kts @@ -1,10 +1,9 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin NoArg IDEA Plugin" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-noarg-compiler-plugin")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) @@ -25,9 +24,6 @@ sourceSets { "test" {} } -val jar: Jar by tasks - -ideaPlugin { - from(jar) -} +runtimeJar() +ideaPlugin() 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 c8f1180d7c7..a51b281f26c 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 @@ -4,8 +4,6 @@ description = "Kotlin SamWithReceiver Compiler Plugin" apply { plugin("kotlin") } dependencies { - val compileOnly by configurations - val runtime by configurations compileOnly(project(":compiler:frontend")) compileOnly(project(":compiler:frontend.java")) compileOnly(project(":compiler:plugin-api")) diff --git a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts index a2eb034c6fb..b0df46bd7d2 100644 --- a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts +++ b/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts @@ -1,9 +1,9 @@ -import org.gradle.jvm.tasks.Jar + +description = "Kotlin SamWithReceiver IDEA Plugin" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-sam-with-receiver-compiler-plugin")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) compile(project(":compiler:util")) @@ -19,10 +19,7 @@ sourceSets { "test" {} } +runtimeJar() -val jar: Jar by tasks - -ideaPlugin { - from(jar) -} +ideaPlugin() diff --git a/plugins/uast-kotlin-idea/build.gradle.kts b/plugins/uast-kotlin-idea/build.gradle.kts index 67d6dfe63a5..377dd1cdfd2 100644 --- a/plugins/uast-kotlin-idea/build.gradle.kts +++ b/plugins/uast-kotlin-idea/build.gradle.kts @@ -8,7 +8,6 @@ dependencies { compile(project(":compiler:frontend.java")) compile(project(":idea:ide-common")) compile(project(":plugins:uast-kotlin")) - buildVersion() } sourceSets { diff --git a/prepare/android-lint/build.gradle.kts b/prepare/android-lint/build.gradle.kts index 732e7cfbd9b..61c2b7eb35e 100644 --- a/prepare/android-lint/build.gradle.kts +++ b/prepare/android-lint/build.gradle.kts @@ -1,16 +1,19 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin Android Lint" -apply { plugin("java") } +apply { plugin("java-base") } val projectsToShadow = listOf( ":plugins:lint", ":plugins:uast-kotlin", ":plugins:uast-kotlin-idea") -tasks.withType { - setupRuntimeJar("Kotlin Android Lint") - archiveName = "android-lint.jar" +sourceSets { + "main" {} + "test" {} +} + +runtimeJar { projectsToShadow.forEach { dependsOn("$it:classes") project(it).let { p -> @@ -21,13 +24,4 @@ tasks.withType { } } -sourceSets { - "main" {} - "test" {} -} - -val jar: Jar by tasks - -ideaPlugin { - from(jar) -} +ideaPlugin() diff --git a/prepare/compiler-client-embeddable/build.gradle.kts b/prepare/compiler-client-embeddable/build.gradle.kts index bcb8adf3ac0..5777687ad07 100644 --- a/prepare/compiler-client-embeddable/build.gradle.kts +++ b/prepare/compiler-client-embeddable/build.gradle.kts @@ -30,7 +30,6 @@ val projectsToInclude = listOf( ":kotlin-daemon-client") dependencies { - val testCompile by configurations projectsToInclude.forEach { jarContents(project(it)) { isTransitive = false } testCompile(project(it)) diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 98f62f42086..08636dc5862 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -33,11 +33,11 @@ val fatJar by configurations.creating val compilerJar by configurations.creating val archives by configurations -val compilerBaseName: String by rootProject.extra +val compilerBaseName = name val outputJar = File(buildDir, "libs", "$compilerBaseName.jar") -val javaHome = System.getProperty("java.home") +val jreHome = System.getProperty("java.home") val compilerModules: Array by rootProject.extra @@ -57,8 +57,8 @@ val ideaCoreSdkJars: Array by rootProject.extra val coreSdkJarsSimple = ideaCoreSdkJars.filterNot { it == "jdom" || it == "log4j" }.toTypedArray() fun firstFromJavaHomeThatExists(vararg paths: String): File = - paths.mapNotNull { File(javaHome, it).takeIf { it.exists() } }.firstOrNull() - ?: throw GradleException("Cannot find under '$javaHome' neither of: ${paths.joinToString()}") + paths.mapNotNull { File(jreHome, it).takeIf { it.exists() } }.firstOrNull() + ?: throw GradleException("Cannot find under '$jreHome' neither of: ${paths.joinToString()}") compilerModules.forEach { evaluationDependsOn(it) } @@ -73,7 +73,6 @@ dependencies { compiledModulesSources.forEach { fatSourcesJarContents(it) } -// buildVersion() fatJarContents(project(":core:builtins", configuration = "builtins")) fatJarContents(ideaSdkCoreDeps(*coreSdkJarsSimple)) @@ -93,10 +92,6 @@ dependencies { proguardLibraryJars(project(":kotlin-script-runtime", configuration = "mainJar")) proguardLibraryJars(project(":kotlin-reflect", configuration = "mainJar")) proguardLibraryJars(preloadedDeps("kotlinx-coroutines-core")) - -// proguardLibraryJars(project(":prepare:runtime", configuration = "default").apply { isTransitive = false }) -// proguardLibraryJars(project(":prepare:reflect", configuration = "default").apply { isTransitive = false }) -// proguardLibraryJars(project(":core:script.runtime").apply { isTransitive = false }) } val packCompiler by task { diff --git a/prepare/formatter/build.gradle.kts b/prepare/formatter/build.gradle.kts index 709d08c9b80..4a0f8f7fcd5 100644 --- a/prepare/formatter/build.gradle.kts +++ b/prepare/formatter/build.gradle.kts @@ -1,10 +1,9 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin Formatter" apply { plugin("java") } -tasks.withType { - setupRuntimeJar("Kotlin Formatter") +runtimeJar { archiveName = "kotlin-formatter.jar" dependsOn(":idea:formatter:classes") project(":idea:formatter").let { p -> diff --git a/prepare/ide-lazy-resolver/build.gradle.kts b/prepare/ide-lazy-resolver/build.gradle.kts index d4dd3c397ef..06e7f9b8c0a 100644 --- a/prepare/ide-lazy-resolver/build.gradle.kts +++ b/prepare/ide-lazy-resolver/build.gradle.kts @@ -1,10 +1,9 @@ -import org.gradle.jvm.tasks.Jar +description = "Kotlin IDE Lazy Resolver" apply { plugin("java") } -tasks.withType { - setupRuntimeJar("Kotlin IDE Lazy Resolver") +runtimeJar { archiveName = "kotlin-ide-common.jar" dependsOn(":idea:ide-common:classes") project(":idea:ide-common").let { p -> diff --git a/prepare/kotlin-plugin/build.gradle.kts b/prepare/kotlin-plugin/build.gradle.kts index 4cdacdf62e2..2938789f776 100644 --- a/prepare/kotlin-plugin/build.gradle.kts +++ b/prepare/kotlin-plugin/build.gradle.kts @@ -1,6 +1,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +description = "Kotlin IDEA plugin" + buildscript { repositories { jcenter() @@ -60,11 +62,7 @@ dependencies { sideJars(preloadedDeps("markdown", "kotlinx-coroutines-core", "kotlinx-coroutines-jdk8")) } -val targetJar = File(buildDir, "libs", "kotlin-plugin.jar") - -val shadowTask = task("shadowJar") { - setupRuntimeJar("Kotlin IDEA plugin") - archiveName = targetJar.canonicalPath +val jar = runtimeJar(task("shadowJar")) { projectsToShadow.forEach { dependsOn("$it:classes") project(it).let { p -> @@ -78,9 +76,7 @@ val shadowTask = task("shadowJar") { } ideaPlugin { - dependsOn(shadowTask) - from(targetJar) - dependsOn(":kotlin-script-runtime:jar") + from(jar) from(sideJars) } diff --git a/prepare/mock-runtime-for-test/build.gradle.kts b/prepare/mock-runtime-for-test/build.gradle.kts index f9e7f81494b..7542c1cfd73 100644 --- a/prepare/mock-runtime-for-test/build.gradle.kts +++ b/prepare/mock-runtime-for-test/build.gradle.kts @@ -1,21 +1,13 @@ -import org.gradle.jvm.tasks.Jar -import org.gradle.api.internal.HasConvention -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +description = "Kotlin Mock Runtime for Tests" apply { plugin("kotlin") } -dependencies { - val compile by configurations - compile(project(":kotlin-stdlib")) -} +jvmTarget = "1.6" +javaHome = rootProject.extra["JDK_16"] as String -val jar: Jar by tasks -jar.apply { - setupRuntimeJar("Kotlin Mock Runtime for Tests") - from(fileTree("${rootProject.extra["distDir"]}/builtins")) { include("kotlin/**") } - archiveName = "kotlin-mock-runtime-for-test.jar" +dependencies { + compile(project(":kotlin-stdlib")) } sourceSets { @@ -38,17 +30,16 @@ sourceSets { tasks.withType { sourceCompatibility = "1.6" targetCompatibility = "1.6" -// options.fork = true - options.forkOptions.javaHome = file(rootProject.extra["JDK_16"] as String) } -tasks.withType { - kotlinOptions.jvmTarget = "1.6" - kotlinOptions.jdkHome = rootProject.extra["JDK_16"] as String +val jar = runtimeJar { + from(fileTree("${rootProject.extra["distDir"]}/builtins")) { include("kotlin/**") } + archiveName = "kotlin-mock-runtime-for-test.jar" } task("dist") { - into(rootProject.extra["distDir"].toString()) from(jar) + into(rootProject.extra["distDir"].toString()) + rename("-${Regex.escape(rootProject.extra["build.number"].toString())}", "") } diff --git a/prepare/reflect/build.gradle.kts b/prepare/reflect/build.gradle.kts deleted file mode 100644 index 4d1c7e5b63d..00000000000 --- a/prepare/reflect/build.gradle.kts +++ /dev/null @@ -1,131 +0,0 @@ - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import org.gradle.api.Project -import org.jetbrains.org.objectweb.asm.* -import org.gradle.jvm.tasks.Jar -import java.io.BufferedOutputStream -import java.io.File -import java.io.FileOutputStream -import java.util.jar.JarFile -import java.util.zip.ZipOutputStream - -buildscript { - repositories { - jcenter() - } - - dependencies { - classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3") - classpath(ideaSdkDeps("asm-all")) - } -} - -apply { plugin("com.github.johnrengelman.shadow") } - -// Set to false to prevent relocation and metadata stripping on kotlin-reflect.jar and reflection sources. Use to debug reflection -val obfuscateReflect = true - -val classesFromProjectsCfg = configurations.create("classes-from-projects") -val otherDepsCfg = configurations.create("other-deps") -val mainCfg = configurations.create("default") - -val outputReflectJarFileBase = "$buildDir/libs/kotlin-reflect" - -val coreProjectName = ":core" -val reflectionProjectName = ":core:reflection.jvm" - -artifacts.add(mainCfg.name, File(outputReflectJarFileBase + ".jar")) - -dependencies { - classesFromProjectsCfg.name(projectDepIntransitive(coreProjectName)) - classesFromProjectsCfg.name(projectDepIntransitive(":core:util.runtime")) - classesFromProjectsCfg.name(projectDepIntransitive(reflectionProjectName)) - otherDepsCfg.name(protobufLite()) - otherDepsCfg.name(commonDep("javax.inject")) - buildVersion() -} - -val prePackReflectTask = task("pre-pack-reflect") { - classifier = if (obfuscateReflect) outputReflectJarFileBase + "_beforeStrip" else outputReflectJarFileBase - configurations = listOf(mainCfg) - setupRuntimeJar("Kotlin Reflect") - dependsOn("$coreProjectName:assemble", "$reflectionProjectName:assemble", protobufLiteTask) - from(project(reflectionProjectName).getCompiledClasses()) - from(project(coreProjectName).getCompiledClasses()) - from(project(":core:util.runtime").getCompiledClasses()) - from(project(coreProjectName).file("descriptor.loader.java/src")) { - include("META-INF/services/**") - } - from(otherDepsCfg.files) - manifest.attributes.put("Class-Path", "kotlin-runtime.jar") - - if (obfuscateReflect) { - relocate("org.jetbrains.kotlin", "kotlin.reflect.jvm.internal.impl") - relocate("javax.inject", "kotlin.reflect.jvm.internal.impl.javax.inject") - } -} - -val mainTask = task("prepare") { - dependsOn(prePackReflectTask) - val inFile = File(outputReflectJarFileBase + "_beforeStrip.jar") - val outFile = File(outputReflectJarFileBase + ".jar") - inputs.file(inFile) - outputs.file(outFile) - val annotationRegex = "kotlin/Metadata".toRegex() - val classRegex = "kotlin/reflect/jvm/internal/impl/.*".toRegex() - doLast { - println("Stripping annotations from all classes in $inFile") - println("Input file size: ${inFile.length()} bytes") - - fun transform(entryName: String, bytes: ByteArray): ByteArray { - if (!entryName.endsWith(".class")) return bytes - if (!classRegex.matches(entryName.removeSuffix(".class"))) return bytes - - var changed = false - val classWriter = ClassWriter(0) - val classVisitor = object : ClassVisitor(Opcodes.ASM5, classWriter) { - override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? { - if (annotationRegex.matches(Type.getType(desc).internalName)) { - changed = true - return null - } - return super.visitAnnotation(desc, visible) - } - } - ClassReader(bytes).accept(classVisitor, 0) - if (!changed) return bytes - - return classWriter.toByteArray() - } - - ZipOutputStream(BufferedOutputStream(FileOutputStream(outFile))).use { outJar -> - val inJar = JarFile(inFile) - try { - for (entry in inJar.entries()) { - if (entry.isDirectory) continue - val inBytes = inJar.getInputStream(entry).readBytes() - val outBytes = transform(entry.name, inBytes) - - if (inBytes.size < outBytes.size) { - error("Size increased for ${entry.name}: was ${inBytes.size} bytes, became ${outBytes.size} bytes") - } - - entry.compressedSize = -1L - outJar.putNextEntry(entry) - outJar.write(outBytes) - outJar.closeEntry() - } - } - finally { - // Yes, JarFile does not extend Closeable on JDK 6 so we can't use "use" here - inJar.close() - } - } - - println("Output written to $outFile") - println("Output file size: ${outFile.length()} bytes") - } -} - -defaultTasks(mainTask.name) - diff --git a/prepare/runtime/build.gradle.kts b/prepare/runtime/build.gradle.kts deleted file mode 100644 index b2ea5c7ee99..00000000000 --- a/prepare/runtime/build.gradle.kts +++ /dev/null @@ -1,39 +0,0 @@ - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import java.io.File - -buildscript { - repositories { - jcenter() - } - - dependencies { - classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3") - classpath(ideaSdkDeps("asm-all")) - } -} - -apply { plugin("com.github.johnrengelman.shadow") } - -val mainCfg = configurations.create("default") - -val outputRuntimeJarFileBase = "$buildDir/libs/kotlin-runtime" - -artifacts.add(mainCfg.name, File(outputRuntimeJarFileBase + ".jar")) - -dependencies { - mainCfg.name(projectDepIntransitive(":core:builtins")) - mainCfg.name(projectDepIntransitive(":kotlin-stdlib")) - buildVersion() -} - -val mainTask = task("prepare") { - classifier = outputRuntimeJarFileBase - configurations = listOf(mainCfg) - dependsOn(":core:builtins:assemble", ":kotlin-stdlib:assemble") - setupRuntimeJar("Kotlin Runtime") - from(mainCfg.files) -} - -defaultTasks(mainTask.name) - diff --git a/settings.gradle b/settings.gradle index ee6e7ca760a..e28ec212d9a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -50,7 +50,6 @@ include ":kotlin-build-common", ":core", ":core:builtins", ":core:reflection.jvm", - ":core:script.runtime", ":core:util.runtime", ":custom-dependencies:protobuf-lite", ":idea:idea-jps-common", @@ -97,7 +96,7 @@ include ":kotlin-build-common", ":prepare:formatter", ":prepare:ide-lazy-resolver", ":prepare:kotlin-plugin", - ":prepare:android-lint", + ":android-lint", ":prepare:mock-runtime-for-test", ":kotlin-compiler", ":kotlin-compiler-embeddable", @@ -157,6 +156,7 @@ project(':idea:idea-android-output-parser').projectDir = "$rootDir/idea/idea-and project(':android-extensions-compiler').projectDir = "$rootDir/plugins/android-extensions/android-extensions-compiler" as File project(':plugins:android-extensions-idea').projectDir = "$rootDir/plugins/android-extensions/android-extensions-idea" as File project(':plugins:android-extensions-jps').projectDir = "$rootDir/plugins/android-extensions/android-extensions-jps" as File +project(':android-lint').projectDir = "$rootDir/prepare/android-lint" as File project(':kotlin-allopen-compiler-plugin').projectDir = "$rootDir/plugins/allopen/allopen-cli" as File project(':plugins:allopen-ide').projectDir = "$rootDir/plugins/allopen/allopen-ide" as File project(':kotlin-noarg-compiler-plugin').projectDir = "$rootDir/plugins/noarg/noarg-cli" as File