Set proper jvmTarget for projects
This commit is contained in:
+36
-1
@@ -1,4 +1,6 @@
|
|||||||
|
import org.gradle.api.Project
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.io.File
|
||||||
import org.gradle.api.tasks.bundling.Jar
|
import org.gradle.api.tasks.bundling.Jar
|
||||||
import org.gradle.kotlin.dsl.java
|
import org.gradle.kotlin.dsl.java
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
@@ -165,8 +167,14 @@ fun Project.allprojectsRecursive(body: Project.() -> Unit) {
|
|||||||
this.subprojects { allprojectsRecursive(body) }
|
this.subprojects { allprojectsRecursive(body) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val defaultJvmTarget = "1.8"
|
||||||
|
val defaultJavaHome = jdkPath(defaultJvmTarget!!)
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
|
jvmTarget = defaultJvmTarget
|
||||||
|
javaHome = defaultJavaHome
|
||||||
|
|
||||||
buildDir = File(commonBuildDir, project.name)
|
buildDir = File(commonBuildDir, project.name)
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -176,10 +184,11 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
configureJvmProject(javaHome!!, jvmTarget!!)
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name)
|
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name)
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
// kotlinOptions.jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Kotlin2JsCompile> {
|
tasks.withType<Kotlin2JsCompile> {
|
||||||
@@ -197,6 +206,13 @@ allprojects {
|
|||||||
tasks.withType<Jar> {
|
tasks.withType<Jar> {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
logger.info("configuring project $name to compile to the target jvm version $jvmTarget using jdk: $javaHome")
|
||||||
|
if (javaHome != defaultJavaHome || jvmTarget != defaultJvmTarget) {
|
||||||
|
configureJvmProject(javaHome!!, jvmTarget!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task<Copy>("dist") {
|
task<Copy>("dist") {
|
||||||
@@ -288,3 +304,22 @@ fun jdkPath(version: String): String {
|
|||||||
val varName = "JDK_${version.replace(".", "")}"
|
val varName = "JDK_${version.replace(".", "")}"
|
||||||
return System.getenv(varName) ?: throw GradleException ("Please set environment variable $varName to point to JDK $version installation")
|
return System.getenv(varName) ?: throw GradleException ("Please set environment variable $varName to point to JDK $version installation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
options.forkOptions.javaHome = file(javaHome)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jdkHome = javaHome
|
||||||
|
kotlinOptions.jvmTarget = javaVersion
|
||||||
|
doFirst {
|
||||||
|
System.setProperty("kotlin.colors.enabled", "false")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
executable = File(javaHome, "bin/java").canonicalPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,7 +65,13 @@ fun Project.getResourceFiles(): SourceDirectorySet? = withJavaPlugin {
|
|||||||
the<JavaPluginConvention>().sourceSets.getByName("main").resources
|
the<JavaPluginConvention>().sourceSets.getByName("main").resources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun File(root: File, vararg children: String): File = children.fold(root, { f, c -> File(f, c) })
|
fun File(root: File, vararg children: String): File = children.fold(root, { f, c -> File(f, c) })
|
||||||
fun File(root: String, vararg children: String): File = children.fold(File(root), { f, c -> File(f, c) })
|
fun File(root: String, vararg children: String): File = children.fold(File(root), { f, c -> File(f, c) })
|
||||||
|
|
||||||
|
var Project.jvmTarget: String?
|
||||||
|
get() = extra.takeIf { it.has("jvmTarget") }?.get("jvmTarget") as? String
|
||||||
|
set(v) { extra["jvmTarget"] = v }
|
||||||
|
|
||||||
|
var Project.javaHome: String?
|
||||||
|
get() = extra.takeIf { it.has("javaHome") }?.get("javaHome") as? String
|
||||||
|
set(v) { extra["javaHome"] = v }
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:cli"))
|
compile(project(":compiler:cli"))
|
||||||
@@ -21,7 +23,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { java.srcDirs() }
|
"main" { projectDefault() }
|
||||||
"test" { projectDefault() }
|
"test" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:backend-common"))
|
compile(project(":compiler:backend-common"))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import java.io.File
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
val compilerModules: Array<String> by rootProject.extra
|
val compilerModules: Array<String> by rootProject.extra
|
||||||
val otherCompilerModules = compilerModules.filter { it != path }
|
val otherCompilerModules = compilerModules.filter { it != path }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:cli-common"))
|
compile(project(":compiler:cli-common"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core:util.runtime"))
|
compile(project(":core:util.runtime"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ description = "Kotlin Runner"
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
compile(project(":kotlin-stdlib"))
|
compile(project(":kotlin-stdlib"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":kotlin-build-common"))
|
compile(project(":kotlin-build-common"))
|
||||||
compile(project(":compiler:cli-common"))
|
compile(project(":compiler:cli-common"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core:util.runtime"))
|
compile(project(":core:util.runtime"))
|
||||||
compile(commonDep("javax.inject"))
|
compile(commonDep("javax.inject"))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ description = "Kotlin Daemon Client"
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
val nativePlatformUberjar = preloadedDeps("native-platform-uberjar")
|
val nativePlatformUberjar = preloadedDeps("native-platform-uberjar")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":compiler:backend"))
|
compile(project(":compiler:backend"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(ideaSdkCoreDeps("intellij-core"))
|
compile(ideaSdkCoreDeps("intellij-core"))
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ description = "Kotlin Preloader"
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
compile(ideaSdkDeps("asm-all"))
|
compile(ideaSdkDeps("asm-all"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":core"))
|
compile(project(":core"))
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
compile(project(":core:builtins"))
|
compile(project(":core:builtins"))
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import java.io.File
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
val builtinsSrc = File(rootDir, "core", "builtins", "src")
|
val builtinsSrc = File(rootDir, "core", "builtins", "src")
|
||||||
val builtinsNative = File(rootDir, "core", "builtins", "native")
|
val builtinsNative = File(rootDir, "core", "builtins", "native")
|
||||||
// TODO: rewrite dependent projects on using build results instead of the fixed location
|
// TODO: rewrite dependent projects on using build results instead of the fixed location
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ apply {
|
|||||||
plugin("com.github.johnrengelman.shadow")
|
plugin("com.github.johnrengelman.shadow")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
compile(project(":core:builtins"))
|
compile(project(":core:builtins"))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import org.gradle.jvm.tasks.Jar
|
|||||||
|
|
||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
compile(project(":core:builtins"))
|
compile(project(":core:builtins"))
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ apply {
|
|||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jvmTarget = "1.6"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":core:builtins"))
|
compile(project(":core:builtins"))
|
||||||
compile(project(":kotlin-stdlib"))
|
compile(project(":kotlin-stdlib"))
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ ext.configureJvmProject = { Project project ->
|
|||||||
|
|
||||||
ext.configureJvm6Project = { Project project ->
|
ext.configureJvm6Project = { Project project ->
|
||||||
project.configure(project) {
|
project.configure(project) {
|
||||||
|
project.ext.jvmTarget = "1.6"
|
||||||
|
project.ext.javaHome = JDK_16
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
classifier = 'sources'
|
classifier = 'sources'
|
||||||
from sourceSets.main.kotlin
|
from sourceSets.main.kotlin
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ apply plugin: 'kotlin'
|
|||||||
|
|
||||||
configureJvm6Project(project)
|
configureJvm6Project(project)
|
||||||
configurePublishing(project)
|
configurePublishing(project)
|
||||||
|
ext.javaHome = JDK_17
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':kotlin-stdlib')
|
compile project(':kotlin-stdlib')
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ apply plugin: 'kotlin'
|
|||||||
|
|
||||||
configureJvm6Project(project)
|
configureJvm6Project(project)
|
||||||
configurePublishing(project)
|
configurePublishing(project)
|
||||||
|
ext.javaHome = JDK_18
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':kotlin-stdlib')
|
compile project(':kotlin-stdlib')
|
||||||
|
|||||||
Reference in New Issue
Block a user