diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f0b49aff..1525b926 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,7 +11,13 @@ on: jobs: tests: + name: "E2E tests on Java ${{ matrix.jdk }}" 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@v3 @@ -20,7 +26,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 @@ -31,5 +37,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 -Pe2eVerboseOutput e2eTest + run: > + ./gradlew + --stacktrace + -PnexusPublishPlugin.test.java=${{ matrix.jdk }} + -Pe2eVerboseOutput + e2eTest 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..25e317b7 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -15,14 +15,14 @@ jobs: openjdk: strategy: matrix: - jdk: [11, 17] + jdk: [8, 11, 17] name: "OpenJDK ${{ matrix.jdk }}" runs-on: ubuntu-latest steps: - 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 @@ -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: | 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: diff --git a/build.gradle.kts b/build.gradle.kts index d2815a54..3125e69b 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") } @@ -251,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) @@ -260,6 +269,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 { 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() 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