Refactor compiler-related published projects

- move preparation into separate projects
- rename projects for publishing
- add compiler plugins
This commit is contained in:
Ilya Chernikov
2017-09-11 13:03:35 +02:00
parent aa4fdaa713
commit e18b77af21
19 changed files with 229 additions and 343 deletions
+4
View File
@@ -176,6 +176,10 @@ allprojects {
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name) kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name)
} }
tasks.withType<Javadoc> {
enabled = false
}
task<Jar>("javadocJar") { task<Jar>("javadocJar") {
classifier = "javadoc" classifier = "javadoc"
} }
+1 -157
View File
@@ -1,70 +1,11 @@
import java.io.File import java.io.File
import proguard.gradle.ProGuardTask
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.internal.plugins.DslObject
import org.gradle.api.publication.maven.internal.deployer.MavenRemoteRepository
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
classpath("net.sf.proguard:proguard-gradle:5.3.1")
}
}
apply { plugin("kotlin") } apply { plugin("kotlin") }
plugins {
maven
}
//apply { plugin("maven") }
// Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build
val shrink = true
val compilerManifestClassPath =
"kotlin-runtime.jar kotlin-reflect.jar kotlin-script-runtime.jar"
val fatJarContents by configurations.creating
val proguardLibraryJars by configurations.creating
val fatJar by configurations.creating
val compilerJar by configurations.creating
val embeddableCompilerJar by configurations.creating
val compilerBaseName: String by rootProject.extra
val embeddableCompilerBaseName: String by rootProject.extra
val javaHome = File(System.getProperty("java.home"))
val buildLocalRepoPath: File by rootProject.extra
val compilerModules: Array<String> by rootProject.extra val compilerModules: Array<String> by rootProject.extra
val otherCompilerModules = compilerModules.filter { it != path } val otherCompilerModules = compilerModules.filter { it != path }
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
val packagesToRelocate =
listOf("com.intellij",
"com.google",
"com.sampullara",
"org.apache",
"org.jdom",
"org.picocontainer",
"jline",
"gnu",
"javax.inject",
"org.fusesource")
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()}")
dependencies { dependencies {
val compile by configurations val compile by configurations
val compileOnly by configurations val compileOnly by configurations
@@ -95,37 +36,12 @@ dependencies {
testCompile(project(":ant")) testCompile(project(":ant"))
otherCompilerModules.forEach { otherCompilerModules.forEach {
testCompile(project(it)) testCompile(project(it))
fatJarContents(project(it)) { isTransitive = false }
} }
testRuntime(ideaSdkCoreDeps("*.jar")) testRuntime(ideaSdkCoreDeps("*.jar"))
testRuntime(ideaSdkDeps("*.jar")) testRuntime(ideaSdkDeps("*.jar"))
// testRuntime(project(":prepare:compiler", configuration = "default")) // testRuntime(project(":kotlin-compiler", configuration = "default"))
buildVersion() buildVersion()
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array<String>)))
fatJarContents(ideaSdkDeps("jna-platform", "oromatcher"))
fatJarContents(ideaSdkDeps("jps-model.jar", subdir = "jps"))
fatJarContents(commonDep("javax.inject"))
fatJarContents(commonDep("org.jline", "jline"))
fatJarContents(protobufFull())
fatJarContents(commonDep("com.github.spullara.cli-parser", "cli-parser"))
fatJarContents(commonDep("com.google.code.findbugs", "jsr305"))
fatJarContents(commonDep("io.javaslang", "javaslang"))
fatJarContents(preloadedDeps("json-org"))
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(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 })
} }
configureKotlinProjectSources( configureKotlinProjectSources(
@@ -153,75 +69,3 @@ tasks.withType<Test> {
ignoreFailures = true ignoreFailures = true
} }
val packCompiler by task<ShadowJar> {
configurations = listOf(fatJar)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDir = File(buildDir, "libs")
baseName = compilerBaseName
classifier = "before-proguard"
dependsOn(protobufFullTask)
setupRuntimeJar("Kotlin Compiler")
from(getCompiledClasses())
from(fatJarContents)
manifest.attributes.put("Class-Path", compilerManifestClassPath)
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
}
val proguard by task<ProGuardTask> {
dependsOn(packCompiler)
configuration("$rootDir/compiler/compiler.pro")
val outputJar = File(buildDir, "libs", "$compilerBaseName-after-proguard.jar")
inputs.files(packCompiler.outputs.files.singleFile)
outputs.file(outputJar)
// TODO: remove after dropping compatibility with ant build
doFirst {
System.setProperty("kotlin-compiler-jar-before-shrink", packCompiler.outputs.files.singleFile.canonicalPath)
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
}
libraryjars(proguardLibraryJars)
printconfiguration("$buildDir/compiler.pro.dump")
}
val embeddable by task<ShadowJar> {
destinationDir = File(buildDir, "libs")
baseName = embeddableCompilerBaseName
configurations = listOf(embeddableCompilerJar)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(proguard)
from(proguard)
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
packagesToRelocate.forEach {
relocate(it, "$kotlinEmbeddableRootPackage.$it")
}
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
// TODO: remove "it." after #KT-12848 get addressed
exclude("org.fusesource.jansi.internal.CLibrary")
}
}
dist {
if (shrink) {
from(proguard)
} else {
from(packCompiler)
}
rename(".*", compilerBaseName + ".jar")
}
artifacts.add(compilerJar.name, proguard.outputs.files.singleFile) {
builtBy(proguard)
classifier = ""
name = compilerBaseName
}
artifacts.add(embeddableCompilerJar.name, embeddable.outputs.files.singleFile) {
builtBy(embeddable)
classifier = ""
name = embeddableCompilerBaseName
}
+3 -3
View File
@@ -79,12 +79,12 @@ dependencies {
testCompile(project(":plugins:android-extensions-compiler")) testCompile(project(":plugins:android-extensions-compiler"))
testCompile(project(":plugins:android-extensions-idea")) { isTransitive = false } testCompile(project(":plugins:android-extensions-idea")) { isTransitive = false }
testCompile(project(":plugins:allopen-ide")) { isTransitive = false } testCompile(project(":plugins:allopen-ide")) { isTransitive = false }
testCompile(project(":plugins:allopen-cli")) testCompile(project(":kotlin-allopen-compiler-plugin"))
testCompile(project(":plugins:noarg-ide")) { isTransitive = false } testCompile(project(":plugins:noarg-ide")) { isTransitive = false }
testCompile(project(":plugins:noarg-cli")) testCompile(project(":kotlin-noarg-compiler-plugin"))
testCompile(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false } testCompile(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false }
testCompile(project(":plugins:sam-with-receiver-ide")) { isTransitive = false } testCompile(project(":plugins:sam-with-receiver-ide")) { isTransitive = false }
testCompile(project(":plugins:sam-with-receiver-cli")) testCompile(project(":kotlin-sam-with-receiver-compiler-plugin"))
testCompile(project(":idea:idea-android")) { isTransitive = false } testCompile(project(":idea:idea-android")) { isTransitive = false }
testCompile(project(":plugins:lint")) { isTransitive = false } testCompile(project(":plugins:lint")) { isTransitive = false }
testCompile(project(":plugins:uast-kotlin")) testCompile(project(":plugins:uast-kotlin"))
+2 -2
View File
@@ -13,8 +13,8 @@ dependencies {
compile project(':kotlin-gradle-plugin-api') compile project(':kotlin-gradle-plugin-api')
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
compileOnly project(path: ':compiler', configuration: 'embeddableCompilerJar') compileOnly project(path: ':kotlin-compiler-embeddable', configuration: 'runtimeJar')
compile project(':plugins:allopen-cli') compile project(':kotlin-allopen-compiler-plugin')
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6' compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
} }
+1 -1
View File
@@ -20,7 +20,7 @@ dependencies {
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
compileOnly project(':compiler') compileOnly project(':compiler')
compile project(':plugins:noarg-cli') compile project(':kotlin-noarg-compiler-plugin')
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6' compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
} }
@@ -20,7 +20,7 @@ dependencies {
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
compileOnly project(':compiler') compileOnly project(':compiler')
compile project(':plugins:sam-with-receiver-cli') compile project(':kotlin-sam-with-receiver-compiler-plugin')
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6' compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
} }
+11 -9
View File
@@ -1,30 +1,32 @@
import org.gradle.jvm.tasks.Jar description = "Kotlin AllOpen Compiler Plugin"
apply { plugin("kotlin") } apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compileOnly by configurations
compile(ideaSdkCoreDeps("intellij-core")) val runtime by configurations
compile(project(":compiler:plugin-api")) compileOnly(ideaSdkCoreDeps("intellij-core"))
compile(project(":compiler:frontend")) compileOnly(project(":compiler:plugin-api"))
compileOnly(project(":compiler:frontend"))
runtime(project(":kotlin-compiler", configuration = "runtimeJar"))
runtime(project(":kotlin-stdlib"))
} }
configureKotlinProjectSourcesDefault() configureKotlinProjectSourcesDefault()
configureKotlinProjectNoTests() configureKotlinProjectNoTests()
val jar: Jar by tasks val jar = runtimeJar {
jar.apply {
setupRuntimeJar("Kotlin AllOpen Compiler Plugin")
from(fileTree("$projectDir/src")) { include("META-INF/**") } from(fileTree("$projectDir/src")) { include("META-INF/**") }
archiveName = "allopen-compiler-plugin.jar"
} }
dist { dist {
from(jar) from(jar)
rename("^kotlin-", "")
} }
ideaPlugin { ideaPlugin {
from(jar) from(jar)
rename("^kotlin-", "")
} }
+1 -1
View File
@@ -4,7 +4,7 @@ apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compile by configurations
compile(project(":plugins:allopen-cli")) compile(project(":kotlin-allopen-compiler-plugin"))
compile(project(":compiler:util")) compile(project(":compiler:util"))
compile(project(":compiler:frontend")) compile(project(":compiler:frontend"))
compile(project(":compiler:cli-common")) compile(project(":compiler:cli-common"))
+13 -11
View File
@@ -1,32 +1,34 @@
import org.gradle.jvm.tasks.Jar description = "Kotlin NoArg Compiler Plugin"
apply { plugin("kotlin") } apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compileOnly by configurations
compile(project(":compiler:frontend")) val runtime by configurations
compile(project(":compiler:frontend.java")) compileOnly(project(":compiler:frontend"))
compile(project(":compiler:backend")) compileOnly(project(":compiler:frontend.java"))
compile(project(":compiler:util")) compileOnly(project(":compiler:backend"))
compile(project(":compiler:plugin-api")) compileOnly(project(":compiler:util"))
compileOnly(project(":compiler:plugin-api"))
runtime(project(":kotlin-compiler", configuration = "runtimeJar"))
runtime(project(":kotlin-stdlib"))
} }
configureKotlinProjectSourcesDefault() configureKotlinProjectSourcesDefault()
configureKotlinProjectNoTests() configureKotlinProjectNoTests()
val jar: Jar by tasks val jar = runtimeJar {
jar.apply {
setupRuntimeJar("Kotlin NoArg Compiler Plugin")
from(fileTree("$projectDir/src")) { include("META-INF/**") } from(fileTree("$projectDir/src")) { include("META-INF/**") }
archiveName = "noarg-compiler-plugin.jar"
} }
dist { dist {
from(jar) from(jar)
rename("^kotlin-", "")
} }
ideaPlugin { ideaPlugin {
from(jar) from(jar)
rename("^kotlin-", "")
} }
+1 -1
View File
@@ -5,7 +5,7 @@ apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compile by configurations
compile(project(":plugins:noarg-cli")) compile(project(":kotlin-noarg-compiler-plugin"))
compile(project(":compiler:util")) compile(project(":compiler:util"))
compile(project(":compiler:frontend")) compile(project(":compiler:frontend"))
compile(project(":compiler:frontend.java")) compile(project(":compiler:frontend.java"))
+3 -3
View File
@@ -14,12 +14,12 @@ dependencies {
testCompile(project(":plugins:android-extensions-compiler")) testCompile(project(":plugins:android-extensions-compiler"))
testCompile(project(":plugins:android-extensions-idea")) testCompile(project(":plugins:android-extensions-idea"))
testCompile(project(":plugins:allopen-ide")) { isTransitive = false } testCompile(project(":plugins:allopen-ide")) { isTransitive = false }
testCompile(project(":plugins:allopen-cli")) testCompile(project(":kotlin-allopen-compiler-plugin"))
testCompile(project(":plugins:noarg-ide")) { isTransitive = false } testCompile(project(":plugins:noarg-ide")) { isTransitive = false }
testCompile(project(":plugins:noarg-cli")) testCompile(project(":kotlin-noarg-compiler-plugin"))
testCompile(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false } testCompile(project(":plugins:annotation-based-compiler-plugins-ide-support")) { isTransitive = false }
testCompile(project(":plugins:sam-with-receiver-ide")) { isTransitive = false } testCompile(project(":plugins:sam-with-receiver-ide")) { isTransitive = false }
testCompile(project(":plugins:sam-with-receiver-cli")) testCompile(project(":kotlin-sam-with-receiver-compiler-plugin"))
testCompile(project(":idea:idea-android")) { isTransitive = false } testCompile(project(":idea:idea-android")) { isTransitive = false }
testCompile(project(":plugins:lint")) { isTransitive = false } testCompile(project(":plugins:lint")) { isTransitive = false }
testCompile(project(":plugins:uast-kotlin")) testCompile(project(":plugins:uast-kotlin"))
@@ -1,30 +1,36 @@
import org.gradle.jvm.tasks.Jar description = "Kotlin SamWithReceiver Compiler Plugin"
apply { plugin("kotlin") } apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compileOnly by configurations
compile(project(":compiler:frontend")) val runtime by configurations
compile(project(":compiler:frontend.java")) compileOnly(project(":compiler:frontend"))
compile(project(":compiler:plugin-api")) compileOnly(project(":compiler:frontend.java"))
compileOnly(project(":compiler:plugin-api"))
runtime(project(":kotlin-compiler", configuration = "runtimeJar"))
runtime(project(":kotlin-stdlib"))
} }
configureKotlinProjectSourcesDefault() configureKotlinProjectSourcesDefault()
configureKotlinProjectNoTests() configureKotlinProjectNoTests()
val jar: Jar by tasks val jar = runtimeJar {
jar.apply {
setupRuntimeJar("Kotlin SamWithReceiver Compiler Plugin")
from(fileTree("$projectDir/src")) { include("META-INF/**") } from(fileTree("$projectDir/src")) { include("META-INF/**") }
archiveName = "sam-with-receiver-compiler-plugin.jar"
} }
sourcesJar()
javadocJar()
publish()
dist { dist {
from(jar) from(jar)
rename("^kotlin-", "")
} }
ideaPlugin { ideaPlugin {
from(jar) from(jar)
rename("^kotlin-", "")
} }
@@ -4,7 +4,7 @@ apply { plugin("kotlin") }
dependencies { dependencies {
val compile by configurations val compile by configurations
compile(project(":plugins:sam-with-receiver-cli")) compile(project(":kotlin-sam-with-receiver-compiler-plugin"))
compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support"))
compile(project(":compiler:util")) compile(project(":compiler:util"))
compile(project(":compiler:frontend")) compile(project(":compiler:frontend"))
@@ -1,5 +1,5 @@
import org.gradle.jvm.tasks.Jar description = "Kotlin SourceSections Compiler Plugin"
apply { plugin("kotlin") } apply { plugin("kotlin") }
@@ -9,9 +9,12 @@ dependencies {
val testCompile by configurations val testCompile by configurations
val testCompileOnly by configurations val testCompileOnly by configurations
val testRuntime by configurations val testRuntime by configurations
compile(project(":compiler:frontend")) compileOnly(project(":compiler:frontend"))
compile(project(":compiler:frontend.script")) compileOnly(project(":compiler:frontend.script"))
compile(project(":compiler:plugin-api")) compileOnly(project(":compiler:plugin-api"))
testCompile(project(":compiler:frontend"))
testCompile(project(":compiler:frontend.script"))
testCompile(project(":compiler:plugin-api"))
testCompile(project(":compiler.tests-common")) testCompile(project(":compiler.tests-common"))
testCompile(commonDep("junit:junit")) testCompile(commonDep("junit:junit"))
testCompile(project(":compiler:util")) testCompile(project(":compiler:util"))
@@ -28,11 +31,11 @@ configureKotlinProjectResources("src") {
} }
configureKotlinProjectTestsDefault() configureKotlinProjectTestsDefault()
val jar: Jar by tasks val jar = runtimeJar()
jar.apply { sourcesJar()
setupRuntimeJar("Kotlin SourceSections Compiler Plugin") javadocJar()
archiveName = "kotlin-source-sections-compiler-plugin.jar"
} publish()
dist { dist {
from(jar) from(jar)
@@ -1,38 +1,7 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Kotlin compiler client embeddable"
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
@@ -53,7 +22,6 @@ val jarContents by configurations.creating
val testRuntimeCompilerJar by configurations.creating val testRuntimeCompilerJar by configurations.creating
val testStdlibJar by configurations.creating val testStdlibJar by configurations.creating
val testScriptRuntimeJar by configurations.creating val testScriptRuntimeJar by configurations.creating
val default by configurations
val archives by configurations val archives by configurations
val projectsToInclude = listOf( val projectsToInclude = listOf(
@@ -70,18 +38,11 @@ dependencies {
testCompile(commonDep("junit:junit")) testCompile(commonDep("junit:junit"))
testCompile(project(":kotlin-test:kotlin-test-jvm")) testCompile(project(":kotlin-test:kotlin-test-jvm"))
testCompile(project(":kotlin-test:kotlin-test-junit")) testCompile(project(":kotlin-test:kotlin-test-junit"))
testRuntimeCompilerJar(project(":compiler", configuration = "compilerJar")) testRuntimeCompilerJar(project(":kotlin-compiler", configuration = "runtimeJar"))
testStdlibJar(project(":kotlin-stdlib", configuration = "mainJar")) testStdlibJar(project(":kotlin-stdlib", configuration = "mainJar"))
testScriptRuntimeJar(project(":kotlin-script-runtime", configuration = "mainJar")) testScriptRuntimeJar(project(":kotlin-script-runtime", configuration = "mainJar"))
} }
val shadowJar by task<ShadowJar> {
setupRuntimeJar("Kotlin compiler client embeddable")
baseName = "kotlin-compiler-client-embeddable"
from(jarContents)
classifier = ""
}
configureKotlinProjectSources() // no sources configureKotlinProjectSources() // no sources
configureKotlinProjectTests("libraries/tools/kotlin-compiler-client-embeddable-test/src", sourcesBaseDir = rootDir) configureKotlinProjectTests("libraries/tools/kotlin-compiler-client-embeddable-test/src", sourcesBaseDir = rootDir)
@@ -108,18 +69,15 @@ archives.artifacts.let { artifacts ->
} }
} }
artifacts.add(default.name, shadowJar.outputs.files.singleFile) { runtimeJar(task<ShadowJar>("shadowJar")) {
builtBy(shadowJar) from(jarContents)
classifier = ""
} }
sourcesJar()
javadocJar()
artifacts.add("archives", shadowJar.outputs.files.singleFile) { publish()
builtBy(shadowJar)
classifier = ""
}
apply<plugins.PublishedKotlinModule>()
// TODO: remove after finalizing publishing (now due to the problems with sam-with-receiver, the code is not fully navigable in the buildSrc)
//tasks { //tasks {
// "uploadArchives"(Upload::class) { // "uploadArchives"(Upload::class) {
// //
+11 -15
View File
@@ -1,6 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Kotlin Compiler (embeddable)"
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
@@ -11,10 +13,7 @@ buildscript {
} }
} }
val embedCfg = configurations.create("embed") val compilerJar by configurations.creating
val mainCfg = configurations.create("default")
val embeddableCompilerBaseName: String by rootProject.extra
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin" val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
@@ -31,16 +30,14 @@ val packagesToRelocate =
"org.fusesource") "org.fusesource")
dependencies { dependencies {
embedCfg(project(":prepare:compiler", configuration = "default")) compilerJar(project(":kotlin-compiler", configuration = "runtimeJar"))
} }
val embeddableTask = task<ShadowJar>("prepare") { runtimeJar(task<ShadowJar>("embeddable")) {
destinationDir = File(buildDir, "libs") destinationDir = File(buildDir, "libs")
baseName = embeddableCompilerBaseName
configurations = listOf(mainCfg)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(":build-common:assemble", ":core:script.runtime:assemble") // dependsOn(":kotlin-compiler:proguard")
from(embedCfg.files) from(compilerJar)
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf") relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
packagesToRelocate.forEach { packagesToRelocate.forEach {
relocate(it, "$kotlinEmbeddableRootPackage.$it") relocate(it, "$kotlinEmbeddableRootPackage.$it")
@@ -51,9 +48,8 @@ val embeddableTask = task<ShadowJar>("prepare") {
} }
} }
defaultTasks(embeddableTask.name) sourcesJar()
javadocJar()
publish()
artifacts.add(mainCfg.name, embeddableTask.outputs.files.singleFile) {
builtBy(embeddableTask)
classifier = ""
}
+90 -57
View File
@@ -4,6 +4,8 @@ import proguard.gradle.ProGuardTask
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.file.DuplicatesStrategy
description = "Kotlin Compiler"
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
@@ -15,22 +17,21 @@ buildscript {
} }
} }
apply { plugin("maven") } plugins {
`java-base`
}
// Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build // Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build
val shrink = true val shrink = true
val bootstrapBuild = false
val compilerManifestClassPath = val compilerManifestClassPath =
if (bootstrapBuild) "kotlin-runtime-internal-bootstrap.jar kotlin-reflect-internal-bootstrap.jar kotlin-script-runtime-internal-bootstrap.jar" "kotlin-runtime.jar kotlin-reflect.jar kotlin-script-runtime.jar"
else "kotlin-runtime.jar kotlin-reflect.jar kotlin-script-runtime.jar"
val ideaSdkCoreCfg = configurations.create("ideaSdk-core") val fatJarContents by configurations.creating
val otherDepsCfg = configurations.create("other-deps") val fatSourcesJarContents by configurations.creating
val proguardLibraryJarsCfg = configurations.create("library-jars") val proguardLibraryJars by configurations.creating
val mainCfg = configurations.create("default_") val fatJar by configurations.creating
val packedCfg = configurations.create("packed") val compilerJar by configurations.creating
//val withBootstrapRuntimeCfg = configurations.create("withBootstrapRuntime") val archives by configurations
val compilerBaseName: String by rootProject.extra val compilerBaseName: String by rootProject.extra
@@ -38,81 +39,113 @@ val outputJar = File(buildDir, "libs", "$compilerBaseName.jar")
val javaHome = System.getProperty("java.home") val javaHome = System.getProperty("java.home")
val compilerProject = project(":compiler") val compilerModules: Array<String> by rootProject.extra
dependencies { val packagesToRelocate =
ideaSdkCoreCfg(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array<String>))) listOf("com.intellij",
ideaSdkCoreCfg(ideaSdkDeps("jna-platform", "oromatcher")) "com.google",
ideaSdkCoreCfg(ideaSdkDeps("jps-model.jar", subdir = "jps")) "com.sampullara",
otherDepsCfg(commonDep("javax.inject")) "org.apache",
otherDepsCfg(commonDep("org.jline", "jline")) "org.jdom",
otherDepsCfg(protobufFull()) "org.picocontainer",
otherDepsCfg(commonDep("com.github.spullara.cli-parser", "cli-parser")) "jline",
otherDepsCfg(commonDep("com.google.code.findbugs", "jsr305")) "gnu",
otherDepsCfg(commonDep("io.javaslang","javaslang")) "javax.inject",
otherDepsCfg(preloadedDeps("json-org")) "org.fusesource")
buildVersion()
proguardLibraryJarsCfg(files("$javaHome/lib/rt.jar".takeIf { File(it).exists() } ?: "$javaHome/../Classes/classes.jar", fun firstFromJavaHomeThatExists(vararg paths: String): File =
"$javaHome/lib/jsse.jar".takeIf { File(it).exists() } ?: "$javaHome/../Classes/jsse.jar")) paths.mapNotNull { File(javaHome, it).takeIf { it.exists() } }.firstOrNull()
proguardLibraryJarsCfg(kotlinDep("stdlib")) ?: throw GradleException("Cannot find under '$javaHome' neither of: ${paths.joinToString()}")
proguardLibraryJarsCfg(kotlinDep("script-runtime"))
proguardLibraryJarsCfg(kotlinDep("reflect")) compilerModules.forEach { evaluationDependsOn(it) }
proguardLibraryJarsCfg(files("${System.getProperty("java.home")}/../lib/tools.jar"))
// proguardLibraryJarsCfg(project(":prepare:runtime", configuration = "default").apply { isTransitive = false }) val compiledModulesSources = compilerModules.map {
// proguardLibraryJarsCfg(project(":prepare:reflect", configuration = "default").apply { isTransitive = false }) project(it).the<JavaPluginConvention>().sourceSets.getByName("main").allSource
// proguardLibraryJarsCfg(project(":core:script.runtime").apply { isTransitive = false })
} }
val packCompilerTask = task<ShadowJar>("internal.pack-compiler") { dependencies {
configurations = listOf(packedCfg) compilerModules.forEach {
fatJarContents(project(it)) { isTransitive = false }
}
compiledModulesSources.forEach {
fatSourcesJarContents(it)
}
// buildVersion()
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array<String>)))
fatJarContents(ideaSdkDeps("jna-platform", "oromatcher"))
fatJarContents(ideaSdkDeps("jps-model.jar", subdir = "jps"))
fatJarContents(commonDep("javax.inject"))
fatJarContents(commonDep("org.jline", "jline"))
fatJarContents(protobufFull())
fatJarContents(commonDep("com.github.spullara.cli-parser", "cli-parser"))
fatJarContents(commonDep("com.google.code.findbugs", "jsr305"))
fatJarContents(commonDep("io.javaslang", "javaslang"))
fatJarContents(preloadedDeps("json-org"))
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(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<ShadowJar> {
configurations = listOf(fatJar)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDir = File(buildDir, "libs") destinationDir = File(buildDir, "libs")
baseName = compilerBaseName + "-before-shrink" // baseName = compilerBaseName
dependsOn(protobufFullTask) dependsOn(protobufFullTask)
setupRuntimeJar("Kotlin Compiler")
(rootProject.extra["compilerModules"] as Array<String>).forEach { setupPublicJar("before-proguard", "")
dependsOn("$it:classes") from(fatJarContents)
from(project(it).getCompiledClasses())
}
from(ideaSdkCoreCfg.files)
from(otherDepsCfg.files)
from(project(":core:builtins").getResourceFiles()) { include("kotlin/**") }
manifest.attributes.put("Class-Path", compilerManifestClassPath) manifest.attributes.put("Class-Path", compilerManifestClassPath)
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
} }
val proguardTask = task<ProGuardTask>("internal.proguard-compiler") { val proguard by task<ProGuardTask> {
dependsOn(packCompilerTask) dependsOn(packCompiler)
configuration("$rootDir/compiler/compiler.pro") configuration("$rootDir/compiler/compiler.pro")
inputs.files(packCompilerTask.outputs.files.singleFile) val outputJar = File(buildDir, "libs", "$compilerBaseName-after-proguard.jar")
inputs.files(packCompiler.outputs.files.singleFile)
outputs.file(outputJar) outputs.file(outputJar)
// TODO: remove after dropping compatibility with ant build // TODO: remove after dropping compatibility with ant build
doFirst { doFirst {
System.setProperty("kotlin-compiler-jar-before-shrink", packCompilerTask.outputs.files.singleFile.canonicalPath) System.setProperty("kotlin-compiler-jar-before-shrink", packCompiler.outputs.files.singleFile.canonicalPath)
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath) System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
} }
proguardLibraryJarsCfg.files.forEach { jar -> libraryjars(proguardLibraryJars)
libraryjars(jar)
}
printconfiguration("$buildDir/compiler.pro.dump") printconfiguration("$buildDir/compiler.pro.dump")
} }
dist { dist {
if (shrink) { if (shrink) {
from(proguardTask) from(proguard)
} else { } else {
from(packCompilerTask) from(packCompiler)
rename("-before-shrink", "")
} }
rename(".*", compilerBaseName + ".jar")
} }
artifacts.add(mainCfg.name, proguardTask.outputs.files.singleFile) { runtimeJarArtifactBy(proguard, proguard.outputs.files.singleFile) {
builtBy(proguardTask) name = compilerBaseName
classifier = "" classifier = ""
} }
sourcesJar {
from(fatSourcesJarContents)
}
javadocJar()
publish()
+31
View File
@@ -0,0 +1,31 @@
description = "Kotlin Daemon Client"
apply { plugin("kotlin") }
val nativePlatformUberjar = "$rootDir/dependencies/native-platform-uberjar.jar"
dependencies {
val compile by configurations
compile(project(":compiler:util"))
compile(project(":compiler:cli-common"))
compile(project(":compiler:daemon-common"))
compile(files(nativePlatformUberjar))
buildVersion()
}
configureKotlinProjectSourcesDefault()
configureKotlinProjectNoTests()
val jar = runtimeJar {
from(zipTree(nativePlatformUberjar))
}
sourcesJar()
javadocJar()
dist {
from(jar)
}
publish()
+19 -12
View File
@@ -4,8 +4,8 @@ include ":build-common",
":compiler", ":compiler",
":compiler:util", ":compiler:util",
":compiler:daemon-common", ":compiler:daemon-common",
":compiler:daemon-client", ":kotlin-daemon-client",
":compiler:preloader", ":kotlin-preloader",
":compiler:cli-runner", ":compiler:cli-runner",
":compiler:container", ":compiler:container",
":compiler:resolution", ":compiler:resolution",
@@ -55,13 +55,13 @@ include ":build-common",
":plugins:android-extensions-compiler", ":plugins:android-extensions-compiler",
":plugins:android-extensions-idea", ":plugins:android-extensions-idea",
":plugins:android-extensions-jps", ":plugins:android-extensions-jps",
":plugins:allopen-cli", ":kotlin-allopen-compiler-plugin",
":plugins:allopen-ide", ":plugins:allopen-ide",
":plugins:noarg-cli", ":kotlin-noarg-compiler-plugin",
":plugins:noarg-ide", ":plugins:noarg-ide",
":plugins:sam-with-receiver-cli", ":kotlin-sam-with-receiver-compiler-plugin",
":plugins:sam-with-receiver-ide", ":plugins:sam-with-receiver-ide",
":plugins:source-sections-compiler", ":kotlin-source-sections-compiler-plugin",
":plugins:uast-kotlin", ":plugins:uast-kotlin",
":plugins:uast-kotlin-idea", ":plugins:uast-kotlin-idea",
":plugins:annotation-based-compiler-plugins-ide-support", ":plugins:annotation-based-compiler-plugins-ide-support",
@@ -86,7 +86,10 @@ include ":build-common",
":prepare:kotlin-plugin", ":prepare:kotlin-plugin",
":prepare:android-lint", ":prepare:android-lint",
":prepare:mock-runtime-for-test", ":prepare:mock-runtime-for-test",
":prepare:compiler-client-embeddable", ":kotlin-compiler",
":kotlin-compiler-embeddable",
":kotlin-compiler-client-embeddable",
":kotlin-daemon-client",
":kotlin-reflect", ":kotlin-reflect",
":ant", ":ant",
":compiler:tests-java8", ":compiler:tests-java8",
@@ -119,10 +122,14 @@ project(':kotlin-stdlib-jre7').projectDir = "$rootDir/libraries/stdlib/jre7" as
project(':kotlin-stdlib-jre8').projectDir = "$rootDir/libraries/stdlib/jre8" as File project(':kotlin-stdlib-jre8').projectDir = "$rootDir/libraries/stdlib/jre8" as File
project(':kotlin-stdlib:samples').projectDir = "$rootDir/libraries/stdlib/samples" as File project(':kotlin-stdlib:samples').projectDir = "$rootDir/libraries/stdlib/samples" as File
project(':kotlin-reflect').projectDir = "$rootDir/libraries/tools/kotlin-reflect" as File project(':kotlin-reflect').projectDir = "$rootDir/libraries/tools/kotlin-reflect" as File
project(':kotlin-compiler').projectDir = "$rootDir/prepare/compiler" as File
project(':kotlin-compiler-embeddable').projectDir = "$rootDir/prepare/compiler-embeddable" as File
project(':kotlin-compiler-client-embeddable').projectDir = "$rootDir/prepare/compiler-client-embeddable" as File
project(':kotlin-daemon-client').projectDir = "$rootDir/prepare/daemon-client" as File
project(':compiler:cli-common').projectDir = "$rootDir/compiler/cli/cli-common" as File project(':compiler:cli-common').projectDir = "$rootDir/compiler/cli/cli-common" as File
project(':compiler:cli-runner').projectDir = "$rootDir/compiler/cli/cli-runner" as File project(':compiler:cli-runner').projectDir = "$rootDir/compiler/cli/cli-runner" as File
project(':compiler:daemon-common').projectDir = "$rootDir/compiler/daemon/daemon-common" as File project(':compiler:daemon-common').projectDir = "$rootDir/compiler/daemon/daemon-common" as File
project(':compiler:daemon-client').projectDir = "$rootDir/compiler/daemon/daemon-client" as File project(':kotlin-daemon-client').projectDir = "$rootDir/compiler/daemon/daemon-client" as File
project(':compiler:ir.tree').projectDir = "$rootDir/compiler/ir/ir.tree" as File project(':compiler:ir.tree').projectDir = "$rootDir/compiler/ir/ir.tree" as File
project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as File project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as File
project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File
@@ -130,13 +137,13 @@ project(':idea:idea-android-output-parser').projectDir = "$rootDir/idea/idea-and
project(':plugins:android-extensions-compiler').projectDir = "$rootDir/plugins/android-extensions/android-extensions-compiler" as File project(':plugins: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-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(':plugins:android-extensions-jps').projectDir = "$rootDir/plugins/android-extensions/android-extensions-jps" as File
project(':plugins:allopen-cli').projectDir = "$rootDir/plugins/allopen/allopen-cli" 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(':plugins:allopen-ide').projectDir = "$rootDir/plugins/allopen/allopen-ide" as File
project(':plugins:noarg-cli').projectDir = "$rootDir/plugins/noarg/noarg-cli" as File project(':kotlin-noarg-compiler-plugin').projectDir = "$rootDir/plugins/noarg/noarg-cli" as File
project(':plugins:noarg-ide').projectDir = "$rootDir/plugins/noarg/noarg-ide" as File project(':plugins:noarg-ide').projectDir = "$rootDir/plugins/noarg/noarg-ide" as File
project(':plugins:sam-with-receiver-cli').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-cli" as File project(':kotlin-sam-with-receiver-compiler-plugin').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-cli" as File
project(':plugins:sam-with-receiver-ide').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-ide" as File project(':plugins:sam-with-receiver-ide').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-ide" as File
project(':plugins:source-sections-compiler').projectDir = "$rootDir/plugins/source-sections/source-sections-compiler" as File project(':kotlin-source-sections-compiler-plugin').projectDir = "$rootDir/plugins/source-sections/source-sections-compiler" as File
project(':tools:binary-compatibility-validator').projectDir = "$rootDir/libraries/tools/binary-compatibility-validator" as File project(':tools:binary-compatibility-validator').projectDir = "$rootDir/libraries/tools/binary-compatibility-validator" as File
project(':tools:kotlin-stdlib-js-merger').projectDir = "$rootDir/libraries/tools/kotlin-stdlib-js-merger" as File project(':tools:kotlin-stdlib-js-merger').projectDir = "$rootDir/libraries/tools/kotlin-stdlib-js-merger" as File
project(':tools:kotlin-stdlib-gen').projectDir = "$rootDir/libraries/tools/kotlin-stdlib-gen" as File project(':tools:kotlin-stdlib-gen').projectDir = "$rootDir/libraries/tools/kotlin-stdlib-gen" as File