From 74411d9b9cb9d55768045327843bc14b2fc28b28 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Thu, 2 Nov 2017 12:39:49 +0100 Subject: [PATCH] Convert all compiler modules to intellij plugin --- build-common/build.gradle.kts | 10 +++++- compiler/android-tests/build.gradle.kts | 2 +- compiler/cli/build.gradle.kts | 12 ++++++- compiler/cli/cli-common/build.gradle.kts | 12 ++++++- compiler/daemon/build.gradle.kts | 12 ++++++- .../daemon/daemon-common/build.gradle.kts | 12 ++++++- compiler/plugin-api/build.gradle.kts | 12 +++++-- compiler/preloader/build.gradle.kts | 8 +++-- compiler/tests-common/build.gradle.kts | 13 ++++++-- prepare/compiler/build.gradle.kts | 31 +++++++++++++------ 10 files changed, 102 insertions(+), 22 deletions(-) diff --git a/build-common/build.gradle.kts b/build-common/build.gradle.kts index bf4b7642e0e..4d74de75664 100644 --- a/build-common/build.gradle.kts +++ b/build-common/build.gradle.kts @@ -3,6 +3,8 @@ description = "Kotlin Build Common" apply { plugin("kotlin") } +configureIntellijPlugin() + dependencies { compileOnly(project(":core:util.runtime")) compileOnly(project(":compiler:util")) @@ -11,7 +13,6 @@ dependencies { compileOnly(project(":js:js.serializer")) compileOnly(project(":js:js.frontend")) compileOnly(project(":kotlin-reflect-api")) - compileOnly(ideaSdkDeps("util")) testCompileOnly(project(":compiler:cli-common")) testCompile(projectTests(":compiler:tests-common")) testCompile(commonDep("junit:junit")) @@ -21,6 +22,13 @@ dependencies { testRuntime(projectDist(":kotlin-reflect")) } +afterEvaluate { + dependencies { + compileOnly(intellij { include("util.jar") }) + testCompileOnly(intellij { include("openapi.jar") }) + } +} + sourceSets { "main" { projectDefault() } "test" { projectDefault() } diff --git a/compiler/android-tests/build.gradle.kts b/compiler/android-tests/build.gradle.kts index 7db11c8c6c0..e780400bb48 100644 --- a/compiler/android-tests/build.gradle.kts +++ b/compiler/android-tests/build.gradle.kts @@ -26,7 +26,7 @@ dependencies { afterEvaluate { dependencies { compile(intellij { include("openapi.jar") }) - testCompile(intellij { include("idea.jar", "idea-rt.jar", "groovy-all.jar", "jps-builders.jar") }) + testCompile(intellij { include("idea.jar", "idea_rt.jar", "groovy-all-*.jar", "jps-builders.jar") }) testCompile(intellijExtra("jps-standalone") { include("jps-model.jar") }) testCompile(intellijExtra("jps-build-test")) } diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index e4fcbd514f6..955185aea96 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -3,6 +3,10 @@ apply { plugin("kotlin") } jvmTarget = "1.8" +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { compile(project(":compiler:util")) compile(project(":compiler:cli-common")) @@ -17,7 +21,6 @@ dependencies { compile(project(":js:js.translator")) compile(project(":js:js.serializer")) compile(project(":js:js.dce")) - compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) compile(commonDep("org.fusesource.jansi", "jansi")) compile(commonDep("org.jline", "jline")) compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) @@ -29,6 +32,13 @@ dependencies { testCompile(commonDep("junit:junit")) } +afterEvaluate { + dependencies { + compile(intellijCoreJar()) + compile(intellijCoreJarDependencies()) + } +} + sourceSets { "main" { projectDefault() diff --git a/compiler/cli/cli-common/build.gradle.kts b/compiler/cli/cli-common/build.gradle.kts index 05b1ef79389..5db83b47741 100644 --- a/compiler/cli/cli-common/build.gradle.kts +++ b/compiler/cli/cli-common/build.gradle.kts @@ -3,13 +3,23 @@ apply { plugin("kotlin") } jvmTarget = "1.6" +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { compile(project(":core:util.runtime")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) compile(project(":compiler:frontend.script")) compileOnly(project(":kotlin-reflect-api")) - compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) +} + +afterEvaluate { + dependencies { + compile(intellijCoreJar()) + compile(intellijCoreJarDependencies()) + } } sourceSets { diff --git a/compiler/daemon/build.gradle.kts b/compiler/daemon/build.gradle.kts index 0872fa4f77b..3c8ef41e332 100644 --- a/compiler/daemon/build.gradle.kts +++ b/compiler/daemon/build.gradle.kts @@ -3,17 +3,27 @@ apply { plugin("kotlin") } jvmTarget = "1.6" +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { val compile by configurations compile(project(":compiler:cli")) compile(project(":compiler:daemon-common")) compile(project(":compiler:incremental-compilation-impl")) compile(project(":kotlin-build-common")) - compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) compile(commonDep("org.fusesource.jansi", "jansi")) compile(commonDep("org.jline", "jline")) } +afterEvaluate { + dependencies { + compile(intellijCoreJar()) + compile(intellijCoreJarDependencies()) + } +} + sourceSets { "main" { projectDefault() } "test" {} diff --git a/compiler/daemon/daemon-common/build.gradle.kts b/compiler/daemon/daemon-common/build.gradle.kts index b4fe0562d1b..899f7969693 100644 --- a/compiler/daemon/daemon-common/build.gradle.kts +++ b/compiler/daemon/daemon-common/build.gradle.kts @@ -3,15 +3,25 @@ apply { plugin("kotlin") } jvmTarget = "1.6" +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { compile(project(":core:descriptors")) compile(project(":core:descriptors.jvm")) compile(project(":compiler:util")) compile(project(":compiler:cli-common")) - compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) compile(project(":kotlin-stdlib")) } +afterEvaluate { + dependencies { + compile(intellijCoreJar()) + compile(intellijCoreJarDependencies()) + } +} + sourceSets { "main" { projectDefault() } "test" {} diff --git a/compiler/plugin-api/build.gradle.kts b/compiler/plugin-api/build.gradle.kts index e0deee681fa..8307ad2d799 100644 --- a/compiler/plugin-api/build.gradle.kts +++ b/compiler/plugin-api/build.gradle.kts @@ -3,14 +3,22 @@ apply { plugin("kotlin") } jvmTarget = "1.6" +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { - compile(ideaSdkCoreDeps("intellij-core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) } +afterEvaluate { + dependencies { + compile(intellijCoreJar()) + } +} + sourceSets { "main" { projectDefault() } "test" {} } - diff --git a/compiler/preloader/build.gradle.kts b/compiler/preloader/build.gradle.kts index 18d886319a7..0d793efac88 100644 --- a/compiler/preloader/build.gradle.kts +++ b/compiler/preloader/build.gradle.kts @@ -5,8 +5,12 @@ apply { plugin("kotlin") } jvmTarget = "1.6" -dependencies { - compile(ideaSdkDeps("asm-all")) +configureIntellijPlugin() + +afterEvaluate { + dependencies { + compile(intellij { include("asm-all.jar") }) + } } sourceSets { diff --git a/compiler/tests-common/build.gradle.kts b/compiler/tests-common/build.gradle.kts index e00bf7d6720..53979194b1b 100644 --- a/compiler/tests-common/build.gradle.kts +++ b/compiler/tests-common/build.gradle.kts @@ -1,6 +1,10 @@ apply { plugin("kotlin") } +configureIntellijPlugin { + setExtraDependencies("intellij-core") +} + dependencies { testCompile(project(":core:descriptors")) testCompile(project(":core:descriptors.jvm")) @@ -25,11 +29,16 @@ dependencies { testCompile(projectTests(":compiler:tests-common-jvm6")) testCompileOnly(project(":kotlin-reflect-api")) testCompile(commonDep("junit:junit")) - testCompile(ideaSdkCoreDeps("intellij-core")) - testCompile(ideaSdkDeps("openapi", "idea", "idea_rt")) testCompile(preloadedDeps("dx", subdir = "android-5.0/lib")) } +afterEvaluate { + dependencies { + testCompile(intellijCoreJar()) + testCompile(intellij { include("openapi.jar", "idea.jar", "idea_rt.jar") }) + } +} + sourceSets { "main" { } "test" { projectDefault() } diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 02f13c38fc6..ba61a92b57a 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -30,6 +30,8 @@ val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar" val fatJarContents by configurations.creating +val fatJarContentsStripMetadata by configurations.creating +val fatJarContentsStripServices by configurations.creating val fatSourcesJarContents by configurations.creating val proguardLibraryJars by configurations.creating val fatJar by configurations.creating @@ -43,15 +45,16 @@ val outputJar = File(buildDir, "libs", "$compilerBaseName.jar") val compilerModules: Array by rootProject.extra -val ideaCoreSdkJars: Array by rootProject.extra -val coreSdkJarsSimple = ideaCoreSdkJars.filterNot { it == "jdom" || it == "log4j" }.toTypedArray() - compilerModules.forEach { evaluationDependsOn(it) } val compiledModulesSources = compilerModules.map { project(it).the().sourceSets.getByName("main").allSource } +configureIntellijPlugin { + setExtraDependencies("intellij-core", "jps-standalone") +} + dependencies { compilerModules.forEach { fatJarContents(project(it)) { isTransitive = false } @@ -61,8 +64,6 @@ dependencies { } fatJarContents(project(":core:builtins", configuration = "builtins")) - fatJarContents(ideaSdkCoreDeps(*coreSdkJarsSimple)) - fatJarContents(ideaSdkDeps("jna-platform")) fatJarContents(commonDep("javax.inject")) fatJarContents(commonDep("org.jline", "jline")) fatJarContents(commonDep("org.fusesource.jansi", "jansi")) @@ -83,6 +84,17 @@ dependencies { compile(project(":kotlin-reflect")) } +afterEvaluate { + dependencies { + fatJarContents(intellijCoreJar()) + fatJarContents(intellijCoreJarDependencies { exclude("jdom.jar", "log4j.jar") }) + fatJarContents(intellij { include("jna-platform.jar") }) + fatJarContentsStripServices(intellijExtra("jps-standalone") { include("jps-model.jar") }) + fatJarContentsStripMetadata(intellij { include("oromatcher.jar", "jdom.jar", "log4j.jar") }) + } +} + + val packCompiler by task { configurations = listOf(fatJar) duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -91,9 +103,10 @@ val packCompiler by task { setupPublicJar("before-proguard") from(fatJarContents) - ideaSdkDeps("jps-model.jar", subdir = "jps").forEach { from(zipTree(it)) { exclude("META-INF/services/**") } } - ideaSdkDeps("oromatcher").forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } } - ideaSdkCoreDeps("jdom", "log4j").forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } } + afterEvaluate { + fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } } + fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } } + } manifest.attributes.put("Class-Path", compilerManifestClassPath) manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") @@ -120,8 +133,6 @@ val proguard by task { noDefaultJar() -cleanArtifacts() - val pack = if (shrink) proguard else packCompiler dist(targetName = compilerBaseName + ".jar",