Refactor :kotlin-compiler project to allow project(":kotlin-compiler") dependencies
This commit is contained in:
@@ -72,7 +72,7 @@ fun<T: Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
|||||||
configurations.getOrCreate("archives").artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
|
configurations.getOrCreate("archives").artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
|
||||||
}
|
}
|
||||||
return task.apply {
|
return task.apply {
|
||||||
setupPublicJar()
|
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
body()
|
body()
|
||||||
project.runtimeJarArtifactBy(this, this)
|
project.runtimeJarArtifactBy(this, this)
|
||||||
@@ -181,12 +181,15 @@ private fun Project.runtimeJarTaskIfExists(): Task? =
|
|||||||
|
|
||||||
fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name)
|
fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name)
|
||||||
|
|
||||||
fun Jar.setupPublicJar(classifier: String = "") {
|
fun Jar.setupPublicJar(baseName: String, classifier: String = "") {
|
||||||
|
val buildNumber = project.rootProject.extra["buildNumber"] as String
|
||||||
|
this.baseName = baseName
|
||||||
|
this.version = buildNumber
|
||||||
this.classifier = classifier
|
this.classifier = classifier
|
||||||
manifest.attributes.apply {
|
manifest.attributes.apply {
|
||||||
put("Implementation-Vendor", "JetBrains")
|
put("Implementation-Vendor", "JetBrains")
|
||||||
put("Implementation-Title", project.the<BasePluginConvention>().archivesBaseName)
|
put("Implementation-Title", baseName)
|
||||||
put("Implementation-Version", project.rootProject.extra["buildNumber"])
|
put("Implementation-Version", buildNumber)
|
||||||
put("Build-Jdk", System.getProperty("java.version"))
|
put("Build-Jdk", System.getProperty("java.version"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import proguard.gradle.ProGuardTask
|
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.artifacts.maven.Conf2ScopeMappingContainer.COMPILE
|
||||||
import org.gradle.api.file.DuplicatesStrategy
|
import org.gradle.api.file.DuplicatesStrategy
|
||||||
|
|
||||||
description = "Kotlin Compiler"
|
description = "Kotlin Compiler"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java`
|
maven
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
||||||
val shrink =
|
val shrink =
|
||||||
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
||||||
?: hasProperty("teamcity")
|
?: hasProperty("teamcity")
|
||||||
|
|
||||||
val compilerManifestClassPath =
|
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
||||||
"kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
|
||||||
|
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating
|
||||||
|
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
val fatJarContentsStripServices by configurations.creating
|
val fatJarContentsStripServices by configurations.creating
|
||||||
val fatSourcesJarContents by configurations.creating
|
val fatSourcesJarContents by configurations.creating
|
||||||
val proguardLibraryJars by configurations.creating
|
|
||||||
val fatJar by configurations.creating
|
val fatJar by configurations.creating
|
||||||
val compilerJar by configurations.creating
|
val compilerJar by configurations.creating
|
||||||
val archives by configurations
|
val runtimeJar by configurations.creating
|
||||||
val compile by configurations
|
val libraries by configurations.creating
|
||||||
|
|
||||||
|
val compile by configurations.creating {
|
||||||
|
the<MavenPluginConvention>()
|
||||||
|
.conf2ScopeMappings
|
||||||
|
.addMapping(0, this, COMPILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val default by configurations
|
||||||
|
default.extendsFrom(runtimeJar)
|
||||||
|
|
||||||
val compilerBaseName = name
|
val compilerBaseName = name
|
||||||
|
|
||||||
@@ -41,9 +49,24 @@ val compiledModulesSources = compilerModules.map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// Maven plugin generates pom compile dependencies from compile configuration
|
||||||
|
compile(project(":kotlin-stdlib"))
|
||||||
|
compile(project(":kotlin-script-runtime"))
|
||||||
|
compile(project(":kotlin-reflect"))
|
||||||
|
|
||||||
|
libraries(project(":kotlin-annotations-jvm"))
|
||||||
|
libraries(
|
||||||
|
files(
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
||||||
|
toolsJar()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
compilerModules.forEach {
|
compilerModules.forEach {
|
||||||
fatJarContents(project(it)) { isTransitive = false }
|
fatJarContents(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
compiledModulesSources.forEach {
|
compiledModulesSources.forEach {
|
||||||
fatSourcesJarContents(it)
|
fatSourcesJarContents(it)
|
||||||
}
|
}
|
||||||
@@ -57,18 +80,6 @@ dependencies {
|
|||||||
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
||||||
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
||||||
|
|
||||||
proguardLibraryJars(files(firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
|
||||||
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
|
||||||
toolsJar()))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-stdlib"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-script-runtime"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-reflect"))
|
|
||||||
proguardLibraryJars(project(":kotlin-annotations-jvm"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-scripting-common"))
|
|
||||||
|
|
||||||
compile(project(":kotlin-stdlib"))
|
|
||||||
compile(project(":kotlin-script-runtime"))
|
|
||||||
compile(project(":kotlin-reflect"))
|
|
||||||
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
||||||
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-1.3.0") }
|
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-1.3.0") }
|
||||||
@@ -82,15 +93,16 @@ val packCompiler by task<ShadowJar> {
|
|||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
destinationDir = File(buildDir, "libs")
|
destinationDir = File(buildDir, "libs")
|
||||||
|
|
||||||
setupPublicJar("before-proguard")
|
setupPublicJar(compilerBaseName, "before-proguard")
|
||||||
|
|
||||||
from(fatJarContents)
|
from(fatJarContents)
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
||||||
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest.attributes.put("Class-Path", compilerManifestClassPath)
|
manifest.attributes["Class-Path"] = compilerManifestClassPath
|
||||||
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
|
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||||
}
|
}
|
||||||
|
|
||||||
val proguard by task<ProGuardTask> {
|
val proguard by task<ProGuardTask> {
|
||||||
@@ -108,25 +120,28 @@ val proguard by task<ProGuardTask> {
|
|||||||
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), compile)
|
||||||
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), libraries)
|
||||||
|
|
||||||
printconfiguration("$buildDir/compiler.pro.dump")
|
printconfiguration("$buildDir/compiler.pro.dump")
|
||||||
}
|
}
|
||||||
|
|
||||||
noDefaultJar()
|
|
||||||
|
|
||||||
val pack = if (shrink) proguard else packCompiler
|
val pack = if (shrink) proguard else packCompiler
|
||||||
|
|
||||||
dist(targetName = compilerBaseName + ".jar",
|
dist(
|
||||||
fromTask = pack)
|
targetName = "$compilerBaseName.jar",
|
||||||
|
fromTask = pack
|
||||||
|
)
|
||||||
|
|
||||||
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
||||||
name = compilerBaseName
|
name = compilerBaseName
|
||||||
classifier = ""
|
classifier = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar {
|
sourcesJar {
|
||||||
from(fatSourcesJarContents)
|
from(fatSourcesJarContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
publish()
|
publish()
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import proguard.gradle.ProGuardTask
|
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.artifacts.maven.Conf2ScopeMappingContainer.COMPILE
|
||||||
import org.gradle.api.file.DuplicatesStrategy
|
import org.gradle.api.file.DuplicatesStrategy
|
||||||
|
|
||||||
description = "Kotlin Compiler"
|
description = "Kotlin Compiler"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java`
|
maven
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
||||||
val shrink =
|
val shrink =
|
||||||
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
||||||
?: hasProperty("teamcity")
|
?: hasProperty("teamcity")
|
||||||
|
|
||||||
val compilerManifestClassPath =
|
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
||||||
"kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
|
||||||
|
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating
|
||||||
|
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
val fatJarContentsStripServices by configurations.creating
|
val fatJarContentsStripServices by configurations.creating
|
||||||
val fatSourcesJarContents by configurations.creating
|
val fatSourcesJarContents by configurations.creating
|
||||||
val proguardLibraryJars by configurations.creating
|
|
||||||
val fatJar by configurations.creating
|
val fatJar by configurations.creating
|
||||||
val compilerJar by configurations.creating
|
val compilerJar by configurations.creating
|
||||||
val archives by configurations
|
val runtimeJar by configurations.creating
|
||||||
val compile by configurations
|
val libraries by configurations.creating
|
||||||
|
|
||||||
|
val compile by configurations.creating {
|
||||||
|
the<MavenPluginConvention>()
|
||||||
|
.conf2ScopeMappings
|
||||||
|
.addMapping(0, this, COMPILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val default by configurations
|
||||||
|
default.extendsFrom(runtimeJar)
|
||||||
|
|
||||||
val compilerBaseName = name
|
val compilerBaseName = name
|
||||||
|
|
||||||
@@ -41,9 +49,24 @@ val compiledModulesSources = compilerModules.map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// Maven plugin generates pom compile dependencies from compile configuration
|
||||||
|
compile(project(":kotlin-stdlib"))
|
||||||
|
compile(project(":kotlin-script-runtime"))
|
||||||
|
compile(project(":kotlin-reflect"))
|
||||||
|
|
||||||
|
libraries(project(":kotlin-annotations-jvm"))
|
||||||
|
libraries(
|
||||||
|
files(
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
||||||
|
toolsJar()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
compilerModules.forEach {
|
compilerModules.forEach {
|
||||||
fatJarContents(project(it)) { isTransitive = false }
|
fatJarContents(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
compiledModulesSources.forEach {
|
compiledModulesSources.forEach {
|
||||||
fatSourcesJarContents(it)
|
fatSourcesJarContents(it)
|
||||||
}
|
}
|
||||||
@@ -57,18 +80,6 @@ dependencies {
|
|||||||
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
||||||
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
||||||
|
|
||||||
proguardLibraryJars(files(firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
|
||||||
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
|
||||||
toolsJar()))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-stdlib"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-script-runtime"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-reflect"))
|
|
||||||
proguardLibraryJars(project(":kotlin-annotations-jvm"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-scripting-common"))
|
|
||||||
|
|
||||||
compile(project(":kotlin-stdlib"))
|
|
||||||
compile(project(":kotlin-script-runtime"))
|
|
||||||
compile(project(":kotlin-reflect"))
|
|
||||||
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
||||||
fatJarContents(intellijDep()) { includeJars("jna-platform") }
|
fatJarContents(intellijDep()) { includeJars("jna-platform") }
|
||||||
@@ -82,15 +93,16 @@ val packCompiler by task<ShadowJar> {
|
|||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
destinationDir = File(buildDir, "libs")
|
destinationDir = File(buildDir, "libs")
|
||||||
|
|
||||||
setupPublicJar("before-proguard")
|
setupPublicJar(compilerBaseName, "before-proguard")
|
||||||
|
|
||||||
from(fatJarContents)
|
from(fatJarContents)
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
||||||
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest.attributes.put("Class-Path", compilerManifestClassPath)
|
manifest.attributes["Class-Path"] = compilerManifestClassPath
|
||||||
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
|
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||||
}
|
}
|
||||||
|
|
||||||
val proguard by task<ProGuardTask> {
|
val proguard by task<ProGuardTask> {
|
||||||
@@ -108,25 +120,28 @@ val proguard by task<ProGuardTask> {
|
|||||||
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), compile)
|
||||||
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), libraries)
|
||||||
|
|
||||||
printconfiguration("$buildDir/compiler.pro.dump")
|
printconfiguration("$buildDir/compiler.pro.dump")
|
||||||
}
|
}
|
||||||
|
|
||||||
noDefaultJar()
|
|
||||||
|
|
||||||
val pack = if (shrink) proguard else packCompiler
|
val pack = if (shrink) proguard else packCompiler
|
||||||
|
|
||||||
dist(targetName = compilerBaseName + ".jar",
|
dist(
|
||||||
fromTask = pack)
|
targetName = "$compilerBaseName.jar",
|
||||||
|
fromTask = pack
|
||||||
|
)
|
||||||
|
|
||||||
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
||||||
name = compilerBaseName
|
name = compilerBaseName
|
||||||
classifier = ""
|
classifier = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar {
|
sourcesJar {
|
||||||
from(fatSourcesJarContents)
|
from(fatSourcesJarContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
publish()
|
publish()
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import proguard.gradle.ProGuardTask
|
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.artifacts.maven.Conf2ScopeMappingContainer.COMPILE
|
||||||
import org.gradle.api.file.DuplicatesStrategy
|
import org.gradle.api.file.DuplicatesStrategy
|
||||||
|
|
||||||
description = "Kotlin Compiler"
|
description = "Kotlin Compiler"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java`
|
maven
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs)
|
||||||
val shrink =
|
val shrink =
|
||||||
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
|
||||||
?: hasProperty("teamcity")
|
?: hasProperty("teamcity")
|
||||||
|
|
||||||
val compilerManifestClassPath =
|
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
||||||
"kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
|
||||||
|
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating
|
||||||
|
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
val fatJarContentsStripServices by configurations.creating
|
val fatJarContentsStripServices by configurations.creating
|
||||||
val fatSourcesJarContents by configurations.creating
|
val fatSourcesJarContents by configurations.creating
|
||||||
val proguardLibraryJars by configurations.creating
|
|
||||||
val fatJar by configurations.creating
|
val fatJar by configurations.creating
|
||||||
val compilerJar by configurations.creating
|
val compilerJar by configurations.creating
|
||||||
val archives by configurations
|
val runtimeJar by configurations.creating
|
||||||
val compile by configurations
|
val libraries by configurations.creating
|
||||||
|
|
||||||
|
val compile by configurations.creating {
|
||||||
|
the<MavenPluginConvention>()
|
||||||
|
.conf2ScopeMappings
|
||||||
|
.addMapping(0, this, COMPILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val default by configurations
|
||||||
|
default.extendsFrom(runtimeJar)
|
||||||
|
|
||||||
val compilerBaseName = name
|
val compilerBaseName = name
|
||||||
|
|
||||||
@@ -41,9 +49,24 @@ val compiledModulesSources = compilerModules.map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// Maven plugin generates pom compile dependencies from compile configuration
|
||||||
|
compile(project(":kotlin-stdlib"))
|
||||||
|
compile(project(":kotlin-script-runtime"))
|
||||||
|
compile(project(":kotlin-reflect"))
|
||||||
|
|
||||||
|
libraries(project(":kotlin-annotations-jvm"))
|
||||||
|
libraries(
|
||||||
|
files(
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
||||||
|
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
||||||
|
toolsJar()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
compilerModules.forEach {
|
compilerModules.forEach {
|
||||||
fatJarContents(project(it)) { isTransitive = false }
|
fatJarContents(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
compiledModulesSources.forEach {
|
compiledModulesSources.forEach {
|
||||||
fatSourcesJarContents(it)
|
fatSourcesJarContents(it)
|
||||||
}
|
}
|
||||||
@@ -57,18 +80,6 @@ dependencies {
|
|||||||
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
fatJarContents(commonDep("io.javaslang", "javaslang"))
|
||||||
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
||||||
|
|
||||||
proguardLibraryJars(files(firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
|
|
||||||
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
|
|
||||||
toolsJar()))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-stdlib"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-script-runtime"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-reflect"))
|
|
||||||
proguardLibraryJars(project(":kotlin-annotations-jvm"))
|
|
||||||
proguardLibraryJars(projectDist(":kotlin-scripting-common"))
|
|
||||||
|
|
||||||
compile(project(":kotlin-stdlib"))
|
|
||||||
compile(project(":kotlin-script-runtime"))
|
|
||||||
compile(project(":kotlin-reflect"))
|
|
||||||
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
|
||||||
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-java-1.3") }
|
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-java-1.3") }
|
||||||
@@ -82,15 +93,16 @@ val packCompiler by task<ShadowJar> {
|
|||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
destinationDir = File(buildDir, "libs")
|
destinationDir = File(buildDir, "libs")
|
||||||
|
|
||||||
setupPublicJar("before-proguard")
|
setupPublicJar(compilerBaseName, "before-proguard")
|
||||||
|
|
||||||
from(fatJarContents)
|
from(fatJarContents)
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
fatJarContentsStripServices.files.forEach { from(zipTree(it)) { exclude("META-INF/services/**") } }
|
||||||
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
fatJarContentsStripMetadata.files.forEach { from(zipTree(it)) { exclude("META-INF/jb/** META-INF/LICENSE") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest.attributes.put("Class-Path", compilerManifestClassPath)
|
manifest.attributes["Class-Path"] = compilerManifestClassPath
|
||||||
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
|
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||||
}
|
}
|
||||||
|
|
||||||
val proguard by task<ProGuardTask> {
|
val proguard by task<ProGuardTask> {
|
||||||
@@ -108,25 +120,28 @@ val proguard by task<ProGuardTask> {
|
|||||||
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), compile)
|
||||||
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), libraries)
|
||||||
|
|
||||||
printconfiguration("$buildDir/compiler.pro.dump")
|
printconfiguration("$buildDir/compiler.pro.dump")
|
||||||
}
|
}
|
||||||
|
|
||||||
noDefaultJar()
|
|
||||||
|
|
||||||
val pack = if (shrink) proguard else packCompiler
|
val pack = if (shrink) proguard else packCompiler
|
||||||
|
|
||||||
dist(targetName = compilerBaseName + ".jar",
|
dist(
|
||||||
fromTask = pack)
|
targetName = "$compilerBaseName.jar",
|
||||||
|
fromTask = pack
|
||||||
|
)
|
||||||
|
|
||||||
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
||||||
name = compilerBaseName
|
name = compilerBaseName
|
||||||
classifier = ""
|
classifier = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar {
|
sourcesJar {
|
||||||
from(fatSourcesJarContents)
|
from(fatSourcesJarContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
publish()
|
publish()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user