Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on all JDKs but only build on 18 #1238

Merged
merged 1 commit into from Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}
}
}