From 08fa304b6fd413f1005388a8a49578313a48508a Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 6 Mar 2017 19:47:51 +0300 Subject: [PATCH] Build common standard library headers and kotlin-test (common and jvm) as multiplatform projects. --- libraries/build.gradle | 101 +++++++++++------- libraries/kotlin.test/common/build.gradle | 55 ++++++++++ .../kotlin/kotlin/jvm/internalAnnotations.kt | 9 -- libraries/kotlin.test/junit/build.gradle | 17 +-- .../kotlin.test/{shared => jvm}/build.gradle | 28 ++--- libraries/settings.gradle | 28 ++--- libraries/stdlib/build.gradle | 29 +---- libraries/stdlib/common/build.gradle | 68 +++++++++++- libraries/stdlib/common/tasks.xml | 20 ++++ libraries/stdlib/jre7/build.gradle | 19 +++- libraries/stdlib/jre8/build.gradle | 19 +++- 11 files changed, 272 insertions(+), 121 deletions(-) create mode 100644 libraries/kotlin.test/common/build.gradle delete mode 100644 libraries/kotlin.test/common/src/main/kotlin/kotlin/jvm/internalAnnotations.kt rename libraries/kotlin.test/{shared => jvm}/build.gradle (53%) create mode 100644 libraries/stdlib/common/tasks.xml diff --git a/libraries/build.gradle b/libraries/build.gradle index c0c9992048c..2e3c2bf2cc4 100644 --- a/libraries/build.gradle +++ b/libraries/build.gradle @@ -14,6 +14,8 @@ buildscript { ext.JDK_16 = System.getenv("JDK_16") ext.JDK_17 = System.getenv("JDK_17") ext.JDK_18 = System.getenv("JDK_18") +ext.bootstrapCompilerFile = project.file("${rootDir}/../dist/kotlinc/lib/kotlin-compiler.jar") +ext.compilerPreloaderFile = project.file("${rootDir}/../dist/kotlinc/lib/kotlin-preloader.jar") allprojects { apply plugin: 'maven' @@ -23,45 +25,12 @@ allprojects { } subprojects { - apply plugin: 'kotlin' apply plugin: 'signing' repositories { mavenCentral() } - jar { - baseName = project.name - 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/") } - } - - // TODO: use dokka instead? - javadoc { - failOnError = false - } - - task sourcesJar(type: Jar, dependsOn:classes) { - classifier = 'sources' - from sourceSets.main.kotlin - } - - task javadocJar(type: Jar, dependsOn:javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - compileKotlin.compilerJarFile = project.file("${rootDir}/../dist/kotlinc/lib/kotlin-compiler.jar") - compileTestKotlin.compilerJarFile = project.file("${rootDir}/../dist/kotlinc/lib/kotlin-compiler.jar") - - compileKotlin.kotlinOptions.jdkHome = JDK_16 - signing { required { project.ext.has('signing.keyId') } sign configurations.archives @@ -83,9 +52,65 @@ subprojects { } } +// plain kotlin jvm projects +configure(subprojects.findAll {it.name in [ + 'kotlin-runtime', 'kotlin-script-runtime', + 'kotlin-stdlib', 'kotlin-stdlib-jre7', 'kotlin-stdlib-jre8', + 'kotlin-test-junit']}) { + + apply plugin: 'kotlin' + + commonJvmProjectConfiguration(project) + +} + +static def commonJvmProjectConfiguration(Project project) { + project.configure(project) { + jar { + 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/") } + } + + + // TODO: use dokka instead? + javadoc { + failOnError = false + } + + task sourcesJar(type: Jar, dependsOn:classes) { + classifier = 'sources' + from sourceSets.main.kotlin + } + + task javadocJar(type: Jar, dependsOn:javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + + compileKotlin.compilerJarFile = bootstrapCompilerFile + compileTestKotlin.compilerJarFile = bootstrapCompilerFile + + compileKotlin.kotlinOptions.jdkHome = JDK_16 + compileTestKotlin.kotlinOptions.jdkHome = JDK_16 + + test { + executable = "$JDK_16/bin/java" + } + } +} + static def manifestAttributes(Manifest manifest, Project project, String component) { - manifest.attributes \ - 'Kotlin-Runtime-Component': component, - 'Kotlin-Version': "${project.kotlin_language_version}", - 'Implementation-Title': "${project.description ?: project.name}" -} \ No newline at end of file + project.configure(manifest) { + attributes \ + 'Kotlin-Runtime-Component': component, + 'Kotlin-Version': "${project.kotlin_language_version}", + 'Implementation-Title': "${project.description ?: project.name}" + } +} + diff --git a/libraries/kotlin.test/common/build.gradle b/libraries/kotlin.test/common/build.gradle new file mode 100644 index 00000000000..c918cc41053 --- /dev/null +++ b/libraries/kotlin.test/common/build.gradle @@ -0,0 +1,55 @@ +description = 'Kotlin Test Common' + +apply plugin: 'kotlin-platform-common' + +dependencies { + compile project(':kotlin-stdlib-common') +} + +sourceSets { + test { + kotlin { + srcDir 'src/test' + exclude '**' + } + } +} + + +// common block + +compileKotlinCommon.compilerJarFile = bootstrapCompilerFile + + + +jar { + baseName = project.name + 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/") } +} + + +// TODO: use dokka instead? +javadoc { + failOnError = false +} + +task sourcesJar(type: Jar, dependsOn:classes) { + classifier = 'sources' + from sourceSets.main.kotlin + +} + +task javadocJar(type: Jar, dependsOn:javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + + + diff --git a/libraries/kotlin.test/common/src/main/kotlin/kotlin/jvm/internalAnnotations.kt b/libraries/kotlin.test/common/src/main/kotlin/kotlin/jvm/internalAnnotations.kt deleted file mode 100644 index 05526240fef..00000000000 --- a/libraries/kotlin.test/common/src/main/kotlin/kotlin/jvm/internalAnnotations.kt +++ /dev/null @@ -1,9 +0,0 @@ -package kotlin.jvm - -@Suppress("HEADER_WITHOUT_IMPLEMENTATION") -@Target(AnnotationTarget.FILE) -internal header annotation class JvmMultifileClass - -@Suppress("HEADER_WITHOUT_IMPLEMENTATION") -@Target(AnnotationTarget.FILE) -internal header annotation class JvmName(val name: String) diff --git a/libraries/kotlin.test/junit/build.gradle b/libraries/kotlin.test/junit/build.gradle index 5c0de1c1429..367ae54f2e7 100644 --- a/libraries/kotlin.test/junit/build.gradle +++ b/libraries/kotlin.test/junit/build.gradle @@ -2,25 +2,10 @@ description = 'Kotlin Test JUnit' dependencies { - compile project(':kotlin-runtime') - compile project(':kotlin-test-parent:kotlin-test') + compile project(':kotlin-test:kotlin-test-jvm') compile('junit:junit:4.12') } -sourceSets { - main { - kotlin { - srcDir 'src/main/kotlin' - srcDir 'src/main/kotlin.jvm' - } - } - test { - kotlin { - srcDir 'src/test/kotlin' - srcDir 'src/test/kotlin.jvm' - } - } -} jar { manifest { diff --git a/libraries/kotlin.test/shared/build.gradle b/libraries/kotlin.test/jvm/build.gradle similarity index 53% rename from libraries/kotlin.test/shared/build.gradle rename to libraries/kotlin.test/jvm/build.gradle index 086206332f6..b6a3f1c31a8 100644 --- a/libraries/kotlin.test/shared/build.gradle +++ b/libraries/kotlin.test/jvm/build.gradle @@ -1,25 +1,17 @@ description = 'Kotlin Test' +apply plugin: 'kotlin-platform-jvm' + dependencies { - compile project(':kotlin-runtime') + implement project(':kotlin-test:kotlin-test-common') + compile project(':kotlin-stdlib') testCompile('junit:junit:4.12') } -sourceSets { - main { - kotlin { - srcDir 'src/main/kotlin' - srcDir 'src/main/kotlin.jvm' - } - } - test { - kotlin { - srcDir 'src/test/kotlin' - srcDir 'src/test/kotlin.jvm' - } - } -} +commonJvmProjectConfiguration(project) + +archivesBaseName = 'kotlin-test' jar { manifest { @@ -28,9 +20,6 @@ jar { } dependsOn classes from sourceSets.main.output - exclude('kotlin/internal/OnlyInputTypes*') - exclude('kotlin/internal/InlineOnly*') - exclude('kotlin/internal') } artifacts { @@ -39,7 +28,8 @@ artifacts { } compileKotlin { - kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", "${project.name}".toString()] + // TODO: Why "-Xmulti-platfrom" ? + kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xmulti-platform", "-module-name", project.archivesBaseName] } compileTestKotlin { diff --git a/libraries/settings.gradle b/libraries/settings.gradle index ab87b5c8636..745fabb9aa7 100644 --- a/libraries/settings.gradle +++ b/libraries/settings.gradle @@ -1,15 +1,17 @@ rootProject.name = 'kotlin-libraries' include ':kotlin-runtime' include ':kotlin-script-runtime' -include ':kotlin-js-library' -include ':kotlin-test-parent' -include ':kotlin-test-parent:kotlin-test' -include ':kotlin-test-parent:kotlin-test-junit' -//include ':kotlin-stdlib-common' +//include ':kotlin-js-library' +include ':kotlin-test' +include ':kotlin-test:kotlin-test-common' +include ':kotlin-test:kotlin-test-jvm' +include ':kotlin-test:kotlin-test-junit' +//include ':kotlin-test:kotlin-test-js' +include ':kotlin-stdlib-common' include ':kotlin-stdlib' include ':kotlin-stdlib-jre7' include ':kotlin-stdlib-jre8' -include ':kotlin-reflect' +//include ':kotlin-reflect' //include ':kotlin-compiler' //include ':kotlin-compiler-embeddable' @@ -50,15 +52,17 @@ include ':kotlin-reflect' project(':kotlin-runtime').projectDir = "$rootDir/tools/runtime" as File project(':kotlin-script-runtime').projectDir = "$rootDir/tools/script-runtime" as File -project(':kotlin-js-library').projectDir = "$rootDir/tools/kotlin-js-library" as File -project(':kotlin-test-parent').projectDir = "$rootDir/kotlin.test" as File -project(':kotlin-test-parent:kotlin-test').projectDir = "$rootDir/kotlin.test/shared" as File -project(':kotlin-test-parent:kotlin-test-junit').projectDir = "$rootDir/kotlin.test/junit" as File -//project(':kotlin-stdlib-common').projectDir = "$rootDir/stdlib/common" as File +//project(':kotlin-js-library').projectDir = "$rootDir/tools/kotlin-js-library" as File +project(':kotlin-test').projectDir = "$rootDir/kotlin.test" as File +project(':kotlin-test:kotlin-test-common').projectDir = "$rootDir/kotlin.test/common" as File +project(':kotlin-test:kotlin-test-jvm').projectDir = "$rootDir/kotlin.test/jvm" as File +project(':kotlin-test:kotlin-test-junit').projectDir = "$rootDir/kotlin.test/junit" as File +//project(':kotlin-test:kotlin-test-js').projectDir = "$rootDir/kotlin.test/js" as File +project(':kotlin-stdlib-common').projectDir = "$rootDir/stdlib/common" as File project(':kotlin-stdlib').projectDir = "$rootDir/stdlib" as File project(':kotlin-stdlib-jre7').projectDir = "$rootDir/stdlib/jre7" as File project(':kotlin-stdlib-jre8').projectDir = "$rootDir/stdlib/jre8" as File -project(':kotlin-reflect').projectDir = "$rootDir/tools/kotlin-reflect" as File +//project(':kotlin-reflect').projectDir = "$rootDir/tools/kotlin-reflect" as File //project(':kotlin-compiler').projectDir = "$rootDir/tools/kotlin-compiler" as File //project(':kotlin-compiler-embeddable').projectDir = "$rootDir/tools/kotlin-compiler-embeddable" as File diff --git a/libraries/stdlib/build.gradle b/libraries/stdlib/build.gradle index 852b6940226..8952f201f01 100644 --- a/libraries/stdlib/build.gradle +++ b/libraries/stdlib/build.gradle @@ -18,15 +18,6 @@ sourceSets { srcDir 'src' } } - testLib { - kotlin { - srcDir '../kotlin.test/common/src/main/kotlin' - srcDir '../kotlin.test/jvm/src/main/kotlin' - srcDir '../kotlin.test/junit/src/main/kotlin' - - //resources '../kotlin.test/junit/src/main/resources' - } - } test { kotlin { srcDir 'test' @@ -37,14 +28,8 @@ sourceSets { dependencies { builtinsCompile group: 'org.jetbrains', name: 'annotations', version:'13.0' compile sourceSets.builtins.output -// compile project(':kotlin-runtime') -// testCompile project(':kotlin-test-parent:kotlin-test-junit') - - testLibCompile sourceSets.builtins.output - //testLibCompile sourceSets.main.output - testLibCompile('junit:junit:4.12') - testCompile configurations.testLibCompile - testCompile sourceSets.testLib.output + + testCompile project(':kotlin-test:kotlin-test-junit') } jar { @@ -71,9 +56,11 @@ artifacts { } compileBuiltinsKotlin { + compilerJarFile = bootstrapCompilerFile kotlinOptions { jdkHome = JDK_16 freeCompilerArgs = [ + "-version", "-Xallow-kotlin-package", "-Xdump-declarations-to", "${buildDir}/runtime-declarations.json", "-cp", "${rootDir}/../dist/builtins", @@ -85,6 +72,7 @@ compileKotlin { kotlinOptions { jdkHome = JDK_16 freeCompilerArgs = [ + "-version", "-Xallow-kotlin-package", "-Xmultifile-parts-inherit", "-Xdump-declarations-to", "${buildDir}/stdlib-declarations.json", @@ -92,10 +80,3 @@ compileKotlin { ] } } - -compileTestLibKotlin { - kotlinOptions { - jdkHome = JDK_16 - freeCompilerArgs = ["-Xallow-kotlin-package", "-Xmulti-platform"] - } -} diff --git a/libraries/stdlib/common/build.gradle b/libraries/stdlib/common/build.gradle index 408c4dc3982..b62bc8ff115 100644 --- a/libraries/stdlib/common/build.gradle +++ b/libraries/stdlib/common/build.gradle @@ -1,2 +1,68 @@ +description = 'Kotlin Common Standard Library' + +apply plugin: 'kotlin-platform-common' + +ext.commonSrcDir = "${buildDir}/common-sources" + +sourceSets { + main { + kotlin { + srcDir 'src' + srcDir commonSrcDir + } + } +} + +ant.properties.baseDir = projectDir +ant.properties.commonSrcDir = commonSrcDir +ant.properties.kotlinCompiler = bootstrapCompilerFile.path +ant.properties.compilerPreloader = compilerPreloaderFile.path + +ant.importBuild('tasks.xml') + +compileKotlinCommon.dependsOn commonSources + +/* +// TODO: currently unsupported +compileKotlinCommon { + kotlinOptions { + freeCompilerArgs = [ + "-module-name", "${project.name}".toString() + ] + } +} +*/ + +compileKotlinCommon.compilerJarFile = bootstrapCompilerFile + + + +jar { + baseName = project.name + 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/") } +} + + +// TODO: use dokka instead? +javadoc { + failOnError = false +} + +task sourcesJar(type: Jar, dependsOn:classes) { + classifier = 'sources' + from sourceSets.main.kotlin + +} + +task javadocJar(type: Jar, dependsOn:javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} -description = '' diff --git a/libraries/stdlib/common/tasks.xml b/libraries/stdlib/common/tasks.xml new file mode 100644 index 00000000000..d587c9e36ba --- /dev/null +++ b/libraries/stdlib/common/tasks.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libraries/stdlib/jre7/build.gradle b/libraries/stdlib/jre7/build.gradle index 4d9144f1bab..96ae7f8e641 100644 --- a/libraries/stdlib/jre7/build.gradle +++ b/libraries/stdlib/jre7/build.gradle @@ -1,8 +1,9 @@ description = 'Kotlin Standard Library JRE 7 extension' + dependencies { compile project(':kotlin-stdlib') - testCompile project(':kotlin-test-parent:kotlin-test-junit') + testCompile project(':kotlin-test:kotlin-test-junit') } sourceSets { @@ -42,3 +43,19 @@ compileTestKotlin { kotlinOptions.jdkHome = JDK_17 kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] } + +test { + executable = "$JDK_17/bin/java" +} + +task testJre6Tests(type: Test) { + dependsOn project(':kotlin-stdlib').tasks.testClasses + group = "verification" + + executable = "$JDK_17/bin/java" + + testClassesDir = project.file('../build/classes/test') + classpath = project.files('../build/classes/test') + sourceSets.test.compileClasspath +} + +check.dependsOn testJre6Tests \ No newline at end of file diff --git a/libraries/stdlib/jre8/build.gradle b/libraries/stdlib/jre8/build.gradle index a1185c46284..e7fcb3a5bf0 100644 --- a/libraries/stdlib/jre8/build.gradle +++ b/libraries/stdlib/jre8/build.gradle @@ -3,7 +3,7 @@ description = 'Kotlin Standard Library JRE 8 extension' dependencies { compile project(':kotlin-stdlib') compile project(':kotlin-stdlib-jre7') - testCompile project(':kotlin-test-parent:kotlin-test-junit') + testCompile project(':kotlin-test:kotlin-test-junit') } sourceSets { @@ -46,3 +46,20 @@ compileTestKotlin { kotlinOptions.jvmTarget = 1.8 kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] } + +test { + executable = "$JDK_18/bin/java" +} + + +task testJre6Tests(type: Test) { + dependsOn project(':kotlin-stdlib').tasks.testClasses + group = "verification" + + executable = "$JDK_18/bin/java" + + testClassesDir = project.file('../build/classes/test') + classpath = project.files('../build/classes/test') + sourceSets.test.compileClasspath +} + +check.dependsOn testJre6Tests \ No newline at end of file