Skip to content

Commit

Permalink
Build on latest Java, test through lowest possible - approach 2
Browse files Browse the repository at this point in the history
  • Loading branch information
szpak committed Jan 16, 2024
1 parent 263b035 commit d4adad6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ on:

jobs:
tests:
name: "E2E tests on Java ${{ matrix.jdk }}"
name: "E2E tests"
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
jdk: [ 8, 11, 17 ]
steps:
- name: Checkout project with submodules
uses: actions/checkout@v4
Expand All @@ -40,6 +35,5 @@ jobs:
run: >
./gradlew
--stacktrace
-PnexusPublishPlugin.test.java=${{ matrix.jdk }}
-Pe2eVerboseOutput
e2eTest
11 changes: 7 additions & 4 deletions .github/workflows/java-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ jobs:
openjdk:
strategy:
matrix:
jdk: [8, 11, 17]
name: "OpenJDK ${{ matrix.jdk }}"
# TODO: Add 19+
jdk: [11, 17]
testJdk: [auto, 8]
name: "OpenJDK ${{ matrix.jdk }} (with testJDK ${{ matrix.testJdk }})"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 19
java-version: ${{ matrix.jdk }}
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2
# Workaround https://github.com/ajoberstar/gradle-stutter/issues/22
Expand All @@ -38,4 +40,5 @@ jobs:
- name: Test cross Java versions compatibility
run: |
./gradlew --version
./gradlew --stacktrace build compatTestJava${{ matrix.jdk }}
./gradlew -q javaToolchains
./gradlew --stacktrace -PnexusPublishPlugin.test.java=${{ matrix.testJdk }} build compatTestJava${{ matrix.jdk }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2
with:
arguments: --stacktrace build compatTestJava11
arguments: --stacktrace build compatTestJava17
24 changes: 21 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ dependencies {
testImplementation("com.github.tomakehurst:wiremock:2.27.2")
testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1")
testImplementation("org.assertj:assertj-core:3.25.1")
testImplementation("org.mockito:mockito-junit-jupiter:5.4.0")
// This cannot be updated to 5.x as it requires Java 11,
// but we are running tests on CI with Java 8 in .github/workflows/java-versions.yml.
testImplementation("org.mockito:mockito-junit-jupiter:4.11.0")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
}

Expand Down Expand Up @@ -127,6 +129,14 @@ stutter {
compatibleRange("7.3")
}
}
register("javaauto") {
javaToolchain {
languageVersion = JavaLanguageVersion.of(JavaVersion.current().majorVersion)
}
gradleVersions {
compatibleRange("7.3")
}
}
}
}

Expand Down Expand Up @@ -172,7 +182,7 @@ kotlin.target.compilations.configureEach {
compilerOptions.configure {
// Gradle fully supports running on Java 8: https://docs.gradle.org/current/userguide/compatibility.html,
// so we should allow users to do that too.
jvmTarget = JvmTarget.fromTarget(JavaVersion.VERSION_1_8.toString())
jvmTarget = JvmTarget.fromTarget(project.java.targetCompatibility.toString())

// Suppress "Language version 1.3 is deprecated and its support will be removed in a future version of Kotlin".
freeCompilerArgs.add("-Xsuppress-version-warnings")
Expand Down Expand Up @@ -272,7 +282,15 @@ tasks {
}
named<Test>("test").configure {
javaLauncher = project.javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
languageVersion = providers
.gradleProperty("nexusPublishPlugin.test.java")
.map {
if (it == "auto") {
JavaLanguageVersion.of(JavaVersion.current().majorVersion)
} else {
JavaLanguageVersion.of(it)
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions stutter.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
java11=6.2.2,6.9.4,7.0.2,7.6.2,8.0.2,8.2.1
java17=7.3.3,7.6.2,8.0.2,8.2.1
java8=6.2.2,6.9.4,7.0.2,7.6.2,8.0.2,8.2.1
javaauto=7.3.3,7.6.2,8.0.2,8.2.1

0 comments on commit d4adad6

Please sign in to comment.