Refactor build to make manifest specification less error-prone.

Use legacy implementation title in manifest of JS stdlib for now.

Change the way common jvm project configurations is applied.
Add missing artifacts to common libraries.
This commit is contained in:
Ilya Gorbunov
2017-03-28 23:43:56 +03:00
parent 325ebfbd5f
commit 92ef26606b
13 changed files with 81 additions and 87 deletions
+12 -30
View File
@@ -68,34 +68,9 @@ subprojects {
} }
} }
// plain kotlin jvm projects static def configureJvmProject(Project project) {
configure(subprojects.findAll {it.name in [
'kotlin-runtime', 'kotlin-script-runtime',
'kotlin-stdlib', 'kotlin-stdlib-jre7', 'kotlin-stdlib-jre8',
'kotlin-test-junit',
'kotlin-reflect']}) {
apply plugin: 'kotlin'
commonJvmProjectConfiguration(project)
}
static def commonJvmProjectConfiguration(Project project) {
project.configure(project) { project.configure(project) {
jar { task sourcesJar(type: Jar, dependsOn: classes) {
manifest {
attributes 'Implementation-Vendor': 'JetBrains',
'Implementation-Title': "${project.description ?: project.name}", // TODO: project.description is resolved after evaluating this, therefore this attribute is repeated in the projects; seek for a solution
'Implementation-Version': version,
'Build-Jdk': System.getProperty('java.version'),
'Built-By': 'JetBrains'
}
from("${rootDir}/../dist/kotlinc/build.txt") { into("META-INF/") }
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.kotlin from sourceSets.main.kotlin
} }
@@ -117,12 +92,19 @@ static def commonJvmProjectConfiguration(Project project) {
} }
} }
static def manifestAttributes(Manifest manifest, Project project, String component) { static def manifestAttributes(Manifest manifest, Project project, String component = null) {
project.configure(manifest) { project.configure(manifest) {
attributes \ attributes \
'Implementation-Vendor': 'JetBrains',
'Implementation-Title': project.archivesBaseName,
'Implementation-Version': project.version,
'Build-Jdk': System.getProperty('java.version')
if (component != null) {
attributes \
'Kotlin-Runtime-Component': component, 'Kotlin-Runtime-Component': component,
'Kotlin-Version': "${project.kotlin_language_version}", 'Kotlin-Version': project.kotlin_language_version
'Implementation-Title': "${project.description ?: project.name}" }
} }
} }
+7 -16
View File
@@ -6,25 +6,16 @@ dependencies {
compile project(':kotlin-stdlib-common') compile project(':kotlin-stdlib-common')
} }
// common block
jar { jar {
baseName = project.name manifestAttributes(manifest, project, 'Test')
manifest {
attributes 'Implementation-Vendor': 'JetBrains',
'Implementation-Title': "${project.description ?: project.name}", // TODO: project.description is resolved after evaluating this, therefore this attribute is repeated in the projects; seek for a solution
'Implementation-Version': version,
'Build-Jdk': System.getProperty('java.version'),
'Built-By': 'JetBrains'
}
from("${rootDir}/../dist/kotlinc/build.txt") { into("META-INF/") }
} }
task sourcesJar(type: Jar, dependsOn:classes) { task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.kotlin from sourceSets.main.kotlin
} }
artifacts {
archives sourcesJar
archives javadocJar
}
+1 -6
View File
@@ -27,12 +27,7 @@ compileTestKotlin2Js {
archivesBaseName = 'kotlin-test-js' archivesBaseName = 'kotlin-test-js'
jar { jar {
manifest { manifestAttributes(manifest, project, 'Test')
attributes 'addDefaultImplementationEntries': true,
'Implementation-Title': "${project.description ?: project.name}"
}
dependsOn classes
from sourceSets.main.output
} }
task sourcesJar(type: Jar, dependsOn: classes) { task sourcesJar(type: Jar, dependsOn: classes) {
+11 -10
View File
@@ -1,27 +1,28 @@
description = 'Kotlin Test JUnit' description = 'Kotlin Test JUnit'
apply plugin: 'kotlin'
configureJvmProject(project)
dependencies { dependencies {
compile project(':kotlin-test:kotlin-test-jvm') compile project(':kotlin-test:kotlin-test-jvm')
compile('junit:junit:4.12') compile('junit:junit:4.12')
} }
jar { jar {
manifest { manifestAttributes(manifest, project, 'Test')
attributes 'Implementation-Title': "${project.description ?: project.name}"
}
} }
artifacts { artifacts {
archives sourcesJar archives sourcesJar
archives javadocJar archives javadocJar
} }
compileKotlin { compileKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name]
} }
compileTestKotlin { compileTestKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
} }
+3 -7
View File
@@ -3,23 +3,19 @@ description = 'Kotlin Test'
apply plugin: 'kotlin-platform-jvm' apply plugin: 'kotlin-platform-jvm'
configureJvmProject(project)
dependencies { dependencies {
implement project(':kotlin-test:kotlin-test-common') implement project(':kotlin-test:kotlin-test-common')
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
testCompile('junit:junit:4.12') testCompile('junit:junit:4.12')
} }
commonJvmProjectConfiguration(project)
archivesBaseName = 'kotlin-test' archivesBaseName = 'kotlin-test'
jar { jar {
manifest { manifestAttributes(manifest, project, 'Test')
attributes 'addDefaultImplementationEntries': true,
'Implementation-Title': "${project.description ?: project.name}"
}
dependsOn classes
from sourceSets.main.output
} }
artifacts { artifacts {
+5 -1
View File
@@ -1,5 +1,9 @@
description = 'Kotlin Standard Library' description = 'Kotlin Standard Library'
apply plugin: 'kotlin'
configureJvmProject(project)
sourceSets { sourceSets {
builtins { builtins {
java { java {
@@ -39,7 +43,7 @@ task originalStdlibJar(type: Jar) {
} }
jar { jar {
manifestAttributes(manifest, project, 'Core') manifestAttributes(manifest, project, 'Main')
from("${rootDir}/../dist/builtins") from("${rootDir}/../dist/builtins")
from sourceSets.builtins.output from sourceSets.builtins.output
} }
+7 -11
View File
@@ -29,20 +29,16 @@ compileKotlinCommon {
*/ */
jar { jar {
baseName = project.name manifestAttributes(manifest, project, 'Main')
manifest {
attributes 'Implementation-Vendor': 'JetBrains',
'Implementation-Title': "${project.description ?: project.name}", // TODO: project.description is resolved after evaluating this, therefore this attribute is repeated in the projects; seek for a solution
'Implementation-Version': version,
'Build-Jdk': System.getProperty('java.version'),
'Built-By': 'JetBrains'
}
from("${rootDir}/../dist/kotlinc/build.txt") { into("META-INF/") }
} }
task sourcesJar(type: Jar, dependsOn:classes) { task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.kotlin from sourceSets.main.kotlin
} }
artifacts {
archives sourcesJar
archives javadocJar
}
+4 -1
View File
@@ -1,5 +1,8 @@
description = 'Kotlin Standard Library JRE 7 extension' description = 'Kotlin Standard Library JRE 7 extension'
apply plugin: 'kotlin'
configureJvmProject(project)
dependencies { dependencies {
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
@@ -23,7 +26,7 @@ sourceSets {
} }
jar { jar {
manifestAttributes(manifest, project, 'Core') manifestAttributes(manifest, project, 'Main')
} }
artifacts { artifacts {
+5 -1
View File
@@ -1,5 +1,9 @@
description = 'Kotlin Standard Library JRE 8 extension' description = 'Kotlin Standard Library JRE 8 extension'
apply plugin: 'kotlin'
configureJvmProject(project)
dependencies { dependencies {
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
compile project(':kotlin-stdlib-jre7') compile project(':kotlin-stdlib-jre7')
@@ -24,7 +28,7 @@ sourceSets {
} }
jar { jar {
manifestAttributes(manifest, project, 'Core') manifestAttributes(manifest, project, 'Main')
} }
artifacts { artifacts {
+9
View File
@@ -188,6 +188,15 @@ jar {
task mergedJar(type: Jar, dependsOn: classes) { task mergedJar(type: Jar, dependsOn: classes) {
classifier = null classifier = null
manifestAttributes(manifest, project, 'Main')
// TODO: Use standard implementation title after js stdlib detector becomes more flexible
Properties properties = new Properties()
new File("${rootDir}/../resources/kotlinManifest.properties").withInputStream {
properties.load(it)
}
manifest.attributes 'Implementation-Title' : properties."manifest.impl.title.kotlin.javascript.stdlib"
includeEmptyDirs false includeEmptyDirs false
duplicatesStrategy DuplicatesStrategy.EXCLUDE duplicatesStrategy DuplicatesStrategy.EXCLUDE
from jsOutputFile from jsOutputFile
@@ -13,6 +13,10 @@ buildscript {
} }
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'kotlin'
configureJvmProject(project)
def core = "${rootDir}/../core" def core = "${rootDir}/../core"
def annotationsSrc = "${buildDir}/annotations" def annotationsSrc = "${buildDir}/annotations"
@@ -79,6 +83,9 @@ kotlin.experimental.coroutines "enable"
task reflectShadowJar(type: ShadowJar) { task reflectShadowJar(type: ShadowJar) {
classifier = 'shadow' classifier = 'shadow'
version = null version = null
manifestAttributes(manifest, project, 'Main')
manifest.attributes 'Class-Path': 'kotlin-runtime.jar' // TODO replace soon with 'kotlin-stdlib.jar'
from (sourceSets.main.output) from (sourceSets.main.output)
from ("${core}/descriptor.loader.java/src") { from ("${core}/descriptor.loader.java/src") {
include 'META-INF/services/**' include 'META-INF/services/**'
+5 -2
View File
@@ -1,5 +1,8 @@
description 'Kotlin Runtime (deprecated, use koltin-stdlib artifact instead)'
description 'Kotlin Runtime' apply plugin: 'kotlin'
configureJvmProject(project)
dependencies { dependencies {
compile group: 'org.jetbrains', name: 'annotations', version:'13.0' compile group: 'org.jetbrains', name: 'annotations', version:'13.0'
@@ -20,7 +23,7 @@ sourceSets {
} }
jar { jar {
manifestAttributes(manifest, project, 'Core') manifestAttributes(manifest, project, 'Main')
from("${rootDir}/../dist/builtins") from("${rootDir}/../dist/builtins")
} }
+5 -2
View File
@@ -1,6 +1,9 @@
description 'Kotlin Script Runtime' description 'Kotlin Script Runtime'
apply plugin: 'kotlin'
configureJvmProject(project)
dependencies { dependencies {
compileOnly project(':kotlin-stdlib') compileOnly project(':kotlin-stdlib')
} }
@@ -14,7 +17,7 @@ sourceSets {
} }
jar { jar {
manifestAttributes(manifest, project, 'Core') manifestAttributes(manifest, project, 'Main')
} }
artifacts { artifacts {