diff --git a/.github/workflows/gradle-pr-build.yml b/.github/workflows/gradle-pr-build.yml index 32313e8252..5007f02f94 100644 --- a/.github/workflows/gradle-pr-build.yml +++ b/.github/workflows/gradle-pr-build.yml @@ -8,13 +8,14 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest ] + jdk: [ 8, 11, 17, 19 ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 19 + java-version: ${{ matrix.jdk }} - uses: gradle/gradle-build-action@v2 - name: Build with release Kotlin version run: ./gradlew clean build ktlint --no-daemon diff --git a/CHANGELOG.md b/CHANGELOG.md index 32cf0eb7f7..027aebad26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Changed +* Revert to matrix build to speed up build, especially for the Windows related build ([#1786](https://github.com/pinterest/ktlint/pull/1787)) + ## [0.48.2] - 2023-01-21 ### Additional clarification on API Changes in `0.48.0` and `0.48.1` diff --git a/build-logic/src/main/kotlin/ToolchainForTests.kt b/build-logic/src/main/kotlin/ToolchainForTests.kt deleted file mode 100644 index 336e4d99d5..0000000000 --- a/build-logic/src/main/kotlin/ToolchainForTests.kt +++ /dev/null @@ -1,39 +0,0 @@ -import org.gradle.api.Project -import org.gradle.api.tasks.testing.Test -import org.gradle.jvm.toolchain.JavaLanguageVersion -import org.gradle.jvm.toolchain.JavaToolchainService -import org.gradle.kotlin.dsl.register - -val Project.javaToolchains: JavaToolchainService - get() = extensions.getByType(JavaToolchainService::class.java) - -fun Project.addAdditionalJdkVersionTests() { - // Tests should be run on all supported LTS versions of the JDK. For example, see https://endoflife.date/java - listOf(8, 11, 17, 19).forEach(::addJdkVersionTests) -} - -private fun Project.addJdkVersionTests(jdkVersion: Int) { - val jdkVersionTests = tasks.register("testOnJdk$jdkVersion") { - javaLauncher.set( - javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(jdkVersion)) - }, - ) - val jvmArgs = mutableListOf() - if (jdkVersion >= 16) { - // https://docs.gradle.org/7.5/userguide/upgrading_version_7.html#removes_implicit_add_opens_for_test_workers - jvmArgs += listOf( - "--add-opens=java.base/java.lang=ALL-UNNAMED", - "--add-opens=java.base/java.util=ALL-UNNAMED", - ) - } - if (jdkVersion >= 18) { - // https://openjdk.org/jeps/411 - jvmArgs += "-Djava.security.manager=allow" - } - setJvmArgs(jvmArgs) - } - tasks.named("check") { - dependsOn(jdkVersionTests) - } -} diff --git a/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts b/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts index 17066c00ee..70df520fc0 100644 --- a/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts +++ b/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts @@ -1,14 +1,17 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { kotlin("jvm") } kotlin { - jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(8)) - } - // All modules, the CLI included, must have an explicit API explicitApi() } -addAdditionalJdkVersionTests() +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 386cb7baff..2eaf6552cd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,6 +19,20 @@ allprojects { } else { logger.warn("Skipping tests for task '$name' as system property 'skipTests=$skipTests'") } + + val args = mutableSetOf() + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16)) { + // https://docs.gradle.org/7.5/userguide/upgrading_version_7.html#removes_implicit_add_opens_for_test_workers + args += listOf( + "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", + ) + } + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18)) { + // https://openjdk.org/jeps/411 + args += "-Djava.security.manager=allow" + } + jvmArgs(args) } }