@@ -93,7 +93,8 @@ class Th2BaseGradlePluginFunctionalTest {
93
93
}
94
94
95
95
val result =
96
- GradleRunner .create()
96
+ GradleRunner
97
+ .create()
97
98
.forwardOutput()
98
99
.withDebug(true )
99
100
.withConfiguredVersion()
@@ -105,8 +106,7 @@ class Th2BaseGradlePluginFunctionalTest {
105
106
// because no git repository exist in test
106
107
" -x" ,
107
108
" generateGitProperties" ,
108
- )
109
- .build()
109
+ ).build()
110
110
111
111
assertAll(
112
112
{ assertEquals(TaskOutcome .SUCCESS , result.task(" :compileKotlin" )?.outcome, " unexpected kotlin compile outcome" ) },
@@ -117,6 +117,79 @@ class Th2BaseGradlePluginFunctionalTest {
117
117
)
118
118
}
119
119
120
+ @Test
121
+ fun `the target jvm release version is 1 dot 8` () {
122
+ settingsFile.writeText(
123
+ """
124
+ rootProject.name = "test"
125
+ """ .trimIndent(),
126
+ )
127
+ buildFile.writeText(
128
+ """
129
+ plugins {
130
+ id('java-library')
131
+ id('org.jetbrains.kotlin.jvm') version '1.9.0'
132
+ id('com.exactpro.th2.gradle.base')
133
+ }
134
+
135
+ th2JavaRelease {
136
+ targetJavaVersion.set(JavaVersion.VERSION_1_8)
137
+ }
138
+
139
+ repositories {
140
+ mavenCentral()
141
+ }
142
+ """ .trimIndent(),
143
+ )
144
+ with (projectDir / " src" / " main" / " java" ) {
145
+ mkdirs()
146
+ resolve(" Hello.java" ).writeText(
147
+ """
148
+ class Hello {
149
+ public static void printHello() {
150
+ System.out.println("Hello World from Java!");
151
+ }
152
+ }
153
+ """ .trimIndent(),
154
+ )
155
+ }
156
+ with (projectDir / " src" / " main" / " kotlin" ) {
157
+ mkdirs()
158
+ resolve(" Main.kt" ).writeText(
159
+ """
160
+ fun main() {
161
+ println("Hello World from Kotlin!")
162
+ Hello.printHello()
163
+ }
164
+ """ .trimIndent(),
165
+ )
166
+ }
167
+
168
+ val result =
169
+ GradleRunner
170
+ .create()
171
+ .forwardOutput()
172
+ .withDebug(true )
173
+ .withConfiguredVersion()
174
+ .withPluginClasspath()
175
+ .withProjectDir(projectDir)
176
+ .withArguments(
177
+ " --stacktrace" ,
178
+ " build" ,
179
+ // because no git repository exist in test
180
+ " -x" ,
181
+ " generateGitProperties" ,
182
+ ).build()
183
+
184
+ assertAll(
185
+ { assertEquals(TaskOutcome .SUCCESS , result.task(" :compileKotlin" )?.outcome, " unexpected kotlin compile outcome" ) },
186
+ { assertEquals(TaskOutcome .SUCCESS , result.task(" :compileJava" )?.outcome, " unexpected java compile outcome" ) },
187
+ { assertEquals(TaskOutcome .SUCCESS , result.task(" :build" )?.outcome, " unexpected build outcome" ) },
188
+ { assertClassVersion(" java" , " Hello.class" , 52 ) },
189
+ { assertClassVersion(" kotlin" , " MainKt.class" , 52 ) },
190
+ )
191
+ }
192
+
120
193
@Test
121
194
fun `the default jvm release version is 11` () {
122
195
settingsFile.writeText(
@@ -162,7 +235,8 @@ class Th2BaseGradlePluginFunctionalTest {
162
235
}
163
236
164
237
val result =
165
- GradleRunner .create()
238
+ GradleRunner
239
+ .create()
166
240
.forwardOutput()
167
241
.withDebug(true )
168
242
.withConfiguredVersion()
@@ -174,8 +248,7 @@ class Th2BaseGradlePluginFunctionalTest {
174
248
// because no git repository exist in test
175
249
" -x" ,
176
250
" generateGitProperties" ,
177
- )
178
- .build()
251
+ ).build()
179
252
180
253
assertAll(
181
254
{ assertEquals(TaskOutcome .SUCCESS , result.task(" :compileKotlin" )?.outcome, " unexpected kotlin compile outcome" ) },
@@ -213,7 +286,8 @@ class Th2BaseGradlePluginFunctionalTest {
213
286
)
214
287
215
288
val result =
216
- GradleRunner .create()
289
+ GradleRunner
290
+ .create()
217
291
.forwardOutput()
218
292
.withDebug(true )
219
293
.withConfiguredVersion()
@@ -225,8 +299,7 @@ class Th2BaseGradlePluginFunctionalTest {
225
299
// because no git repository exist in test
226
300
" -x" ,
227
301
" generateGitProperties" ,
228
- )
229
- .build()
302
+ ).build()
230
303
val checkLicenses = result.task(" :checkLicense" )
231
304
assertNotNull(checkLicenses, " task checkLicense was not executed" ) {
232
305
assertEquals(TaskOutcome .SUCCESS , it.outcome, " unexpected task result" )
@@ -312,7 +385,8 @@ class Th2BaseGradlePluginFunctionalTest {
312
385
""" .trimIndent(),
313
386
)
314
387
val result =
315
- GradleRunner .create()
388
+ GradleRunner
389
+ .create()
316
390
.forwardOutput()
317
391
.withDebug(true )
318
392
.withConfiguredVersion()
@@ -324,8 +398,7 @@ class Th2BaseGradlePluginFunctionalTest {
324
398
// because no git repository exist in test
325
399
" -x" ,
326
400
" generateGitProperties" ,
327
- )
328
- .build()
401
+ ).build()
329
402
330
403
val checkLicenses = result.task(" :checkLicense" )
331
404
assertNotNull(checkLicenses, " task checkLicense was not executed" ) {
@@ -371,7 +444,8 @@ class Th2BaseGradlePluginFunctionalTest {
371
444
extraAssertion : (ArrayNode , String ) -> Unit = { _, _ -> },
372
445
) {
373
446
val module =
374
- elements().asSequence()
447
+ elements()
448
+ .asSequence()
375
449
.find { it.get(" moduleName" ).textValue() == moduleName }
376
450
assertNotNull(module, " module $moduleName not found" ) { m ->
377
451
val moduleInfo = assertIs<ObjectNode >(m, " module info must be an object" )
0 commit comments