Add module-info.java for standard Kotlin libraries
Using the new multi-release jar feature, store compiled module-info.class files into META-INF/versions/9 instead of the artifact root. Hopefully, this will break fewer tools which do not support module-info.class files because any sane tool should not do anything with files in META-INF because before Java 9 that directory only contained resources. Upgrade some Maven plugins to newer versions which do not fail on module-info.class files #KT-21266 In Progress
This commit is contained in:
@@ -32,11 +32,10 @@ class TestStdlibWithDxTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun doTest(file: File) {
|
private fun doTest(file: File) {
|
||||||
val zip = ZipInputStream(FileInputStream(file))
|
ZipInputStream(FileInputStream(file)).use { zip ->
|
||||||
zip.use {
|
for (entry in generateSequence { zip.nextEntry }) {
|
||||||
generateSequence { zip.nextEntry }.forEach {
|
if (entry.name.endsWith(".class") && !entry.name.startsWith("META-INF/")) {
|
||||||
if (it.name.endsWith(".class")) {
|
DxChecker.checkFileWithDx(zip.readBytes(), entry.name)
|
||||||
DxChecker.checkFileWithDx(zip.readBytes(), it.name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
project.configure(manifest) {
|
||||||
attributes \
|
attributes \
|
||||||
'Implementation-Vendor': 'JetBrains',
|
'Implementation-Vendor': 'JetBrains',
|
||||||
@@ -65,6 +65,10 @@ ext.manifestAttributes = { Manifest manifest, Project project, String component
|
|||||||
'Kotlin-Runtime-Component': component,
|
'Kotlin-Runtime-Component': component,
|
||||||
'Kotlin-Version': project.kotlinLanguageVersion
|
'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]
|
args = [sourceDir, targetDir, profile]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext.createCompileJava9Task = { Project project, String name, String moduleName, List<? extends FileCollection> 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"]
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
description = 'Kotlin Test'
|
description = 'Kotlin Test'
|
||||||
|
|
||||||
apply plugin: 'kotlin-platform-jvm'
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
@@ -9,6 +8,10 @@ configurePublishing(project)
|
|||||||
|
|
||||||
project.ext["jpsLibraryPath"] = rootProject.distLibDir
|
project.ext["jpsLibraryPath"] = rootProject.distLibDir
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
java9
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
expectedBy project(':kotlin-test:kotlin-test-common')
|
expectedBy project(':kotlin-test:kotlin-test-common')
|
||||||
compile project(':kotlin-stdlib')
|
compile project(':kotlin-stdlib')
|
||||||
@@ -18,8 +21,11 @@ dependencies {
|
|||||||
|
|
||||||
archivesBaseName = 'kotlin-test'
|
archivesBaseName = 'kotlin-test'
|
||||||
|
|
||||||
|
createCompileJava9Task(project, "compileJava9", "kotlin.test")
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Test')
|
manifestAttributes(manifest, project, 'Test', true)
|
||||||
|
from compileJava9.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
module kotlin.test {
|
||||||
|
requires transitive kotlin.stdlib;
|
||||||
|
|
||||||
|
exports kotlin.test;
|
||||||
|
|
||||||
|
uses kotlin.test.AsserterContributor;
|
||||||
|
}
|
||||||
@@ -41,6 +41,11 @@ sourceSets {
|
|||||||
srcDir 'test'
|
srcDir 'test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
java9 {
|
||||||
|
java {
|
||||||
|
srcDir 'jvm/java9'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -56,27 +61,31 @@ configurations {
|
|||||||
builtins
|
builtins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createCompileJava9Task(project, "compileJava9", "kotlin.stdlib", [sourceSets.builtins.output/* TODO: sourceSets.annotations.output?*/])
|
||||||
|
|
||||||
task originalStdlibJar(type: Jar) {
|
task originalStdlibJar(type: Jar) {
|
||||||
baseName = 'original-kotlin-stdlib'
|
baseName = 'original-kotlin-stdlib'
|
||||||
from sourceSets.main.output
|
from sourceSets.main.output
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Main')
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
from("${rootDir}/dist/builtins")
|
from("${rootDir}/dist/builtins")
|
||||||
from sourceSets.builtins.output
|
from sourceSets.builtins.output
|
||||||
from sourceSets.experimental.output
|
from sourceSets.experimental.output
|
||||||
|
from compileJava9.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
task distJar(type: Jar) {
|
task distJar(type: Jar) {
|
||||||
baseName = 'dist-kotlin-stdlib'
|
baseName = 'dist-kotlin-stdlib'
|
||||||
version = null
|
version = null
|
||||||
manifestAttributes(manifest, project, 'Main')
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
from("${rootDir}/dist/builtins")
|
from("${rootDir}/dist/builtins")
|
||||||
from sourceSets.annotations.output
|
from sourceSets.annotations.output
|
||||||
from sourceSets.builtins.output
|
from sourceSets.builtins.output
|
||||||
from sourceSets.main.output
|
from sourceSets.main.output
|
||||||
from sourceSets.experimental.output
|
from sourceSets.experimental.output
|
||||||
|
from compileJava9.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
task builtinsJar(type: Jar) {
|
task builtinsJar(type: Jar) {
|
||||||
|
|||||||
@@ -26,10 +26,18 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
java9 {
|
||||||
|
java {
|
||||||
|
srcDirs = ['java9']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk7")
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Main')
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
|
from compileJava9.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
module kotlin.stdlib.jdk7 {
|
||||||
|
requires transitive kotlin.stdlib;
|
||||||
|
|
||||||
|
exports kotlin.jdk7;
|
||||||
|
}
|
||||||
@@ -29,10 +29,18 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
java9 {
|
||||||
|
java {
|
||||||
|
srcDirs = ['java9']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk8")
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Main')
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
|
from compileJava9.outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
module kotlin.stdlib.jdk8 {
|
||||||
|
requires transitive kotlin.stdlib;
|
||||||
|
|
||||||
|
exports kotlin.collections.jdk8;
|
||||||
|
exports kotlin.streams.jdk8;
|
||||||
|
exports kotlin.text.jdk8;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':kotlin-stdlib')
|
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'
|
compile 'com.google.code.gson:gson:2.6.2'
|
||||||
testCompile project(':kotlin-test:kotlin-test-junit')
|
testCompile project(':kotlin-test:kotlin-test-junit')
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -15,8 +15,9 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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<String, ClassVisibility>): List<ClassBinarySignature> =
|
fun getBinaryAPI(jar: JarFile, visibilityMap: Map<String, ClassVisibility>): List<ClassBinarySignature> =
|
||||||
getBinaryAPI(jar.classEntries().map { entry -> jar.getInputStream(entry) }, visibilityMap)
|
getBinaryAPI(jar.classEntries().map { entry -> jar.getInputStream(entry) }, visibilityMap)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-plugin-plugin</artifactId>
|
<artifactId>maven-plugin-plugin</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.5.1</version>
|
||||||
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.apache.felix</groupId>
|
||||||
<artifactId>maven-bundle-plugin</artifactId>
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
<version>2.5.4</version>
|
<version>3.5.0</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ val proguard by task<ProGuardTask> {
|
|||||||
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryjars(proguardLibraryJars)
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
||||||
printconfiguration("$buildDir/compiler.pro.dump")
|
printconfiguration("$buildDir/compiler.pro.dump")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user