From 16507746425c1d10ee09e023106cace9779c950a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Fri, 14 Jul 2023 10:40:09 +0100 Subject: [PATCH 01/16] Upgrade mockito now that the minimum Java is 11 on CI --- build.gradle.kts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d2815a54..2ad8cf7f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -90,9 +90,7 @@ dependencies { testImplementation("com.github.tomakehurst:wiremock:2.27.2") testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1") testImplementation("org.assertj:assertj-core:3.24.2") - // This cannot be updated to 5.x as it requires Java 11, - // but we are running CI on Java 8 in .github/workflows/java-versions.yml. - testImplementation("org.mockito:mockito-junit-jupiter:4.11.0") + testImplementation("org.mockito:mockito-junit-jupiter:5.4.0") testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0") } From 97d8f227da63d6413475f6090ba8638d7289650a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 09:56:55 +0100 Subject: [PATCH 02/16] Use latest Java to run Gradle. --- .github/workflows/gradle-latest-versions.yml | 2 +- .github/workflows/java-versions.yml | 2 +- .github/workflows/main.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle-latest-versions.yml b/.github/workflows/gradle-latest-versions.yml index 2d278854..6f6d5a79 100644 --- a/.github/workflows/gradle-latest-versions.yml +++ b/.github/workflows/gradle-latest-versions.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 19 distribution: 'zulu' - uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 98e4e0fc..d3fc2641 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - java-version: ${{ matrix.jdk }} + java-version: 19 distribution: 'zulu' - uses: gradle/gradle-build-action@v2 # Workaround https://github.com/ajoberstar/gradle-stutter/issues/22 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 314dda8c..10735bc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 19 distribution: 'zulu' - uses: gradle/gradle-build-action@v2 with: From 6715672f4488930ef028d3b73935024818f90913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 10:46:43 +0100 Subject: [PATCH 03/16] Always run unit tests on Java 11 --- build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 2ad8cf7f..e2baf6ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -258,6 +258,11 @@ tasks { withType().matching { it.name.startsWith("compatTest") }.configureEach { systemProperty("plugin.version", project.version) } + named("test").configure { + javaLauncher = project.javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(11) + } + } } publishing { From 641535f1d9c7c5003406064f422d2c66decac7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 09:59:26 +0100 Subject: [PATCH 04/16] Add back Java 8 for running compat tests --- .github/workflows/java-versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index d3fc2641..525f5129 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -15,7 +15,7 @@ jobs: openjdk: strategy: matrix: - jdk: [11, 17] + jdk: [8, 11, 17] name: "OpenJDK ${{ matrix.jdk }}" runs-on: ubuntu-latest steps: From 3a502f10170e0cc65c4e989d22e6b3e3c3fb8602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 10:41:17 +0100 Subject: [PATCH 05/16] Test earliest and latest supported version on each Java version. --- .github/workflows/java-versions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 525f5129..25e317b7 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -32,8 +32,8 @@ jobs: # java11=6.0.1,6.9.4,7.0.2,7.6.1,8.0.2,8.1.1,8.2-rc-1 # -> # java11=8.2-rc-1 - # The trick is that \2 will greedily eat everything before the last comma. - sed -r 's/^(.*?)=(.*),(.*)$/\1=\3/g' -i stutter.lockfile + # The trick is that \3 will greedily eat everything before the last comma. + sed -r 's/^(.*?)=(.*?),(.*),(.*?)$/\1=\2,\4/g' -i stutter.lockfile cat stutter.lockfile - name: Test cross Java versions compatibility run: | From 55b9ebdde5e2512bbfd5c0446c5b79dd35162d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 10:56:44 +0100 Subject: [PATCH 06/16] Add tests to verify java versions on CI --- .github/workflows/java-versions.yml | 1 + .github/workflows/main.yml | 1 + .../publishplugin/JavaVersionInCompatTest.kt | 27 +++++++++++++++++++ .../publishplugin/e2e/JavaVersionInE2ETest.kt | 27 +++++++++++++++++++ .../publishplugin/JavaVersionUnitTest.kt | 27 +++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt create mode 100644 src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt create mode 100644 src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 25e317b7..6645292c 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -14,6 +14,7 @@ on: jobs: openjdk: strategy: + fail-fast: false matrix: jdk: [8, 11, 17] name: "OpenJDK ${{ matrix.jdk }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10735bc3..c48962c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ on: jobs: gradle: strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt b/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt new file mode 100644 index 00000000..61785308 --- /dev/null +++ b/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.gradlenexus.publishplugin + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.fail + +class JavaVersionInCompatTest { + + @Test fun test() { + fail(System.getProperty("java.version").toString()) + } +} diff --git a/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt b/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt new file mode 100644 index 00000000..5d6feea1 --- /dev/null +++ b/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.gradlenexus.publishplugin.e2e + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.fail + +class JavaVersionInE2ETest { + + @Test fun test() { + fail(System.getProperty("java.version").toString()) + } +} diff --git a/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt b/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt new file mode 100644 index 00000000..3e49fa69 --- /dev/null +++ b/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.gradlenexus.publishplugin + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.fail + +class JavaVersionUnitTest { + + @Test fun test() { + fail(System.getProperty("java.version").toString()) + } +} From a0da4d7ca179888f234853b901823e1f355029d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 11:31:24 +0100 Subject: [PATCH 07/16] Apply ktlint to IdeaExtExtensions.kt momentarily. Cannot be applied permanently, because Spotless doesn't allow "adding" sources only "setting". --- buildSrc/src/main/kotlin/IdeaExtExtensions.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/IdeaExtExtensions.kt b/buildSrc/src/main/kotlin/IdeaExtExtensions.kt index d6cd9d40..a104a4ea 100644 --- a/buildSrc/src/main/kotlin/IdeaExtExtensions.kt +++ b/buildSrc/src/main/kotlin/IdeaExtExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,13 +24,13 @@ import java.io.File import kotlin.math.min fun IdeaProject.settings(configuration: ProjectSettings.() -> kotlin.Unit) = - (this as ExtensionAware).configure(configuration) + (this as ExtensionAware).configure(configuration) fun ProjectSettings.copyright(configuration: CopyrightConfiguration.() -> kotlin.Unit) = - (this as ExtensionAware).configure(configuration) + (this as ExtensionAware).configure(configuration) fun Project.readCopyrightHeader(licenseHeaderFile: File) = - licenseHeaderFile.readLines() - .map { line -> line.substring(min(line.length, 3)) } - .joinToString("\n") - .trim() + licenseHeaderFile.readLines() + .map { line -> line.substring(min(line.length, 3)) } + .joinToString("\n") + .trim() From 478e1b3737e1ab9c3161a3e1f224942f583b61d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 12:02:27 +0100 Subject: [PATCH 08/16] Revert "Add tests to verify java versions on CI" This reverts commit 55b9ebdde5e2512bbfd5c0446c5b79dd35162d15. --- .github/workflows/java-versions.yml | 1 - .github/workflows/main.yml | 1 - .../publishplugin/JavaVersionInCompatTest.kt | 27 ------------------- .../publishplugin/e2e/JavaVersionInE2ETest.kt | 27 ------------------- .../publishplugin/JavaVersionUnitTest.kt | 27 ------------------- 5 files changed, 83 deletions(-) delete mode 100644 src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt delete mode 100644 src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt delete mode 100644 src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 6645292c..25e317b7 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -14,7 +14,6 @@ on: jobs: openjdk: strategy: - fail-fast: false matrix: jdk: [8, 11, 17] name: "OpenJDK ${{ matrix.jdk }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c48962c7..10735bc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,6 @@ on: jobs: gradle: strategy: - fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt b/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt deleted file mode 100644 index 61785308..00000000 --- a/src/compatTest/kotlin/io/github/gradlenexus/publishplugin/JavaVersionInCompatTest.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.gradlenexus.publishplugin - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.fail - -class JavaVersionInCompatTest { - - @Test fun test() { - fail(System.getProperty("java.version").toString()) - } -} diff --git a/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt b/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt deleted file mode 100644 index 5d6feea1..00000000 --- a/src/e2eTest/kotlin/io/github/gradlenexus/publishplugin/e2e/JavaVersionInE2ETest.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.gradlenexus.publishplugin.e2e - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.fail - -class JavaVersionInE2ETest { - - @Test fun test() { - fail(System.getProperty("java.version").toString()) - } -} diff --git a/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt b/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt deleted file mode 100644 index 3e49fa69..00000000 --- a/src/test/kotlin/io/github/gradlenexus/publishplugin/JavaVersionUnitTest.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.gradlenexus.publishplugin - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.fail - -class JavaVersionUnitTest { - - @Test fun test() { - fail(System.getProperty("java.version").toString()) - } -} From b2dff42a5bbb6f1d9bf3468392b1c2c3e5381da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 13:00:15 +0100 Subject: [PATCH 09/16] E2E tests bump Java --- .github/workflows/e2e.yml | 9 +++++++-- build.gradle.kts | 11 +++++++++++ gradle.properties | 6 ++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f0b49aff..b57627af 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,7 +11,12 @@ on: jobs: tests: + name: "E2E tests on Java ${{ matrix.jdk }}" runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + jdk: [ 8, 11, 17 ] steps: - name: Checkout project with submodules uses: actions/checkout@v3 @@ -20,7 +25,7 @@ jobs: - name: Setup JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 19 distribution: 'zulu' - uses: gradle/gradle-build-action@v2 - name: Run sanity check @@ -32,4 +37,4 @@ jobs: ORG_GRADLE_PROJECT_signingKeyE2E: ${{ secrets.GPG_SIGNING_KEY_E2E }} ORG_GRADLE_PROJECT_signingPasswordE2E: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE_E2E }} run: | - ./gradlew --stacktrace -Pe2eVerboseOutput e2eTest + ./gradlew --stacktrace -PnexusPublishPlugin.test.java=${{ matrix.jdk }} -Pe2eVerboseOutput e2eTest diff --git a/build.gradle.kts b/build.gradle.kts index e2baf6ef..3125e69b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -249,6 +249,17 @@ tasks { showStandardStreams = true } } + javaLauncher = project.javaToolchains.launcherFor { + languageVersion = providers + .gradleProperty("nexusPublishPlugin.test.java") + .map { + if (it == "auto") { + JavaLanguageVersion.of(JavaVersion.current().majorVersion) + } else { + JavaLanguageVersion.of(it) + } + } + } } withType().configureEach { dependsOn(shadowJar) diff --git a/gradle.properties b/gradle.properties index 8c5fc5cf..78eaa17f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,9 @@ org.gradle.caching=true org.gradle.parallel=true org.gradle.configuration-cache=true + +# Version of JDK to use for running tests. +# Possible values: +# - auto -> use Java running Gradle, best for local dev. +# - A Java major version number, like 8, 11 or 17. +nexusPublishPlugin.test.java=auto From b63ebcbc21362d9ed7a93de28bd38d5edf03d705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 13:02:27 +0100 Subject: [PATCH 10/16] Split down commandline for easier readability --- .github/workflows/e2e.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b57627af..293cd9f8 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,5 +36,9 @@ jobs: ORG_GRADLE_PROJECT_sonatypePasswordE2E: ${{ secrets.SONATYPE_PASSWORD_E2E }} ORG_GRADLE_PROJECT_signingKeyE2E: ${{ secrets.GPG_SIGNING_KEY_E2E }} ORG_GRADLE_PROJECT_signingPasswordE2E: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE_E2E }} - run: | - ./gradlew --stacktrace -PnexusPublishPlugin.test.java=${{ matrix.jdk }} -Pe2eVerboseOutput e2eTest + run: > + ./gradlew + --stacktrace + -PnexusPublishPlugin.test.java=${{ matrix.jdk }} + -Pe2eVerboseOutput + e2eTest From a358c6394497ae1e750c6cd8393be38cce089c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 22 Jul 2023 13:08:07 +0100 Subject: [PATCH 11/16] Run end to end tests linearly --- .github/workflows/e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 293cd9f8..1525b926 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -15,6 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false + max-parallel: 1 matrix: jdk: [ 8, 11, 17 ] steps: From d4adad629b95783cea2babec7726aeced7d6fd6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:37:02 +0100 Subject: [PATCH 12/16] Build on latest Java, test through lowest possible - approach 2 --- .github/workflows/e2e.yml | 8 +------- .github/workflows/java-versions.yml | 11 +++++++---- .github/workflows/main.yml | 2 +- build.gradle.kts | 24 +++++++++++++++++++++--- stutter.lockfile | 1 + 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a2310b24..74f6c043 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -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 @@ -40,6 +35,5 @@ jobs: run: > ./gradlew --stacktrace - -PnexusPublishPlugin.test.java=${{ matrix.jdk }} -Pe2eVerboseOutput e2eTest diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 7e17869e..af5cf8c2 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0522933..3c115085 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,4 +25,4 @@ jobs: distribution: 'zulu' - uses: gradle/gradle-build-action@v2 with: - arguments: --stacktrace build compatTestJava11 + arguments: --stacktrace build compatTestJava17 diff --git a/build.gradle.kts b/build.gradle.kts index 2fdad755..389b5e78 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") } @@ -127,6 +129,14 @@ stutter { compatibleRange("7.3") } } + register("javaauto") { + javaToolchain { + languageVersion = JavaLanguageVersion.of(JavaVersion.current().majorVersion) + } + gradleVersions { + compatibleRange("7.3") + } + } } } @@ -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") @@ -272,7 +282,15 @@ tasks { } named("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) + } + } } } } diff --git a/stutter.lockfile b/stutter.lockfile index bff6f5cf..e8cb8435 100644 --- a/stutter.lockfile +++ b/stutter.lockfile @@ -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 From 2aaaf853adc97d9edd89348a6925c859331c4f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:49:21 +0100 Subject: [PATCH 13/16] Restore old sed command to reduce number of Gradle versions --- .github/workflows/java-versions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index af5cf8c2..9b14e19c 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -34,8 +34,8 @@ jobs: # java11=6.2.2,6.9.4,7.0.2,7.6.1,8.0.2,8.1.1,8.2-rc-1 # -> # java11=8.2-rc-1 - # The trick is that \3 will greedily eat everything before the last comma. - sed -r 's/^(.*?)=(.*?),(.*),(.*?)$/\1=\2,\4/g' -i stutter.lockfile + # The trick is that \2 will greedily eat everything before the last comma. + sed -r 's/^(.*?)=(.*),(.*)$/\1=\3/g' -i stutter.lockfile cat stutter.lockfile - name: Test cross Java versions compatibility run: | From 6ef36da245469b3996c5b0d2476516edd2a83b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:50:22 +0100 Subject: [PATCH 14/16] Restore JDK 19 testing on CI in "Java cross-version tests" --- .github/workflows/java-versions.yml | 3 +-- build.gradle.kts | 10 +++++++++- stutter.lockfile | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/java-versions.yml b/.github/workflows/java-versions.yml index 9b14e19c..d661cd0d 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -15,8 +15,7 @@ jobs: openjdk: strategy: matrix: - # TODO: Add 19+ - jdk: [11, 17] + jdk: [11, 17, 19] testJdk: [auto, 8] name: "OpenJDK ${{ matrix.jdk }} (with testJDK ${{ matrix.testJdk }})" runs-on: ubuntu-latest diff --git a/build.gradle.kts b/build.gradle.kts index 389b5e78..70a0b986 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -129,12 +129,20 @@ stutter { compatibleRange("7.3") } } + register("java19") { + javaToolchain { + languageVersion = JavaLanguageVersion.of(19) + } + gradleVersions { + compatibleRange("7.6") + } + } register("javaauto") { javaToolchain { languageVersion = JavaLanguageVersion.of(JavaVersion.current().majorVersion) } gradleVersions { - compatibleRange("7.3") + compatibleRange("7.6") } } } diff --git a/stutter.lockfile b/stutter.lockfile index e8cb8435..a01316f2 100644 --- a/stutter.lockfile +++ b/stutter.lockfile @@ -1,5 +1,6 @@ # DO NOT MODIFY: Generated by Stutter plugin. 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 +java19=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 From 48f40854d7a08a2ca20e82d366a17ff513c5d48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:00:40 +0100 Subject: [PATCH 15/16] TMP - Intentionally break JDK8 compatibility - TMP --- build.gradle.kts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 70a0b986..7789c25a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -98,8 +98,9 @@ dependencies { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + //TODO: Revert before merge! - To demonstrate failure on CI + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } stutter { From 08bef0af16a1d3b4be14fe525a9d90f1c3ab00be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:08:33 +0100 Subject: [PATCH 16/16] Revert "TMP - Intentionally break JDK8 compatibility - TMP" This reverts commit 48f40854d7a08a2ca20e82d366a17ff513c5d48b. --- build.gradle.kts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7789c25a..70a0b986 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -98,9 +98,8 @@ dependencies { } java { - //TODO: Revert before merge! - To demonstrate failure on CI - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } stutter {