diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt index a0728fccdc5..d372c008b7d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt @@ -32,11 +32,10 @@ class TestStdlibWithDxTest { } private fun doTest(file: File) { - val zip = ZipInputStream(FileInputStream(file)) - zip.use { - generateSequence { zip.nextEntry }.forEach { - if (it.name.endsWith(".class")) { - DxChecker.checkFileWithDx(zip.readBytes(), it.name) + ZipInputStream(FileInputStream(file)).use { zip -> + for (entry in generateSequence { zip.nextEntry }) { + if (entry.name.endsWith(".class") && !entry.name.startsWith("META-INF/")) { + DxChecker.checkFileWithDx(zip.readBytes(), entry.name) } } } diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index 453f243572e..ea6fcef10ac 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -52,7 +52,7 @@ ext.configureJvm6Project = { Project project -> } } -ext.manifestAttributes = { Manifest manifest, Project project, String component = null -> +ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false -> project.configure(manifest) { attributes \ 'Implementation-Vendor': 'JetBrains', @@ -65,6 +65,10 @@ ext.manifestAttributes = { Manifest manifest, Project project, String component 'Kotlin-Runtime-Component': component, 'Kotlin-Version': project.kotlinLanguageVersion } + if (multiRelease) { + attributes \ + 'Multi-Release': 'true' + } } } @@ -198,3 +202,33 @@ ext.createPreprocessorTask = { Project project, def name, def sourceDir, def tar args = [sourceDir, targetDir, profile] } } + +ext.createCompileJava9Task = { Project project, String name, String moduleName, List extraModuleContent = [] -> + project.tasks.findByName("compileJava9Java").enabled = false + + def task = project.tasks.create(name, Exec) + + def sourceSet = project.sourceSets.java9.java + task.inputs.dir(sourceSet.srcDirs.first()) + task.outputs.dir(sourceSet.outputDir) + + task.dependsOn(project.tasks.findByName("compileKotlin"), project.tasks.findByName("compileJava")) + + def moduleContent = project.sourceSets.main.output.join(File.pathSeparator) + for (collection in extraModuleContent) { + moduleContent += File.pathSeparator + collection.asPath + } + + def output = new File(sourceSet.outputDir, "META-INF/versions/9") + + task.doFirst { + output.delete() + output.mkdirs() + } + + task.commandLine = ["${JDK_9}/bin/javac", + *fileTree(sourceSet.srcDirs.first()).files.toArray(), + "-d", output.path, + "-p", project.configurations.compile.asPath, + "--patch-module", "$moduleName=$moduleContent"] +} diff --git a/libraries/kotlin.test/jvm/build.gradle b/libraries/kotlin.test/jvm/build.gradle index dee52b35e16..0f80da5e5e0 100644 --- a/libraries/kotlin.test/jvm/build.gradle +++ b/libraries/kotlin.test/jvm/build.gradle @@ -1,4 +1,3 @@ - description = 'Kotlin Test' apply plugin: 'kotlin-platform-jvm' @@ -9,6 +8,10 @@ configurePublishing(project) project.ext["jpsLibraryPath"] = rootProject.distLibDir +sourceSets { + java9 +} + dependencies { expectedBy project(':kotlin-test:kotlin-test-common') compile project(':kotlin-stdlib') @@ -18,8 +21,11 @@ dependencies { archivesBaseName = 'kotlin-test' +createCompileJava9Task(project, "compileJava9", "kotlin.test") + jar { - manifestAttributes(manifest, project, 'Test') + manifestAttributes(manifest, project, 'Test', true) + from compileJava9.outputs } artifacts { diff --git a/libraries/kotlin.test/jvm/src/java9/java/module-info.java b/libraries/kotlin.test/jvm/src/java9/java/module-info.java new file mode 100644 index 00000000000..c0ce606a76e --- /dev/null +++ b/libraries/kotlin.test/jvm/src/java9/java/module-info.java @@ -0,0 +1,7 @@ +module kotlin.test { + requires transitive kotlin.stdlib; + + exports kotlin.test; + + uses kotlin.test.AsserterContributor; +} diff --git a/libraries/stdlib/build.gradle b/libraries/stdlib/build.gradle index 8e3824cfa55..6ac7bbf8c13 100644 --- a/libraries/stdlib/build.gradle +++ b/libraries/stdlib/build.gradle @@ -41,6 +41,11 @@ sourceSets { srcDir 'test' } } + java9 { + java { + srcDir 'jvm/java9' + } + } } dependencies { @@ -56,27 +61,31 @@ configurations { builtins } +createCompileJava9Task(project, "compileJava9", "kotlin.stdlib", [sourceSets.builtins.output/* TODO: sourceSets.annotations.output?*/]) + task originalStdlibJar(type: Jar) { baseName = 'original-kotlin-stdlib' from sourceSets.main.output } jar { - manifestAttributes(manifest, project, 'Main') + manifestAttributes(manifest, project, 'Main', true) from("${rootDir}/dist/builtins") from sourceSets.builtins.output from sourceSets.experimental.output + from compileJava9.outputs } task distJar(type: Jar) { baseName = 'dist-kotlin-stdlib' version = null - manifestAttributes(manifest, project, 'Main') + manifestAttributes(manifest, project, 'Main', true) from("${rootDir}/dist/builtins") from sourceSets.annotations.output from sourceSets.builtins.output from sourceSets.main.output from sourceSets.experimental.output + from compileJava9.outputs } task builtinsJar(type: Jar) { diff --git a/libraries/stdlib/jdk7/build.gradle b/libraries/stdlib/jdk7/build.gradle index 875386e6f8c..7b5f7e7f8dd 100644 --- a/libraries/stdlib/jdk7/build.gradle +++ b/libraries/stdlib/jdk7/build.gradle @@ -26,10 +26,18 @@ sourceSets { } } } + java9 { + java { + srcDirs = ['java9'] + } + } } +createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk7") + jar { - manifestAttributes(manifest, project, 'Main') + manifestAttributes(manifest, project, 'Main', true) + from compileJava9.outputs } artifacts { diff --git a/libraries/stdlib/jdk7/java9/module-info.java b/libraries/stdlib/jdk7/java9/module-info.java new file mode 100644 index 00000000000..b45c36549c1 --- /dev/null +++ b/libraries/stdlib/jdk7/java9/module-info.java @@ -0,0 +1,5 @@ +module kotlin.stdlib.jdk7 { + requires transitive kotlin.stdlib; + + exports kotlin.jdk7; +} diff --git a/libraries/stdlib/jdk8/build.gradle b/libraries/stdlib/jdk8/build.gradle index 632099e17c2..95dd9a630f7 100644 --- a/libraries/stdlib/jdk8/build.gradle +++ b/libraries/stdlib/jdk8/build.gradle @@ -29,10 +29,18 @@ sourceSets { } } } + java9 { + java { + srcDirs = ['java9'] + } + } } +createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk8") + jar { - manifestAttributes(manifest, project, 'Main') + manifestAttributes(manifest, project, 'Main', true) + from compileJava9.outputs } artifacts { diff --git a/libraries/stdlib/jdk8/java9/module-info.java b/libraries/stdlib/jdk8/java9/module-info.java new file mode 100644 index 00000000000..6aea62c686f --- /dev/null +++ b/libraries/stdlib/jdk8/java9/module-info.java @@ -0,0 +1,7 @@ +module kotlin.stdlib.jdk8 { + requires transitive kotlin.stdlib; + + exports kotlin.collections.jdk8; + exports kotlin.streams.jdk8; + exports kotlin.text.jdk8; +} diff --git a/libraries/stdlib/jvm/java9/module-info.java b/libraries/stdlib/jvm/java9/module-info.java new file mode 100644 index 00000000000..b816c55b57c --- /dev/null +++ b/libraries/stdlib/jvm/java9/module-info.java @@ -0,0 +1,37 @@ +module kotlin.stdlib { + exports kotlin; + exports kotlin.annotation; + exports kotlin.collections; + exports kotlin.comparisons; + exports kotlin.concurrent; + exports kotlin.io; + exports kotlin.jvm; + exports kotlin.jvm.functions; + exports kotlin.math; + exports kotlin.properties; + exports kotlin.ranges; + exports kotlin.reflect; + exports kotlin.sequences; + exports kotlin.system; + exports kotlin.text; + + exports kotlin.coroutines.experimental; + exports kotlin.coroutines.experimental.intrinsics; + exports kotlin.coroutines.experimental.jvm.internal; + exports kotlin.experimental; + + exports kotlin.internal; + exports kotlin.jvm.internal; + exports kotlin.jvm.internal.markers; + + // TODO? + // exports org.jetbrains.annotations; + + // Open packages with .kotlin_builtins files to kotlin-reflect, to allow reflection to load built-in declarations there + opens kotlin to kotlin.reflect; + opens kotlin.annotation to kotlin.reflect; + opens kotlin.collections to kotlin.reflect; + opens kotlin.internal to kotlin.reflect; + opens kotlin.ranges to kotlin.reflect; + opens kotlin.reflect to kotlin.reflect; +} diff --git a/libraries/tools/binary-compatibility-validator/build.gradle b/libraries/tools/binary-compatibility-validator/build.gradle index 7b428b75a2e..19aa1957475 100644 --- a/libraries/tools/binary-compatibility-validator/build.gradle +++ b/libraries/tools/binary-compatibility-validator/build.gradle @@ -6,7 +6,7 @@ configurations { dependencies { compile project(':kotlin-stdlib') - compile 'org.ow2.asm:asm-debug-all:5.0.4' + compile 'org.ow2.asm:asm-debug-all:6.0_BETA' compile 'com.google.code.gson:gson:2.6.2' testCompile project(':kotlin-test:kotlin-test-junit') @@ -48,4 +48,4 @@ test { jvmArgs '-ea' ignoreFailures = System.getenv("kotlin_build_ignore_test_failures") == 'yes' -} \ No newline at end of file +} diff --git a/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/PublicApiDump.kt b/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/PublicApiDump.kt index e84b02fde10..90de594b357 100644 --- a/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/PublicApiDump.kt +++ b/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/PublicApiDump.kt @@ -15,8 +15,9 @@ fun main(args: Array) { } -fun JarFile.classEntries() = entries().asSequence().filter { !it.isDirectory && it.name.endsWith(".class") } - +fun JarFile.classEntries() = entries().asSequence().filter { + !it.isDirectory && it.name.endsWith(".class") && !it.name.startsWith("META-INF/") +} fun getBinaryAPI(jar: JarFile, visibilityMap: Map): List = getBinaryAPI(jar.classEntries().map { entry -> jar.getInputStream(entry) }, visibilityMap) diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml index ebf603765ce..4a357fdf531 100644 --- a/libraries/tools/kotlin-maven-plugin/pom.xml +++ b/libraries/tools/kotlin-maven-plugin/pom.xml @@ -76,7 +76,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.4 + 3.5.1 diff --git a/libraries/tools/kotlin-osgi-bundle/pom.xml b/libraries/tools/kotlin-osgi-bundle/pom.xml index bdcd321acae..fa6f7d29a1a 100644 --- a/libraries/tools/kotlin-osgi-bundle/pom.xml +++ b/libraries/tools/kotlin-osgi-bundle/pom.xml @@ -51,7 +51,7 @@ org.apache.felix maven-bundle-plugin - 2.5.4 + 3.5.0 true diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 81ec06b1e77..2620c96d666 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -106,7 +106,7 @@ val proguard by task { System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath) } - libraryjars(proguardLibraryJars) + libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars) printconfiguration("$buildDir/compiler.pro.dump") }