diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f380f87f..74f6c043 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,6 +11,7 @@ on: jobs: tests: + name: "E2E tests" runs-on: ubuntu-latest steps: - name: Checkout project with submodules @@ -20,7 +21,7 @@ jobs: - name: Setup JDK uses: actions/setup-java@v4 with: - java-version: 11 + java-version: 19 distribution: 'zulu' - uses: gradle/gradle-build-action@v2 - name: Run sanity check @@ -31,5 +32,8 @@ 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 + -Pe2eVerboseOutput + e2eTest diff --git a/.github/workflows/gradle-latest-versions.yml b/.github/workflows/gradle-latest-versions.yml index c9e4fd9c..c90c96bc 100644 --- a/.github/workflows/gradle-latest-versions.yml +++ b/.github/workflows/gradle-latest-versions.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 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 e17ac642..d661cd0d 100644 --- a/.github/workflows/java-versions.yml +++ b/.github/workflows/java-versions.yml @@ -15,8 +15,9 @@ jobs: openjdk: strategy: matrix: - jdk: [11, 17] - name: "OpenJDK ${{ matrix.jdk }}" + jdk: [11, 17, 19] + testJdk: [auto, 8] + name: "OpenJDK ${{ matrix.jdk }} (with testJDK ${{ matrix.testJdk }})" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,4 +39,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 926e1fe7..3c115085 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,8 +21,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 with: - java-version: 11 + java-version: 19 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 495d62e6..70a0b986 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -92,7 +92,7 @@ dependencies { testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1") testImplementation("org.assertj:assertj-core:3.25.1") // 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. + // 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") } @@ -129,6 +129,22 @@ 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.6") + } + } } } @@ -174,7 +190,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") @@ -252,6 +268,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) @@ -261,6 +288,19 @@ tasks { withType().matching { it.name.startsWith("compatTest") }.configureEach { systemProperty("plugin.version", project.version) } + named("test").configure { + javaLauncher = project.javaToolchains.launcherFor { + languageVersion = providers + .gradleProperty("nexusPublishPlugin.test.java") + .map { + if (it == "auto") { + JavaLanguageVersion.of(JavaVersion.current().majorVersion) + } else { + JavaLanguageVersion.of(it) + } + } + } + } } 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 diff --git a/stutter.lockfile b/stutter.lockfile index bff6f5cf..a01316f2 100644 --- a/stutter.lockfile +++ b/stutter.lockfile @@ -1,4 +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