Skip to content

Commit

Permalink
Pre-register all testOnJdk test tasks for all LTS java versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Jul 15, 2023
1 parent 0820c1e commit 171790c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-with-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ jobs:
with:
gradle-home-cache-cleanup: true

- run: ./gradlew testOnJdk -PtestJdkVersion=${{ matrix.jdk }}
- run: ./gradlew testOnJdk${{ matrix.jdk }} -PtestJdkVersion=${{ matrix.jdk }}
10 changes: 7 additions & 3 deletions build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ tasks.withType<KotlinCompile>().configureEach {
}

val requestedJdkVersion = project.findProperty("testJdkVersion")?.toString()?.toInt()
if (requestedJdkVersion != null) {
tasks.register<Test>("testOnJdk") {
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(requestedJdkVersion) }
// List all non-current Java versions the developers may want to run via IDE click
setOf(8, 11, 17, requestedJdkVersion).filterNotNull().forEach { version ->
tasks.register<Test>("testOnJdk$version") {
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(version) }

description = "Runs the test suite on JDK $version"
group = LifecycleBasePlugin.VERIFICATION_GROUP

// Copy inputs from normal Test task.
val testTask = tasks.test.get()
Expand Down

0 comments on commit 171790c

Please sign in to comment.