Build: Centralize compiler dist build logic in :kotlin-compiler project

This commit is contained in:
Vyacheslav Gerasimov
2019-06-19 19:02:40 +03:00
parent 62126d0e43
commit db3b01d2d4
52 changed files with 270 additions and 305 deletions
-3
View File
@@ -19,6 +19,3 @@ sourceSets {
runtimeJar { runtimeJar {
manifest.attributes.put("Class-Path", "$compilerManifestClassPath kotlin-preloader.jar") manifest.attributes.put("Class-Path", "$compilerManifestClassPath kotlin-preloader.jar")
} }
dist()
+2 -7
View File
@@ -437,13 +437,8 @@ gradle.taskGraph.whenReady {
} }
} }
val dist by task<Copy> { val dist = tasks.register("dist") {
val childDistTasks = getTasksByName("dist", true) - this@task dependsOn(":kotlin-compiler:dist")
dependsOn(childDistTasks)
into(distDir)
from(files("compiler/cli/bin")) { into("kotlinc/bin") }
from(files("license")) { into("kotlinc/license") }
} }
val copyCompilerToIdeaPlugin by task<Copy> { val copyCompilerToIdeaPlugin by task<Copy> {
-25
View File
@@ -151,31 +151,6 @@ fun Project.publish(body: Upload.() -> Unit = {}): Upload {
} }
} }
fun Project.dist(
targetDir: File? = null,
targetName: String? = null,
fromTask: Task? = null,
body: AbstractCopyTask.() -> Unit = {}
): AbstractCopyTask {
val distJarCfg = configurations.getOrCreate("distJar")
val distLibDir: File by rootProject.extra
val distJarName = targetName ?: (the<BasePluginConvention>().archivesBaseName + ".jar")
val thisProject = this
return task<Copy>("dist") {
body()
(fromTask ?: runtimeJarTaskIfExists())?.let {
from(it)
if (targetName != null) {
rename(it.outputs.files.singleFile.name, targetName)
}
}
rename("-${java.util.regex.Pattern.quote(thisProject.version.toString())}", "")
into(targetDir ?: distLibDir)
project.addArtifact(distJarCfg, this, File(targetDir ?: distLibDir, distJarName))
}
}
private fun Project.runtimeJarTaskIfExists(): Task? = private fun Project.runtimeJarTaskIfExists(): Task? =
if (extra.has("runtimeJarTask")) extra["runtimeJarTask"] as Task if (extra.has("runtimeJarTask")) extra["runtimeJarTask"] as Task
else tasks.findByName("jar") else tasks.findByName("jar")
+5 -4
View File
@@ -73,13 +73,14 @@ fun Project.ideaUltimatePreloadedDeps(vararg artifactBaseNames: String, subdir:
else files() else files()
} }
fun Project.kotlinDep(artifactBaseName: String, version: String): String = "org.jetbrains.kotlin:kotlin-$artifactBaseName:$version" fun Project.kotlinDep(artifactBaseName: String, version: String, classifier: String? = null): String =
listOfNotNull("org.jetbrains.kotlin:kotlin-$artifactBaseName:$version", classifier).joinToString(":")
fun Project.kotlinStdlib(suffix: String? = null): Any { fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): Any {
return if (kotlinBuildProperties.useBootstrapStdlib) return if (kotlinBuildProperties.useBootstrapStdlib)
kotlinDep(listOfNotNull("stdlib", suffix).joinToString("-"), bootstrapKotlinVersion) kotlinDep(listOfNotNull("stdlib", suffix).joinToString("-"), bootstrapKotlinVersion, classifier)
else else
dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-")) dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-"), classifier)
} }
fun Project.kotlinBuiltins(): Any = fun Project.kotlinBuiltins(): Any =
-3
View File
@@ -19,6 +19,3 @@ runtimeJar {
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main") manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main")
manifest.attributes.put("Class-Path", "kotlin-stdlib.jar") manifest.attributes.put("Class-Path", "kotlin-stdlib.jar")
} }
dist()
-2
View File
@@ -57,5 +57,3 @@ runtimeJar(task<ShadowJar>("shadowJar")) {
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
@@ -71,5 +71,3 @@ runtimeJar(task<ShadowJar>("shadowJar")) {
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
@@ -50,5 +50,3 @@ runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
-2
View File
@@ -22,5 +22,3 @@ sourceSets {
runtimeJar { runtimeJar {
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.preloading.Preloader") manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.preloading.Preloader")
} }
dist()
+9 -19
View File
@@ -1,5 +1,9 @@
ext.configureJvmProject = { Project project -> ext.configureJvmProject = { Project project ->
project.configure(project) { project.configure(project) {
configurations {
sources
}
task sourcesJar(type: Jar, dependsOn: classes) { task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.kotlin from sourceSets.main.kotlin
@@ -31,6 +35,10 @@ ext.configureJavaOnlyJvm6Project = { Project project ->
ext.configureJvm6Project = { Project project -> ext.configureJvm6Project = { Project project ->
project.configure(project) { project.configure(project) {
configurations {
sources
}
project.ext.jvmTarget = "1.6" project.ext.jvmTarget = "1.6"
project.ext.javaHome = JDK_16 project.ext.javaHome = JDK_16
@@ -132,24 +140,6 @@ ext.signPom = { Project project, MavenDeployer deployer ->
} }
} }
ext.configureDist = { Project project ->
project.configure(project) {
configurations {
distJar
}
task dist(type: Copy, dependsOn: assemble) {
rename "-${java.util.regex.Pattern.quote(version)}", ''
into distLibDir
afterEvaluate {
project.artifacts {
distJar file: file("$distLibDir${File.separator}${archivesBaseName}.jar"), builtBy: "dist"
}
}
}
}
}
ext.configurePublishing = { Project project -> ext.configurePublishing = { Project project ->
project.configure(project) { project.configure(project) {
apply plugin: 'maven' apply plugin: 'maven'
@@ -221,6 +211,6 @@ allprojects { project ->
} }
dependencies.ext.kotlinStdlib = { suffix -> dependencies.ext.kotlinStdlib = { suffix ->
DependenciesKt.kotlinStdlib(project, suffix) DependenciesKt.kotlinStdlib(project, suffix, null)
} }
} }
@@ -3,10 +3,8 @@ description = 'Kotlin Test Annotations Common'
apply plugin: 'kotlin-platform-common' apply plugin: 'kotlin-platform-common'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureDist(project)
configurePublishing(project) configurePublishing(project)
dependencies { dependencies {
compile kotlinStdlib("common") compile kotlinStdlib("common")
testCompile project(":kotlin-test:kotlin-test-common") testCompile project(":kotlin-test:kotlin-test-common")
@@ -3,10 +3,8 @@ description = 'Kotlin Test Common'
apply plugin: 'kotlin-platform-common' apply plugin: 'kotlin-platform-common'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureDist(project)
configurePublishing(project) configurePublishing(project)
dependencies { dependencies {
compile kotlinStdlib("common") compile kotlinStdlib("common")
testCompile project(":kotlin-test:kotlin-test-annotations-common") testCompile project(":kotlin-test:kotlin-test-annotations-common")
-8
View File
@@ -68,11 +68,3 @@ artifacts {
if (project.findProperty("kotlin.stdlib.js.ir.publish")?.toBoolean() == true) { if (project.findProperty("kotlin.stdlib.js.ir.publish")?.toBoolean() == true) {
configurePublishing(project) configurePublishing(project)
} }
if (project.findProperty("kotlin.stdlib.js.ir.dist")?.toBoolean() == true) {
configureDist(project)
dist {
from(jar, sourcesJar)
}
}
+9 -12
View File
@@ -2,9 +2,13 @@ description = 'Kotlin Test for JS'
apply plugin: 'kotlin-platform-js' apply plugin: 'kotlin-platform-js'
configureDist(project)
configurePublishing(project) configurePublishing(project)
configurations {
sources
distJs
}
dependencies { dependencies {
expectedBy project(':kotlin-test:kotlin-test-common') expectedBy project(':kotlin-test:kotlin-test-common')
expectedBy project(':kotlin-test:kotlin-test-annotations-common') expectedBy project(':kotlin-test:kotlin-test-annotations-common')
@@ -44,17 +48,10 @@ task sourcesJar(type: Jar, dependsOn: classes) {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
distJs(file(compileKotlin2Js.kotlinOptions.outputFile)) {
builtBy(compileKotlin2Js)
}
} }
javadocJar() javadocJar()
task distJs(type: Copy) {
dependsOn(compileKotlin2Js)
from(compileKotlin2Js.kotlinOptions.outputFile)
into "$distDir/js"
}
dist {
dependsOn distJs
from (jar, sourcesJar)
}
+1 -5
View File
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-platform-jvm'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
pill { pill {
@@ -24,14 +23,11 @@ jar {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
compileKotlin { compileKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name]
} }
+1 -5
View File
@@ -3,7 +3,6 @@ description = 'Kotlin Test JUnit 5'
apply plugin: 'kotlin-platform-jvm' apply plugin: 'kotlin-platform-jvm'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
ext.javaHome = JDK_18 ext.javaHome = JDK_18
ext.jvmTarget = "1.8" ext.jvmTarget = "1.8"
@@ -24,14 +23,11 @@ jar {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions.jdkHome = JDK_18 kotlinOptions.jdkHome = JDK_18
kotlinOptions.jvmTarget = 1.8 kotlinOptions.jvmTarget = 1.8
+1 -5
View File
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-platform-jvm'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
pill { pill {
@@ -47,15 +46,12 @@ task modularJar(type: Jar) {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
archives modularJar archives modularJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
compileKotlin { compileKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xnormalize-constructor-calls=enable", kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xnormalize-constructor-calls=enable",
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts", "-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
+1 -7
View File
@@ -3,32 +3,26 @@ description = 'Kotlin Test TestNG'
apply plugin: 'kotlin-platform-jvm' apply plugin: 'kotlin-platform-jvm'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
ext.javaHome = JDK_17 ext.javaHome = JDK_17
dependencies { dependencies {
expectedBy project(':kotlin-test:kotlin-test-annotations-common') expectedBy project(':kotlin-test:kotlin-test-annotations-common')
compile project(':kotlin-test:kotlin-test-jvm') compile project(':kotlin-test:kotlin-test-jvm')
compile('org.testng:testng:6.13.1') compile('org.testng:testng:6.13.1')
} }
jar { jar {
manifestAttributes(manifest, project, 'Test') manifestAttributes(manifest, project, 'Test')
} }
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
compileKotlin { compileKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name]
} }
-4
View File
@@ -222,7 +222,3 @@ artifacts {
} }
javadocJar() javadocJar()
dist(fromTask = result) {
from(sourcesJar)
}
@@ -23,5 +23,3 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
-2
View File
@@ -22,5 +22,3 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
-12
View File
@@ -3,7 +3,6 @@ description = 'Kotlin Common Standard Library'
apply plugin: 'kotlin-platform-common' apply plugin: 'kotlin-platform-common'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureDist(project)
configurePublishing(project) configurePublishing(project)
def commonSrcDir = "../src" def commonSrcDir = "../src"
@@ -109,15 +108,4 @@ artifacts {
javadocJar() javadocJar()
// TODO: call the "dist" task instead, once we need to publish kotlin-stdlib-common.jar with the compiler distribution
task distCommon(type: Copy) {
from(jar)
from(sourcesJar)
into "$distDir/common"
rename "-${java.util.regex.Pattern.quote(version)}", ''
}
dist.dependsOn distCommon
classes.setDependsOn(classes.dependsOn.findAll { it != "compileJava" }) classes.setDependsOn(classes.dependsOn.findAll { it != "compileJava" })
+2 -6
View File
@@ -4,7 +4,6 @@ apply plugin: 'kotlin'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
ext.javaHome = JDK_17 ext.javaHome = JDK_17
@@ -67,16 +66,13 @@ task modularJar(type: Jar) {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
archives modularJar archives modularJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions.jdkHome = JDK_17 kotlinOptions.jdkHome = JDK_17
} }
+2 -5
View File
@@ -4,7 +4,6 @@ apply plugin: 'kotlin'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
ext.javaHome = JDK_18 ext.javaHome = JDK_18
ext.jvmTarget = "1.8" ext.jvmTarget = "1.8"
@@ -61,15 +60,13 @@ task modularJar(type: Jar) {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
archives modularJar archives modularJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions.jdkHome = JDK_18 kotlinOptions.jdkHome = JDK_18
kotlinOptions.jvmTarget = 1.8 kotlinOptions.jvmTarget = 1.8
-7
View File
@@ -161,13 +161,6 @@ if (project.findProperty("kotlin.stdlib.js.ir.publish")?.toBoolean() == true) {
configurePublishing(project) configurePublishing(project)
} }
if (project.findProperty("kotlin.stdlib.js.ir.dist")?.toBoolean() == true) {
configureDist(project)
dist {
from (jar, sourcesJar)
}
}
node { node {
download = true download = true
version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation
+14 -20
View File
@@ -7,9 +7,14 @@ description = 'Kotlin Standard Library for JS'
apply plugin: 'kotlin-platform-js' apply plugin: 'kotlin-platform-js'
apply plugin: 'idea' apply plugin: 'idea'
configureDist(project)
configurePublishing(project) configurePublishing(project)
configurations {
sources
commonSources
distSources
distJs
}
def builtinsSrcDir = "${buildDir}/builtin-sources" def builtinsSrcDir = "${buildDir}/builtin-sources"
def builtinsSrcDir2 = "${buildDir}/builtin-sources-for-builtins" def builtinsSrcDir2 = "${buildDir}/builtin-sources-for-builtins"
@@ -77,9 +82,6 @@ sourceSets {
} }
} }
configurations {
commonSources
}
dependencies { dependencies {
expectedBy project(":kotlin-stdlib-common") expectedBy project(":kotlin-stdlib-common")
commonSources project(path: ":kotlin-stdlib-common", configuration: "sources") commonSources project(path: ":kotlin-stdlib-common", configuration: "sources")
@@ -331,9 +333,8 @@ task sourcesJar(type: Jar, dependsOn: compileJs) {
task distSourcesJar(type: Jar) { task distSourcesJar(type: Jar) {
dependsOn(sourcesJar, configurations.commonSources) dependsOn(sourcesJar, configurations.commonSources)
baseName = 'dist-kotlin-stdlib-js' destinationDirectory = file("$buildDir/lib/dist")
version = null archiveClassifier = 'sources'
classifier = 'sources'
duplicatesStrategy = DuplicatesStrategy.FAIL duplicatesStrategy = DuplicatesStrategy.FAIL
from zipTree(sourcesJar.outputs.files.singleFile) from zipTree(sourcesJar.outputs.files.singleFile)
@@ -354,23 +355,16 @@ artifacts {
runtime mergedJar runtime mergedJar
archives mergedJar archives mergedJar
archives sourcesJar archives sourcesJar
sources sourcesJar
distSources distSourcesJar
compileJs.outputs.files.forEach { artifact ->
distJs(artifact) { builtBy(compileJs) }
}
} }
javadocJar() javadocJar()
task distJs(type: Copy) {
from(compileJs)
into "$distDir/js"
}
dist {
dependsOn distJs
[mergedJar, distSourcesJar].forEach {
rename("dist-", "")
from(it)
}
}
node { node {
download = true download = true
version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation
@@ -12,6 +12,11 @@ javaHome = rootProject.extra["JDK_16"] as String
val builtins by configurations.creating val builtins by configurations.creating
val runtime by configurations
val runtimeJar by configurations.creating {
runtime.extendsFrom(this)
}
dependencies { dependencies {
compileOnly(project(":kotlin-stdlib")) compileOnly(project(":kotlin-stdlib"))
builtins(project(":core:builtins")) builtins(project(":core:builtins"))
@@ -61,14 +66,11 @@ tasks.withType<KotlinCompile> {
} }
val jar = runtimeJar { val jar = runtimeJar {
archiveFileName.set("kotlin-stdlib-minimal-for-test.jar")
dependsOn(builtins) dependsOn(builtins)
from(provider { zipTree(builtins.singleFile) }) { include("kotlin/**") } from(provider { zipTree(builtins.singleFile) }) { include("kotlin/**") }
} }
val distDir: String by rootProject.extra
dist(targetName = "kotlin-stdlib-minimal-for-test.jar", targetDir = File(distDir), fromTask = jar)
publishing { publishing {
publications { publications {
create<MavenPublication>("internal") { create<MavenPublication>("internal") {
+8 -23
View File
@@ -6,9 +6,12 @@ apply plugin: 'pill-configurable'
archivesBaseName = 'kotlin-stdlib' archivesBaseName = 'kotlin-stdlib'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
configurations {
distSources
}
pill { pill {
importAsLibrary = true importAsLibrary = true
} }
@@ -105,10 +108,10 @@ sourcesJar {
task distSourcesJar(type: Jar) { task distSourcesJar(type: Jar) {
dependsOn(sourcesJar, configurations.commonSources) dependsOn(sourcesJar, configurations.commonSources)
baseName = 'dist-kotlin-stdlib' destinationDirectory = file("$buildDir/lib/dist")
version = null
classifier = 'sources' classifier = 'sources'
duplicatesStrategy = DuplicatesStrategy.FAIL duplicatesStrategy = DuplicatesStrategy.FAIL
from zipTree(sourcesJar.outputs.files.singleFile) from zipTree(sourcesJar.outputs.files.singleFile)
from(zipTree(configurations.commonSources.singleFile)) { from(zipTree(configurations.commonSources.singleFile)) {
@@ -118,12 +121,6 @@ task distSourcesJar(type: Jar) {
} }
} }
task distMavenSources(type: Copy) {
from(sourcesJar)
into "$distDir/maven"
rename "-${java.util.regex.Pattern.quote(version)}", ''
}
task modularJar(type: Jar) { task modularJar(type: Jar) {
dependsOn(jar) dependsOn(jar)
manifestAttributes(manifest, project, 'Main', true) manifestAttributes(manifest, project, 'Main', true)
@@ -138,25 +135,13 @@ task modularJar(type: Jar) {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
distSources distSourcesJar
archives modularJar archives modularJar
} }
javadocJar() javadocJar()
dist {
dependsOn distMavenSources
[jar, distSourcesJar].forEach {
from(it) {
rename('dist-', '')
}
}
from (configurations.compile) {
include 'annotations*.jar'
}
}
task dexMethodCount(type: DexMethodCount) { task dexMethodCount(type: DexMethodCount) {
from jar from jar
ownPackages = ['kotlin'] ownPackages = ['kotlin']
@@ -37,5 +37,3 @@ publish()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
runtimeJar() runtimeJar()
dist()
@@ -4,7 +4,6 @@ apply plugin: 'kotlin'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
pill { pill {
@@ -25,14 +24,11 @@ dependencies {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions.jdkHome = JDK_16 kotlinOptions.jdkHome = JDK_16
kotlinOptions.jvmTarget = 1.6 kotlinOptions.jvmTarget = 1.6
@@ -17,18 +17,12 @@ val jarBaseName = property("archivesBaseName") as String
val proguardLibraryJars by configurations.creating val proguardLibraryJars by configurations.creating
val default by configurations
val runtimeJar by configurations.creating
default.apply {
extendsFrom(runtimeJar)
}
val projectsDependencies = listOf( val projectsDependencies = listOf(
":kotlin-scripting-common", ":kotlin-scripting-common",
":kotlin-scripting-jvm", ":kotlin-scripting-jvm",
":kotlin-script-util", ":kotlin-script-util",
":kotlin-script-runtime") ":kotlin-script-runtime"
)
dependencies { dependencies {
projectsDependencies.forEach { projectsDependencies.forEach {
@@ -95,17 +89,18 @@ val proguard by task<ProGuardTask> {
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars) libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
} }
val pack = if (shrink) proguard else packJar val resultJar = tasks.register<Jar>("resultJar") {
val pack = if (shrink) proguard else packJar
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) { dependsOn(pack)
name = jarBaseName setupPublicJar(jarBaseName)
classifier = "" from {
zipTree(pack.outputs.files.singleFile)
}
} }
dist( addArtifact("runtime", resultJar)
targetName = "$name.jar", addArtifact("archives", resultJar)
fromTask = pack
)
sourcesJar() sourcesJar()
javadocJar() javadocJar()
+1 -2
View File
@@ -60,8 +60,7 @@ tasks {
} }
"test" { "test" {
// These dependencies are needed because ForTestCompileRuntime loads jars from dist // These dependencies are needed because ForTestCompileRuntime loads jars from dist
dependsOn(":kotlin-reflect:dist") dependsOn(":dist")
dependsOn(":kotlin-script-runtime:dist")
} }
} }
@@ -16,5 +16,3 @@ sourceSets {
"main" { projectDefault() } "main" { projectDefault() }
"test" {} "test" {}
} }
dist()
+1 -7
View File
@@ -4,7 +4,6 @@ apply plugin: 'kotlin'
apply plugin: 'pill-configurable' apply plugin: 'pill-configurable'
configureJvm6Project(project) configureJvm6Project(project)
configureDist(project)
configurePublishing(project) configurePublishing(project)
pill { pill {
@@ -33,15 +32,12 @@ jar {
artifacts { artifacts {
archives sourcesJar archives sourcesJar
sources sourcesJar
mainJar jar mainJar jar
} }
javadocJar() javadocJar()
dist {
from (jar, sourcesJar)
}
compileKotlin { compileKotlin {
kotlinOptions.freeCompilerArgs = [ kotlinOptions.freeCompilerArgs = [
"-Xallow-kotlin-package", "-Xallow-kotlin-package",
@@ -49,5 +45,3 @@ compileKotlin {
"-module-name", project.name "-module-name", project.name
] ]
} }
+2 -4
View File
@@ -30,11 +30,9 @@ sourceSets {
"test" { projectDefault() } "test" { projectDefault() }
} }
val jar = runtimeJar {} runtimeJar()
testsJar {} testsJar()
dist(targetName = the<BasePluginConvention>().archivesBaseName.removePrefix("kotlin-") + ".jar")
projectTest(parallel = true) { projectTest(parallel = true) {
workingDir = rootDir workingDir = rootDir
@@ -47,8 +47,6 @@ sourceSets {
runtimeJar() runtimeJar()
dist()
testsJar() testsJar()
projectTest { projectTest {
@@ -75,7 +75,7 @@ sourceSets {
testsJar {} testsJar {}
projectTest(parallel = true) { projectTest(parallel = true) {
dependsOn(":kotlin-android-extensions-runtime:dist") dependsOn(":dist")
workingDir = rootDir workingDir = rootDir
useAndroidSdk() useAndroidSdk()
useAndroidJar() useAndroidJar()
@@ -22,5 +22,3 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist(targetName = "android-extensions-runtime.jar")
-2
View File
@@ -35,5 +35,3 @@ projectTest {
} }
runtimeJar() runtimeJar()
dist()
-1
View File
@@ -39,6 +39,5 @@ publish()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
testsJar() testsJar()
+1 -3
View File
@@ -18,9 +18,7 @@ sourceSets {
"test" { projectDefault() } "test" { projectDefault() }
} }
testsJar {} testsJar()
dist()
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
@@ -60,5 +60,3 @@ runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
@@ -21,5 +21,3 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist(targetName = "kotlin-annotation-processing-runtime.jar")
@@ -36,9 +36,7 @@ sourceSets {
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
testsJar {} testsJar()
dist(targetName = the<BasePluginConvention>().archivesBaseName + ".jar")
projectTest(parallel = true) { projectTest(parallel = true) {
workingDir = rootDir workingDir = rootDir
-2
View File
@@ -34,8 +34,6 @@ runtimeJar()
testsJar() testsJar()
dist(targetName = the<BasePluginConvention>().archivesBaseName.removePrefix("kotlin-") + ".jar")
projectTest(parallel = true) { projectTest(parallel = true) {
workingDir = rootDir workingDir = rootDir
} }
@@ -34,13 +34,9 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
testsJar {} testsJar()
dist {
rename("kotlin-", "")
}
projectTest(parallel = true) { projectTest(parallel = true) {
dependsOn(":kotlin-stdlib:jvm-minimal-for-test:dist") dependsOn(":dist")
workingDir = rootDir workingDir = rootDir
} }
@@ -50,8 +50,6 @@ runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
} }
@@ -47,12 +47,10 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
publish() publish()
val jar = runtimeJar {} runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
} }
@@ -47,5 +47,3 @@ publish()
runtimeJar() runtimeJar()
sourcesJar() sourcesJar()
javadocJar() javadocJar()
dist()
+6 -14
View File
@@ -1,8 +1,8 @@
@file:Suppress("HasPlatformType")
import java.io.File import java.io.File
val buildVersionFilePath = "${rootProject.extra["distDir"]}/build.txt" val buildVersionFilePath = "$buildDir/build.txt"
val buildVersion by configurations.creating val buildVersion by configurations.creating
val buildNumber: String by rootProject.extra val buildNumber: String by rootProject.extra
val kotlinVersion: String by rootProject.extra val kotlinVersion: String by rootProject.extra
@@ -17,6 +17,10 @@ val writeBuildNumber by tasks.creating {
} }
} }
artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
builtBy(writeBuildNumber)
}
fun replaceVersion(versionFile: File, versionPattern: String, replacement: (MatchResult) -> String) { fun replaceVersion(versionFile: File, versionPattern: String, replacement: (MatchResult) -> String) {
check(versionFile.isFile) { "Version file $versionFile is not found" } check(versionFile.isFile) { "Version file $versionFile is not found" }
val text = versionFile.readText() val text = versionFile.readText()
@@ -69,15 +73,3 @@ val writePluginVersion by tasks.creating {
val writeVersions by tasks.creating { val writeVersions by tasks.creating {
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion) dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
} }
artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
builtBy(writeBuildNumber)
}
val distKotlinHomeDir: String by rootProject.extra
val dist by task<Copy> {
from(writeBuildNumber)
into(File(distKotlinHomeDir))
}
@@ -36,9 +36,7 @@ sourceSets {
} }
projectTest { projectTest {
dependsOn(":kotlin-compiler:dist", dependsOn(":dist")
":kotlin-stdlib:dist",
":kotlin-script-runtime:dist")
workingDir = File(rootDir, "libraries/tools/kotlin-compiler-client-embeddable-test/src") workingDir = File(rootDir, "libraries/tools/kotlin-compiler-client-embeddable-test/src")
doFirst { doFirst {
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator)) systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
+178 -15
View File
@@ -1,5 +1,8 @@
@file:Suppress("HasPlatformType")
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import proguard.gradle.ProGuardTask import proguard.gradle.ProGuardTask
import java.util.regex.Pattern.quote
description = "Kotlin Compiler" description = "Kotlin Compiler"
@@ -12,21 +15,30 @@ plugins {
// 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 = findProperty("kotlin.build.proguard")?.toString()?.toBoolean() ?: hasProperty("teamcity") val shrink = findProperty("kotlin.build.proguard")?.toString()?.toBoolean() ?: hasProperty("teamcity")
val jsIrDist = findProperty("kotlin.stdlib.js.ir.dist")?.toString()?.toBoolean() == true
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 runtimeJar by configurations.creating val runtimeJar by configurations.creating
val compile by configurations // maven plugin writes pom compile scope from compile configuration by default val compile by configurations // maven plugin writes pom compile scope from compile configuration by default
val libraries by configurations.creating { val proguardLibraries by configurations.creating {
extendsFrom(compile) extendsFrom(compile)
} }
val trove4jJar by configurations.creating // Libraries to copy to the lib directory
val ktorNetworkJar by configurations.creating val libraries by configurations.creating
// Compiler plugins should be copied without `kotlin-` prefix
val default by configurations val compilerPlugins by configurations.creating
default.extendsFrom(runtimeJar) val sources by configurations.creating
// contents of dist/maven directory
val distMavenContents by configurations.creating
// contents of dist/common directory
val distCommonContents by configurations.creating
val distStdlibMinimalForTests by configurations.creating
val buildNumber by configurations.creating
val distJSContents by configurations.creating
val compilerBaseName = name val compilerBaseName = name
@@ -34,14 +46,78 @@ val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName.jar")
val compilerModules: Array<String> by rootProject.extra val compilerModules: Array<String> by rootProject.extra
val distLibraryProjects = listOfNotNull(
":kotlin-annotation-processing",
":kotlin-annotation-processing-cli",
":kotlin-annotation-processing-runtime",
":kotlin-annotations-android",
":kotlin-annotations-jvm",
":kotlin-ant",
":kotlin-daemon",
":kotlin-daemon-client",
":kotlin-daemon-client-new",
":kotlin-imports-dumper-compiler-plugin",
":kotlin-main-kts",
":kotlin-preloader",
":kotlin-reflect",
":kotlin-runner",
":kotlin-script-runtime",
":kotlin-scripting-common",
":kotlin-scripting-compiler",
":kotlin-scripting-compiler-impl",
":kotlin-scripting-jvm",
":kotlin-stdlib-js-ir".takeIf { jsIrDist },
":kotlin-source-sections-compiler-plugin",
":kotlin-test:kotlin-test-js",
":kotlin-test:kotlin-test-js-ir".takeIf { jsIrDist },
":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-junit5",
":kotlin-test:kotlin-test-jvm",
":kotlin-test:kotlin-test-testng",
":libraries:tools:mutability-annotations-compat",
":plugins:android-extensions-compiler",
":plugins:jvm-abi-gen"
)
val distCompilerPluginProjects = listOf(
":kotlin-allopen-compiler-plugin",
":kotlin-android-extensions-runtime",
":kotlin-noarg-compiler-plugin",
":kotlin-sam-with-receiver-compiler-plugin",
":kotlinx-serialization-compiler-plugin"
)
val distSourcesProjects = listOfNotNull(
":kotlin-annotations-jvm",
":kotlin-reflect",
":kotlin-script-runtime",
":kotlin-stdlib-jdk7".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-stdlib-jdk8".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-stdlib-js-ir".takeIf { jsIrDist },
":kotlin-test:kotlin-test-js",
":kotlin-test:kotlin-test-js-ir".takeIf { jsIrDist },
":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-junit5",
":kotlin-test:kotlin-test-jvm",
":kotlin-test:kotlin-test-testng"
)
libraries.apply {
resolutionStrategy {
preferProjectModules()
}
exclude("org.jetbrains.kotlin", "kotlin-stdlib-common")
}
dependencies { dependencies {
compile(kotlinStdlib()) compile(kotlinStdlib())
compile(project(":kotlin-script-runtime")) compile(project(":kotlin-script-runtime"))
compile(project(":kotlin-reflect")) compile(project(":kotlin-reflect"))
compile(commonDep("org.jetbrains.intellij.deps", "trove4j")) compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
libraries(project(":kotlin-annotations-jvm")) proguardLibraries(project(":kotlin-annotations-jvm"))
libraries( proguardLibraries(
files( files(
firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"), firstFromJavaHomeThatExists("jre/lib/rt.jar", "../Classes/classes.jar"),
firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"), firstFromJavaHomeThatExists("jre/lib/jsse.jar", "../Classes/jsse.jar"),
@@ -53,8 +129,39 @@ dependencies {
fatJarContents(project(it)) { isTransitive = false } fatJarContents(project(it)) { isTransitive = false }
} }
trove4jJar(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } } libraries(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } }
ktorNetworkJar(commonDep("io.ktor", "ktor-network")) libraries(commonDep("io.ktor", "ktor-network"))
libraries(kotlinStdlib("jdk8"))
libraries(kotlinStdlib("js"))
distLibraryProjects.forEach {
libraries(project(it)) { isTransitive = false }
}
distCompilerPluginProjects.forEach {
compilerPlugins(project(it)) { isTransitive = false }
}
distSourcesProjects.forEach {
sources(project(it, configuration = "sources"))
}
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
sources(project(":kotlin-stdlib", configuration = "distSources"))
sources(project(":kotlin-stdlib-js", configuration = "distSources"))
distStdlibMinimalForTests(project(":kotlin-stdlib:jvm-minimal-for-test"))
distJSContents(project(":kotlin-stdlib-js", configuration = "distJs"))
distJSContents(project(":kotlin-test:kotlin-test-js", configuration = "distJs"))
}
distCommonContents(kotlinStdlib(suffix = "common"))
distCommonContents(kotlinStdlib(suffix = "common", classifier = "sources"))
distMavenContents(kotlinStdlib(classifier = "sources"))
buildNumber(project(":prepare:build.version", configuration = "buildVersion"))
fatJarContents(kotlinBuiltins()) fatJarContents(kotlinBuiltins())
fatJarContents(commonDep("javax.inject")) fatJarContents(commonDep("javax.inject"))
@@ -96,7 +203,7 @@ noDefaultJar()
val packCompiler by task<ShadowJar> { val packCompiler by task<ShadowJar> {
configurations = emptyList() configurations = emptyList()
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDir = File(buildDir, "libs") destinationDirectory.set(File(buildDir, "libs"))
setupPublicJar(compilerBaseName, "before-proguard") setupPublicJar(compilerBaseName, "before-proguard")
@@ -129,7 +236,7 @@ val proguard by task<ProGuardTask> {
inputs.files(packCompiler.outputs.files.singleFile) inputs.files(packCompiler.outputs.files.singleFile)
outputs.file(outputJar) outputs.file(outputJar)
libraryjars(mapOf("filter" to "!META-INF/versions/**"), libraries) libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraries)
printconfiguration("$buildDir/compiler.pro.dump") printconfiguration("$buildDir/compiler.pro.dump")
@@ -142,9 +249,56 @@ val proguard by task<ProGuardTask> {
val pack = if (shrink) proguard else packCompiler val pack = if (shrink) proguard else packCompiler
dist(targetName = "$compilerBaseName.jar", fromTask = pack) { val distDir: String by rootProject.extra
from(trove4jJar)
from(ktorNetworkJar) val distKotlinc = distTask<Sync>("distKotlinc") {
destinationDir = File("$distDir/kotlinc")
from(buildNumber)
into("bin") {
from(files("$rootDir/compiler/cli/bin"))
}
into("license") {
from(files("$rootDir/license"))
}
into("lib") {
from(pack) { rename { "$compilerBaseName.jar" } }
from(libraries)
from(sources)
from(compilerPlugins) {
rename { it.removePrefix("kotlin-") }
}
}
}
val distCommon = distTask<Sync>("distCommon") {
destinationDir = File("$distDir/common")
from(distCommonContents)
}
val distMaven = distTask<Sync>("distMaven") {
destinationDir = File("$distDir/maven")
from(distMavenContents)
}
val distJs = distTask<Sync>("distJs") {
destinationDir = File("$distDir/js")
from(distJSContents)
}
distTask<Copy>("dist") {
destinationDir = File(distDir)
dependsOn(distKotlinc)
dependsOn(distCommon)
dependsOn(distMaven)
dependsOn(distJs)
from(buildNumber)
from(distStdlibMinimalForTests)
} }
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) { runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
@@ -161,3 +315,12 @@ sourcesJar {
} }
javadocJar() javadocJar()
inline fun <reified T : AbstractCopyTask> Project.distTask(
name: String,
crossinline block: T.() -> Unit
) = tasks.register<T>(name) {
duplicatesStrategy = DuplicatesStrategy.FAIL
rename(quote("-$version"), "")
block()
}