Migrate repo to use JVM toolchains Gradle feature.
^KT-46972 Fixed
This commit is contained in:
@@ -1,84 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
ext.configureJavaOnlyJvm6Project = { Project project ->
|
||||
project.tasks.withType(JavaCompile) {
|
||||
sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
options.fork = true
|
||||
options.forkOptions.javaHome = file(JDK_16)
|
||||
}
|
||||
}
|
||||
|
||||
List<String> tasksWithWarnings = (List<String>) rootProject.ext.get("tasksWithWarnings")
|
||||
|
||||
ext.configureJvm6Project = { Project project ->
|
||||
project.configure(project) {
|
||||
configurations {
|
||||
sources
|
||||
}
|
||||
|
||||
project.ext.jvmTarget = "1.6"
|
||||
project.ext.javaHome = JDK_16
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.kotlin
|
||||
}
|
||||
|
||||
configureJavaOnlyJvm6Project(project)
|
||||
|
||||
tasks.withType(project.compileKotlin.class) {
|
||||
kotlinOptions.jdkHome = JDK_16
|
||||
kotlinOptions.jvmTarget = "1.6"
|
||||
}
|
||||
|
||||
test {
|
||||
executable = "$JDK_16/bin/java"
|
||||
}
|
||||
}
|
||||
|
||||
if (!BuildPropertiesExtKt.getDisableWerror(project.kotlinBuildProperties)) {
|
||||
project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile.class) { task ->
|
||||
if (!tasksWithWarnings.contains(task.path)) {
|
||||
task.kotlinOptions {
|
||||
allWarningsAsErrors = true
|
||||
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.configurations.java9CompileClasspath.extendsFrom(project.configurations.compileClasspath)
|
||||
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)
|
||||
def compileClasspath = project.configurations.java9CompileClasspath
|
||||
def objects = project.objects
|
||||
|
||||
doFirst {
|
||||
def moduleFiles = objects.fileCollection().from(*moduleOutputs)
|
||||
def modulePath = compileClasspath.filter { !(it in moduleFiles.files) }
|
||||
|
||||
options.compilerArgs = [
|
||||
'--module-path', modulePath.asPath,
|
||||
'--patch-module', "$moduleName=${moduleFiles.asPath}",
|
||||
'-Xlint:-requires-transitive-automatic' // suppress automatic module transitive dependencies in kotlin.test
|
||||
]
|
||||
|
||||
classpath = objects.fileCollection().from()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false ->
|
||||
project.configure(manifest) {
|
||||
attributes \
|
||||
|
||||
Reference in New Issue
Block a user