Use default compileJava9Java task to build java9 source set
This commit is contained in:
committed by
Alexander Udalov
parent
bd4abaa8bf
commit
299d6fa772
@@ -52,6 +52,30 @@ ext.configureJvm6Project = { Project project ->
|
||||
}
|
||||
}
|
||||
|
||||
ext.compileJava9Sources = { Project project, String moduleName, Collection<FileCollection> moduleOutputs = [project.sourceSets.main.output] ->
|
||||
// module-info.java should be in java9 source set by convention
|
||||
SourceDirectorySet java9SourceSet = project.sourceSets.java9.java
|
||||
project.tasks.getByName("compileJava9Java").configure { JavaCompile it ->
|
||||
dependsOn(moduleOutputs)
|
||||
it.sourceCompatibility = 1.9
|
||||
it.targetCompatibility = 1.9
|
||||
it.destinationDir = file("${java9SourceSet.outputDir}/META-INF/versions/9")
|
||||
it.options.fork = true
|
||||
it.options.forkOptions.javaHome = file(JDK_9)
|
||||
it.options.sourcepath = files(java9SourceSet.srcDirs)
|
||||
|
||||
doFirst {
|
||||
def moduleFiles = moduleOutputs.collect { it.files }.flatten().join(File.pathSeparator)
|
||||
|
||||
options.compilerArgs = [
|
||||
'--module-path', project.configurations.compileClasspath.asPath,
|
||||
'--patch-module', "$moduleName=$moduleFiles"
|
||||
]
|
||||
classpath = files()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false ->
|
||||
project.configure(manifest) {
|
||||
attributes \
|
||||
@@ -202,33 +226,3 @@ 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"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user