Use property to specify test java version instead of adding tasks. (#3365)

* Use property to specify test java version instead of adding tasks.

* Typo
This commit is contained in:
Anuraag Agrawal 2021-07-05 11:15:48 +09:00 committed by GitHub
parent fffc831c46
commit 431bb1281a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 31 deletions

View File

@ -14,9 +14,12 @@ jobs:
os: os:
- macos-latest - macos-latest
- ubuntu-18.04 - ubuntu-18.04
test-java-version:
- 8
- 11
include: include:
- os: ubuntu-18.04 - os: ubuntu-18.04
testAdditionalJavaVersions: true test-java-version: 11
coverage: true coverage: true
steps: steps:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
@ -40,7 +43,7 @@ jobs:
remote-build-cache-proxy-enabled: false remote-build-cache-proxy-enabled: false
arguments: build --stacktrace ${{ matrix.coverage && 'jacocoTestReport' || '' }} arguments: build --stacktrace ${{ matrix.coverage && 'jacocoTestReport' || '' }}
properties: | properties: |
testAdditionalJavaVersions=${{ matrix.testAdditionalJavaVersions }} testJavaVersion=${{ matrix.test-java-version }}
org.gradle.java.installations.paths=${{ steps.setup-java-8.outputs.path }},${{ steps.setup-java-11.outputs.path }} org.gradle.java.installations.paths=${{ steps.setup-java-8.outputs.path }},${{ steps.setup-java-11.outputs.path }}
- uses: codecov/codecov-action@v1.5.2 - uses: codecov/codecov-action@v1.5.2
if: ${{ matrix.coverage }} if: ${{ matrix.coverage }}

View File

@ -14,9 +14,12 @@ jobs:
os: os:
- macos-latest - macos-latest
- ubuntu-18.04 - ubuntu-18.04
test-java-version:
- 8
- 11
include: include:
- os: ubuntu-18.04 - os: ubuntu-18.04
testAdditionalJavaVersions: true test-java-version: 11
coverage: true coverage: true
steps: steps:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
@ -40,7 +43,7 @@ jobs:
remote-build-cache-proxy-enabled: false remote-build-cache-proxy-enabled: false
arguments: build --stacktrace ${{ matrix.coverage && 'jacocoTestReport' || '' }} arguments: build --stacktrace ${{ matrix.coverage && 'jacocoTestReport' || '' }}
properties: | properties: |
testAdditionalJavaVersions=${{ matrix.testAdditionalJavaVersions }} testJavaVersion=${{ matrix.test-java-version }}
org.gradle.java.installations.paths=${{ steps.setup-java-8.outputs.path }},${{ steps.setup-java-11.outputs.path }} org.gradle.java.installations.paths=${{ steps.setup-java-8.outputs.path }},${{ steps.setup-java-11.outputs.path }}
- uses: codecov/codecov-action@v1.5.2 - uses: codecov/codecov-action@v1.5.2
if: ${{ matrix.coverage }} if: ${{ matrix.coverage }}

View File

@ -15,10 +15,6 @@ jobs:
os: os:
- macos-latest - macos-latest
- ubuntu-18.04 - ubuntu-18.04
include:
- os: ubuntu-18.04
testAdditionalJavaVersions: true
coverage: true
steps: steps:
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
- id: setup-java-11 - id: setup-java-11

View File

@ -14,10 +14,13 @@ tasks {
options.release.set(11) options.release.set(11)
} }
named("testJava8") { val testJavaVersion: String? by project
if (testJavaVersion == "8") {
test {
enabled = false enabled = false
} }
} }
}
dependencies { dependencies {
rootProject.subprojects.forEach { subproject -> rootProject.subprojects.forEach { subproject ->

View File

@ -40,24 +40,9 @@ checkstyle {
configProperties["rootDir"] = rootDir configProperties["rootDir"] = rootDir
} }
val testJavaVersion = gradle.startParameter.projectProperties.get("testJavaVersion")?.let(JavaVersion::toVersion)
tasks { tasks {
val testJava8 by registering(Test::class) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(8))
})
jacoco {
enabled = false
}
}
val testAdditionalJavaVersions: String? by rootProject
if (testAdditionalJavaVersions == "true") {
named("check") {
dependsOn(testJava8)
}
}
withType<JavaCompile>().configureEach { withType<JavaCompile>().configureEach {
with(options) { with(options) {
release.set(8) release.set(8)
@ -96,6 +81,12 @@ tasks {
withType<Test>().configureEach { withType<Test>().configureEach {
useJUnitPlatform() useJUnitPlatform()
if (testJavaVersion != null) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion))
})
}
testLogging { testLogging {
exceptionFormat = TestExceptionFormat.FULL exceptionFormat = TestExceptionFormat.FULL
showExceptions = true showExceptions = true

View File

@ -16,11 +16,12 @@ tasks {
options.release.set(11) options.release.set(11)
} }
named("testJava8") { test {
val testJavaVersion: String? by project
if (testJavaVersion == "8") {
enabled = false enabled = false
} }
named("test") {
// Disabled due to https://bugs.openjdk.java.net/browse/JDK-8245283 // Disabled due to https://bugs.openjdk.java.net/browse/JDK-8245283
configure<JacocoTaskExtension> { configure<JacocoTaskExtension> {
enabled = false enabled = false