forked from Baeldung/kotlin-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTLN-246 - Configure Kotlin's bytecode version with Gradle (Baeldung#…
…1107) * add module * add class * build test * downgrade to java 11 * split project * split, to avoid redundance * groovy to kts * skip * update kts * remove unused plugin * try remove toolchain * remove unused test * merge module * clean * targetCompatibility to release
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") version "2.0.0" | ||
} | ||
|
||
group = "com.baeldung" | ||
version = "1.0-SNAPSHOT" | ||
|
||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.jetbrains.kotlin:kotlin-test") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
// compileKotlin, compileKotlinTest | ||
kotlin { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
} | ||
|
||
tasks.compileJava { | ||
options.release.set(11) | ||
} | ||
|
||
// Reaching Test Source Only | ||
tasks.compileTestJava { | ||
options.release.set(11) | ||
} | ||
|
||
tasks.compileTestKotlin { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
} | ||
|
||
// configureEach | ||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
} | ||
|
||
tasks.withType(JavaCompile::class).configureEach { | ||
options.release.set(11) | ||
} | ||
|
||
// toolChain | ||
kotlin { | ||
jvmToolchain(11) | ||
} |
10 changes: 10 additions & 0 deletions
10
gradle-kotlin-dsl/configure-bytecode/src/main/kotlin/com/baeldung/Main.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.baeldung | ||
|
||
class Main { | ||
companion object { | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
println("Just for test bytecode version!") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
rootProject.name = "gradle-kotlin-dsl" | ||
|
||
include("gradle-kotlin-dsl", "custom-source-set") | ||
include( | ||
"gradle-kotlin-dsl", | ||
"custom-source-set", | ||
"configure-bytecode") |