diff --git a/buildSrc/src/main/kotlin/spring.batch.plus.java-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/spring.batch.plus.java-library-conventions.gradle.kts index 0fe79b1..02581b9 100644 --- a/buildSrc/src/main/kotlin/spring.batch.plus.java-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/spring.batch.plus.java-library-conventions.gradle.kts @@ -3,6 +3,10 @@ plugins { // https://docs.gradle.org/current/userguide/java_library_plugin.html `java-library` + // for managing custom test suite + // https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html + `jvm-test-suite` + // coverage, jacoco can cover kotlin codes // https://docs.gradle.org/current/userguide/jacoco_plugin.html jacoco @@ -48,17 +52,43 @@ tasks.javadoc { } } -tasks.named("test") { - useJUnitPlatform() - maxParallelForks = Runtime.getRuntime().availableProcessors() -} - -sourceSets { - create("integrationTest") { - compileClasspath += sourceSets.main.get().output - runtimeClasspath += sourceSets.main.get().output +testing { + suites { + // reference to test task which is automatically created + val test by getting(JvmTestSuite::class) { + targets { + all { + testTask.configure { + useJUnitPlatform() + maxParallelForks = Runtime.getRuntime().availableProcessors() + } + } + } + } + + register("integrationTest") { + dependencies { + // add dependency of project itself + implementation(project()) + } + + targets { + all { + testTask.configure { + // run after 'test' task + shouldRunAfter(test) + + useJUnitPlatform() + maxParallelForks = Runtime.getRuntime().availableProcessors() + } + } + } + } } } + +// configure dependencies integrationTest from project itself +// see also: https://github.com/gradle/gradle/issues/19870 val integrationTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.implementation.get(), configurations.testImplementation.get()) } @@ -66,17 +96,6 @@ val integrationTestRuntimeOnly: Configuration by configurations.getting { extendsFrom(configurations.runtimeOnly.get(), configurations.testRuntimeOnly.get()) } -tasks.register("integrationTest") { - // run after 'test' task - shouldRunAfter("test") - - useJUnitPlatform() - maxParallelForks = Runtime.getRuntime().availableProcessors() - - testClassesDirs = sourceSets["integrationTest"].output.classesDirs - classpath = sourceSets["integrationTest"].runtimeClasspath -} - /* jacoco */