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:
Alexander Udalov
2017-08-29 11:02:45 +03:00
parent 650e97f200
commit 2d41c7d462
15 changed files with 140 additions and 19 deletions
+35 -1
View File
@@ -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<? 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"]
}