Use default compileJava9Java task to build java9 source set
This commit is contained in:
committed by
Alexander Udalov
parent
bd4abaa8bf
commit
299d6fa772
+6
-4
@@ -596,10 +596,12 @@ fun jdkPath(version: String): String = jdkPathIfFound(version)
|
|||||||
|
|
||||||
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
options.isFork = true
|
if (name != "compileJava9Java") {
|
||||||
options.forkOptions.javaHome = file(javaHome)
|
options.isFork = true
|
||||||
options.compilerArgs.add("-proc:none")
|
options.forkOptions.javaHome = file(javaHome)
|
||||||
options.encoding = "UTF-8"
|
options.compilerArgs.add("-proc:none")
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
|
|||||||
@@ -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 ->
|
ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false ->
|
||||||
project.configure(manifest) {
|
project.configure(manifest) {
|
||||||
attributes \
|
attributes \
|
||||||
@@ -202,33 +226,3 @@ 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"]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -21,11 +21,9 @@ dependencies {
|
|||||||
|
|
||||||
archivesBaseName = 'kotlin-test'
|
archivesBaseName = 'kotlin-test'
|
||||||
|
|
||||||
createCompileJava9Task(project, "compileJava9", "kotlin.test")
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Test', true)
|
manifestAttributes(manifest, project, 'Test', true)
|
||||||
from compileJava9.outputs
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
@@ -45,3 +43,5 @@ compileKotlin {
|
|||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileJava9Sources(project, 'kotlin.test')
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ dependencies {
|
|||||||
compileOnly project(':core:util.runtime')
|
compileOnly project(':core:util.runtime')
|
||||||
}
|
}
|
||||||
|
|
||||||
createCompileJava9Task(project, "compileJava9", "kotlin.reflect", [configurations.compileOnly])
|
compileJava9Sources(project, 'kotlin.reflect', [sourceSets.main.output, configurations.compileOnly])
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
@@ -39,7 +39,6 @@ jar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task java9Jar(type: Jar) {
|
task java9Jar(type: Jar) {
|
||||||
dependsOn(compileJava9)
|
|
||||||
classifier = "java9"
|
classifier = "java9"
|
||||||
from sourceSets.java9.output
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ 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
|
||||||
@@ -73,7 +71,7 @@ jar {
|
|||||||
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
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|
||||||
task distJar(type: Jar) {
|
task distJar(type: Jar) {
|
||||||
@@ -85,7 +83,7 @@ task distJar(type: Jar) {
|
|||||||
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
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|
||||||
task builtinsJar(type: Jar) {
|
task builtinsJar(type: Jar) {
|
||||||
@@ -168,4 +166,6 @@ compileExperimentalKotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileJava9Sources(project, 'kotlin.stdlib', [sourceSets.builtins.output, sourceSets.main.output])
|
||||||
|
|
||||||
kotlin.experimental.coroutines 'enable'
|
kotlin.experimental.coroutines 'enable'
|
||||||
|
|||||||
@@ -28,16 +28,14 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
java9 {
|
java9 {
|
||||||
java {
|
java {
|
||||||
srcDirs = ['java9']
|
srcDir 'java9'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk7")
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Main', true)
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
from compileJava9.outputs
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
@@ -68,6 +66,8 @@ compileTestKotlin {
|
|||||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileJava9Sources(project, 'kotlin.stdlib.jdk7')
|
||||||
|
|
||||||
kotlin.experimental.coroutines 'enable'
|
kotlin.experimental.coroutines 'enable'
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
@@ -31,16 +31,14 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
java9 {
|
java9 {
|
||||||
java {
|
java {
|
||||||
srcDirs = ['java9']
|
srcDir 'java9'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createCompileJava9Task(project, "compileJava9", "kotlin.stdlib.jdk8")
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifestAttributes(manifest, project, 'Main', true)
|
manifestAttributes(manifest, project, 'Main', true)
|
||||||
from compileJava9.outputs
|
from sourceSets.java9.output
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
@@ -71,6 +69,8 @@ compileTestKotlin {
|
|||||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileJava9Sources(project, 'kotlin.stdlib.jdk8')
|
||||||
|
|
||||||
kotlin.experimental.coroutines 'enable'
|
kotlin.experimental.coroutines 'enable'
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
Reference in New Issue
Block a user