File tree Expand file tree Collapse file tree 3 files changed +74
-1
lines changed
src/main/kotlin/com/baeldung Expand file tree Collapse file tree 3 files changed +74
-1
lines changed Original file line number Diff line number Diff line change
1
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3
+
4
+ plugins {
5
+ kotlin(" jvm" ) version " 2.0.0"
6
+ }
7
+
8
+ group = " com.baeldung"
9
+ version = " 1.0-SNAPSHOT"
10
+
11
+
12
+ repositories {
13
+ mavenCentral()
14
+ }
15
+
16
+ dependencies {
17
+ testImplementation(" org.jetbrains.kotlin:kotlin-test" )
18
+ }
19
+
20
+ tasks.test {
21
+ useJUnitPlatform()
22
+ }
23
+
24
+ // compileKotlin, compileKotlinTest
25
+ kotlin {
26
+ compilerOptions {
27
+ jvmTarget.set(JvmTarget .JVM_11 )
28
+ }
29
+ }
30
+
31
+ tasks.compileJava {
32
+ options.release.set(11 )
33
+ }
34
+
35
+ // Reaching Test Source Only
36
+ tasks.compileTestJava {
37
+ options.release.set(11 )
38
+ }
39
+
40
+ tasks.compileTestKotlin {
41
+ compilerOptions {
42
+ jvmTarget.set(JvmTarget .JVM_11 )
43
+ }
44
+ }
45
+
46
+ // configureEach
47
+ tasks.withType<KotlinCompile >().configureEach {
48
+ compilerOptions {
49
+ jvmTarget.set(JvmTarget .JVM_11 )
50
+ }
51
+ }
52
+
53
+ tasks.withType(JavaCompile ::class ).configureEach {
54
+ options.release.set(11 )
55
+ }
56
+
57
+ // toolChain
58
+ kotlin {
59
+ jvmToolchain(11 )
60
+ }
Original file line number Diff line number Diff line change
1
+ package com.baeldung
2
+
3
+ class Main {
4
+ companion object {
5
+ @JvmStatic
6
+ fun main (args : Array <String >) {
7
+ println (" Just for test bytecode version!" )
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change 1
1
rootProject.name = " gradle-kotlin-dsl"
2
2
3
- include(" gradle-kotlin-dsl" , " custom-source-set" )
3
+ include(
4
+ " gradle-kotlin-dsl" ,
5
+ " custom-source-set" ,
6
+ " configure-bytecode" )
You can’t perform that action at this time.
0 commit comments