@@ -6,6 +6,8 @@ import org.gradle.testing.jacoco.plugins.JacocoPlugin
6
6
import org.gradle.testing.jacoco.tasks.JacocoReport
7
7
import org.junit.Test
8
8
9
+ import java.nio.file.Paths
10
+
9
11
import static com.vanniktech.android.junit.jacoco.ProjectHelper.ProjectType.*
10
12
11
13
class GenerationTest {
@@ -269,15 +271,22 @@ class GenerationTest {
269
271
}
270
272
271
273
assert reports. xml. enabled
272
- assert reports. xml. destination. toString () == project. buildDir. absolutePath + " /reports/jacoco/${ flavor}${ buildType.capitalize()} /jacoco.xml"
274
+ assert reports. xml. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/${ flavor}${ buildType.capitalize()} /jacoco.xml" )
273
275
assert reports. csv. enabled
274
- assert reports. csv. destination. toString () == project. buildDir. absolutePath + " /reports/jacoco/${ flavor}${ buildType.capitalize()} /jacoco.csv"
276
+ assert reports. csv. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/${ flavor}${ buildType.capitalize()} /jacoco.csv" )
275
277
assert reports. html. enabled
276
- assert reports. html. destination. toString () == project. buildDir. absolutePath + " /reports/jacoco/${ flavor}${ buildType.capitalize()} "
278
+ assert reports. html. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/${ flavor}${ buildType.capitalize()} " )
277
279
278
280
assert classDirectories. dir == project. file(" build/" )
279
281
assert contentEquals(classDirectories. includes, [" **/intermediates/classes/${ flavor} /${ buildType} /**" . toString(), " **/intermediates/javac/${ flavor}${ buildType.capitalize()} /*/classes/**" . toString()])
280
282
283
+ if (hasKotlin(project)) {
284
+ assert contentEquals(classDirectories. includes, [" **/intermediates/classes/${ flavor} /${ buildType} /**" . toString(), " **/intermediates/javac/${ flavor}${ buildType.capitalize()} /*/classes/**" . toString(),
285
+ " **/tmp/kotlin-classes/${ buildType} /**" . toString(), " **/tmp/kotlin-classes/${ flavor}${ buildType.capitalize()} /**" . toString()])
286
+ } else {
287
+ assert contentEquals(classDirectories. includes, [" **/intermediates/classes/${ flavor} /${ buildType} /**" . toString(), " **/intermediates/javac/${ flavor}${ buildType.capitalize()} /*/classes/**" . toString()])
288
+ }
289
+
281
290
assert taskDependsOn(task, " test${ flavor.capitalize()}${ buildType.capitalize()} UnitTest" )
282
291
assert taskDependsOn(project. tasks. findByName(' check' ), " jacocoTestReport${ flavor.capitalize()}${ buildType.capitalize()} " )
283
292
}
@@ -311,14 +320,18 @@ class GenerationTest {
311
320
}
312
321
313
322
assert reports. xml. enabled
314
- assert reports. xml. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/debug/jacoco.xml'
323
+ assert reports. xml. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/debug/jacoco.xml" )
315
324
assert reports. csv. enabled
316
- assert reports. csv. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/debug/jacoco.csv'
325
+ assert reports. csv. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/debug/jacoco.csv" )
317
326
assert reports. html. enabled
318
- assert reports. html. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/debug'
327
+ assert reports. html. destination. toPath () == Paths . get( project. buildDir. absolutePath, " /reports/jacoco/debug" )
319
328
320
329
assert classDirectories. dir == project. file(" build/" )
321
- assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' ])
330
+ if (hasKotlin(project)) {
331
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' , ' **/tmp/kotlin-classes/debug/**' ])
332
+ } else {
333
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' ])
334
+ }
322
335
323
336
assert taskDependsOn(debugTask, ' testDebugUnitTest' )
324
337
assert taskDependsOn(project. tasks. findByName(' check' ), ' jacocoTestReportDebug' )
@@ -347,14 +360,18 @@ class GenerationTest {
347
360
}
348
361
349
362
assert reports. xml. enabled
350
- assert reports. xml. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/debug/jacoco.xml'
363
+ assert reports. xml. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/debug/jacoco.xml' )
351
364
assert reports. csv. enabled
352
- assert reports. csv. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/debug/jacoco.csv'
365
+ assert reports. csv. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/debug/jacoco.csv' )
353
366
assert reports. html. enabled
354
- assert reports. html. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/debug'
367
+ assert reports. html. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/debug' )
355
368
356
369
assert classDirectories. dir == project. file(" build/" )
357
- assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' ])
370
+ if (hasKotlin(project)) {
371
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' , ' **/tmp/kotlin-classes/debug/**' ])
372
+ } else {
373
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/debug/**' , ' **/intermediates/javac/debug/*/classes/**' ])
374
+ }
358
375
359
376
assert taskDependsOn(debugTaskCombined, ' testDebugUnitTest' )
360
377
assert taskDependsOn(debugTaskCombined, ' createDebugCoverageReport' )
@@ -387,14 +404,18 @@ class GenerationTest {
387
404
}
388
405
389
406
assert reports. xml. enabled
390
- assert reports. xml. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/release/jacoco.xml'
407
+ assert reports. xml. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacoco/release/jacoco.xml' )
391
408
assert reports. csv. enabled
392
- assert reports. csv. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/release/jacoco.csv'
409
+ assert reports. csv. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacoco/release/jacoco.csv' )
393
410
assert reports. html. enabled
394
- assert reports. html. destination. toString () == project. buildDir. absolutePath + ' /reports/jacoco/release'
411
+ assert reports. html. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacoco/release' )
395
412
396
413
assert classDirectories. dir == project. file(" build/" )
397
- assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' ])
414
+ if (hasKotlin(project)) {
415
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' , ' **/tmp/kotlin-classes/release/**' ])
416
+ } else {
417
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' ])
418
+ }
398
419
399
420
assert taskDependsOn(releaseTask, ' testReleaseUnitTest' )
400
421
assert taskDependsOn(project. tasks. findByName(' check' ), ' jacocoTestReportRelease' )
@@ -424,14 +445,18 @@ class GenerationTest {
424
445
}
425
446
426
447
assert reports. xml. enabled
427
- assert reports. xml. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/release/jacoco.xml'
448
+ assert reports. xml. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/release/jacoco.xml' )
428
449
assert reports. csv. enabled
429
- assert reports. csv. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/release/jacoco.csv'
450
+ assert reports. csv. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/release/jacoco.csv' )
430
451
assert reports. html. enabled
431
- assert reports. html. destination. toString () == project. buildDir. absolutePath + ' /reports/jacocoCombined/release'
452
+ assert reports. html. destination. toPath () == Paths . get( project. buildDir. absolutePath, ' /reports/jacocoCombined/release' )
432
453
433
454
assert classDirectories. dir == project. file(" build/" )
434
- assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' ])
455
+ if (hasKotlin(project)) {
456
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' , ' **/tmp/kotlin-classes/release/**' ])
457
+ } else {
458
+ assert contentEquals(classDirectories. includes, [' **/intermediates/classes/release/**' , ' **/intermediates/javac/release/*/classes/**' ])
459
+ }
435
460
436
461
assert taskDependsOn(releaseTaskCombined, ' testReleaseUnitTest' )
437
462
assert taskDependsOn(releaseTaskCombined, ' createReleaseCoverageReport' )
@@ -496,6 +521,10 @@ class GenerationTest {
496
521
return false
497
522
}
498
523
524
+ static boolean hasKotlin (Project project ) {
525
+ return project. plugins. hasPlugin(' org.jetbrains.kotlin.android' ) || project. plugins. hasPlugin(' org.jetbrains.kotlin.multiplatform' )
526
+ }
527
+
499
528
@Test void getExcludesDefault () {
500
529
final def excludes = GenerationPlugin . getExcludes(new JunitJacocoExtension ())
501
530
0 commit comments