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:
@@ -234,6 +234,7 @@ extra["compilerModules"] = arrayOf(
|
||||
":compiler:cli",
|
||||
":compiler:cli-js",
|
||||
":compiler:incremental-compilation-impl",
|
||||
":compiler:compiler.version",
|
||||
":js:js.ast",
|
||||
":js:js.serializer",
|
||||
":js:js.parser",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
jvmTarget = "1.6"
|
||||
javaHome = rootProject.extra["JDK_16"] as String
|
||||
|
||||
val kotlinVersion: String by rootProject.extra
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.jetbrains:annotations:13.0")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
sourceCompatibility = "1.6"
|
||||
targetCompatibility = "1.6"
|
||||
}
|
||||
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
inputs.property("compilerVersion", kotlinVersion)
|
||||
filesMatching("META-INF/compiler.version") {
|
||||
filter<ReplaceTokens>("tokens" to mapOf("snapshot" to kotlinVersion))
|
||||
}
|
||||
}
|
||||
+2
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.config;
|
||||
@@ -5,8 +5,10 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(kotlinStdlib())
|
||||
compile(project(":core:deserialization"))
|
||||
api(kotlinStdlib())
|
||||
api(project(":compiler:compiler.version"))
|
||||
api(project(":core:deserialization"))
|
||||
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
java
|
||||
@@ -9,8 +8,6 @@ plugins {
|
||||
jvmTarget = "1.6"
|
||||
javaHome = rootProject.extra["JDK_16"] as String
|
||||
|
||||
val kotlinVersion: String by rootProject.extra
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
}
|
||||
@@ -24,10 +21,3 @@ tasks.withType<JavaCompile> {
|
||||
sourceCompatibility = "1.6"
|
||||
targetCompatibility = "1.6"
|
||||
}
|
||||
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
inputs.property("compilerVersion", kotlinVersion)
|
||||
filesMatching("META-INF/compiler.version") {
|
||||
filter<ReplaceTokens>("tokens" to mapOf("snapshot" to kotlinVersion))
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ val projectsToShadow by extra(listOf(
|
||||
":compiler:resolution",
|
||||
":compiler:serialization",
|
||||
":compiler:util",
|
||||
":compiler:compiler.version",
|
||||
":core:util.runtime",
|
||||
":plugins:lint",
|
||||
":plugins:uast-kotlin",
|
||||
|
||||
@@ -20,7 +20,8 @@ val projectsToShadow = listOf(
|
||||
":jps-plugin",
|
||||
":kotlin-preloader",
|
||||
":compiler:util",
|
||||
":core:util.runtime"
|
||||
":core:util.runtime",
|
||||
":compiler:compiler.version"
|
||||
)
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -138,6 +138,7 @@ include ":kotlin-build-common",
|
||||
":core:metadata",
|
||||
":core:metadata.jvm",
|
||||
":core:util.runtime",
|
||||
":compiler:compiler.version",
|
||||
":dependencies:android-sdk",
|
||||
":idea:idea-jvm",
|
||||
":idea:idea-maven",
|
||||
|
||||
Reference in New Issue
Block a user