Skip to content

Commit

Permalink
Merge pull request #1238 from square/egor/220414/test-on-all-jdks
Browse files Browse the repository at this point in the history
Run tests on all JDKs but only build on 18
  • Loading branch information
Egorand committed Apr 14, 2022
2 parents 9d463fc + b4c8303 commit cec7a96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/build.yml
Expand Up @@ -9,22 +9,6 @@ jobs:
jvm:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
java-version:
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -36,7 +20,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
java-version: 18

- name: Test
run: ./gradlew build
Expand All @@ -55,7 +39,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 17
java-version: 18

- name: Upload Artifacts
run: ./gradlew publish
Expand Down
25 changes: 25 additions & 0 deletions build.gradle.kts
Expand Up @@ -99,4 +99,29 @@ subprojects {
)
}
}

// Copied from https://github.com/square/retrofit/blob/master/retrofit/build.gradle#L28.
// Create a test task for each supported JDK.
for (majorVersion in 8..18) {
// Adoptium JDK 9 cannot extract on Linux or Mac OS.
if (majorVersion == 9) continue

val jdkTest = tasks.register<Test>("testJdk$majorVersion") {
val javaToolchains = project.extensions.getByType(JavaToolchainService::class)
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(majorVersion))
})

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

// Copy inputs from normal Test task.
val testTask = tasks.getByName<Test>("test")
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
}
tasks.named("check").configure {
dependsOn(jdkTest)
}
}
}

0 comments on commit cec7a96

Please sign in to comment.