Build: Extract compiler version to separate module to improve caching

Compiler version changes every build and makes impossible to reuse
caches for heavy tasks such as compiler proguard. We may fix that by
adding version module directly to the final jar.
This commit is contained in:
Vyacheslav Gerasimov
2020-02-29 19:12:09 +03:00
parent c2457cae60
commit bab87c9837
10 changed files with 55 additions and 29 deletions
+13 -3
View File
@@ -15,6 +15,7 @@ plugins {
val fatJarContents by configurations.creating
val fatJarContentsStripMetadata by configurations.creating
val fatJarContentsStripServices by configurations.creating
val compilerVersion by configurations.creating
// JPS build assumes fat jar is built from embedded configuration,
// but we can't use it in gradle build since slightly more complex processing is required like stripping metadata & services from some jars
@@ -139,9 +140,13 @@ dependencies {
)
)
compilerModules.forEach {
fatJarContents(project(it)) { isTransitive = false }
}
compilerVersion(project(":compiler:compiler.version"))
proguardLibraries(project(":compiler:compiler.version"))
compilerModules
.filter { it != ":compiler:compiler.version" } // Version will be added directly to the final jar excluding proguard and relocation
.forEach {
fatJarContents(project(it)) { isTransitive = false }
}
libraries(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } }
libraries(commonDep("io.ktor", "ktor-network"))
@@ -272,11 +277,16 @@ val distDir: String by rootProject.extra
val jar = runtimeJar {
dependsOn(pack)
dependsOn(compilerVersion)
from {
zipTree(pack.get().outputs.files.singleFile)
}
from {
compilerVersion.map(::zipTree)
}
manifest.attributes["Class-Path"] = compilerManifestClassPath
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
}