From fc166f10b01d9b30d9e7debaa80e104b492079e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwieci=C5=84ski?= <36954793+mateuszkwiecinski@users.noreply.github.com> Date: Fri, 3 Nov 2023 22:29:13 +0100 Subject: [PATCH] Compile with Java 21 (#547) --- .github/workflows/default.yml | 6 +++--- .github/workflows/dependencies.yml | 4 ++-- .github/workflows/publish_release.yml | 2 +- .github/workflows/publish_snapshot.yml | 4 ++-- .github/workflows/run_diffuse.yml | 2 +- .../modules/plugins/AndroidLibraryPlugin.kt | 1 - .../modules/AndroidApplicationPluginTest.kt | 18 +++++++++++++++--- .../modules/AndroidLibraryPluginTest.kt | 18 +++++++++++++++--- .../modules/tasks/ConfigurationCacheTest.kt | 14 +++++++++++++- .../quality/AndroidQualityPluginTest.kt | 2 +- build.gradle | 5 +++-- gradle/plugins/build.gradle | 2 +- .../starter/modules/KotlinLibraryPluginTest.kt | 4 ++-- .../starter/quality/plugins/QualityPlugin.kt | 2 +- .../starter/quality/QualityPluginTest.kt | 2 +- 15 files changed, 61 insertions(+), 25 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 6a50893a..d8bd5037 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - uses: gradle/wrapper-validation-action@v1 @@ -89,7 +89,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - name: Run ${{ matrix.task }} uses: gradle/gradle-build-action@v2 @@ -120,7 +120,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - name: Run ${{ matrix.task }} uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 4129b688..39e8c193 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - name: Cache uses: gradle/gradle-build-action@v2 @@ -75,7 +75,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - name: Cache uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index eb71cfa7..7fcff71a 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -32,7 +32,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/publish_snapshot.yml b/.github/workflows/publish_snapshot.yml index dc429569..966d42f4 100644 --- a/.github/workflows/publish_snapshot.yml +++ b/.github/workflows/publish_snapshot.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - name: Build app with Gradle uses: gradle/gradle-build-action@v2 @@ -63,7 +63,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/run_diffuse.yml b/.github/workflows/run_diffuse.yml index 3cd1d0ef..adf100d8 100644 --- a/.github/workflows/run_diffuse.yml +++ b/.github/workflows/run_diffuse.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 20 + java-version: 21 - uses: actions/cache@v3 name: Download base diff --git a/android/src/main/kotlin/com/project/starter/modules/plugins/AndroidLibraryPlugin.kt b/android/src/main/kotlin/com/project/starter/modules/plugins/AndroidLibraryPlugin.kt index 4b9cafba..ab0fddeb 100644 --- a/android/src/main/kotlin/com/project/starter/modules/plugins/AndroidLibraryPlugin.kt +++ b/android/src/main/kotlin/com/project/starter/modules/plugins/AndroidLibraryPlugin.kt @@ -24,7 +24,6 @@ class AndroidLibraryPlugin : Plugin { extensions.getByType().apply { configureAndroidPlugin(rootConfig) - defaultConfig.targetSdk = rootConfig.android.targetSdkVersion ?: rootConfig.android.compileSdkVersion buildFeatures.buildConfig = false diff --git a/android/src/test/kotlin/com/project/starter/modules/AndroidApplicationPluginTest.kt b/android/src/test/kotlin/com/project/starter/modules/AndroidApplicationPluginTest.kt index f4ef44a3..8a111e0e 100644 --- a/android/src/test/kotlin/com/project/starter/modules/AndroidApplicationPluginTest.kt +++ b/android/src/test/kotlin/com/project/starter/modules/AndroidApplicationPluginTest.kt @@ -21,7 +21,19 @@ internal class AndroidApplicationPluginTest : WithGradleProjectTest() { rootDirectory.apply { resolve("settings.gradle").writeText("""include ":module1", ":module2" """) - rootBuildScript = resolve("build.gradle") + rootBuildScript = resolve("build.gradle") { + writeText( + """ + plugins { + id('com.starter.config') + } + + commonConfig { + javaVersion = JavaVersion.VERSION_1_8 // workaround for http://issuetracker.google.com/issues/294137077 + } + """.trimIndent(), + ) + } module1Root = resolve("module1") { val buildScript = // language=groovy @@ -45,7 +57,7 @@ internal class AndroidApplicationPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent() @@ -83,7 +95,7 @@ internal class AndroidApplicationPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent(), diff --git a/android/src/test/kotlin/com/project/starter/modules/AndroidLibraryPluginTest.kt b/android/src/test/kotlin/com/project/starter/modules/AndroidLibraryPluginTest.kt index d44b5f26..0ba288fb 100644 --- a/android/src/test/kotlin/com/project/starter/modules/AndroidLibraryPluginTest.kt +++ b/android/src/test/kotlin/com/project/starter/modules/AndroidLibraryPluginTest.kt @@ -22,7 +22,19 @@ internal class AndroidLibraryPluginTest : WithGradleProjectTest() { mkdirs() resolve("settings.gradle").writeText("""include ":module1", ":module2" """) - rootBuildScript = resolve("build.gradle") + rootBuildScript = resolve("build.gradle") { + writeText( + """ + plugins { + id('com.starter.config') + } + + commonConfig { + javaVersion = JavaVersion.VERSION_1_8 // workaround for http://issuetracker.google.com/issues/294137077 + } + """.trimIndent(), + ) + } module1Root = resolve("module1") { val buildScript = // language=groovy @@ -46,7 +58,7 @@ internal class AndroidLibraryPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent() @@ -88,7 +100,7 @@ internal class AndroidLibraryPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent(), diff --git a/android/src/test/kotlin/com/project/starter/modules/tasks/ConfigurationCacheTest.kt b/android/src/test/kotlin/com/project/starter/modules/tasks/ConfigurationCacheTest.kt index bc297628..b35b7931 100644 --- a/android/src/test/kotlin/com/project/starter/modules/tasks/ConfigurationCacheTest.kt +++ b/android/src/test/kotlin/com/project/starter/modules/tasks/ConfigurationCacheTest.kt @@ -16,7 +16,19 @@ internal class ConfigurationCacheTest : WithGradleProjectTest() { rootDirectory.apply { resolve("settings.gradle").writeText("""include ':module1', ':module2' """) - resolve("build.gradle").writeText("") + resolve("build.gradle") { + writeText( + """ + plugins { + id('com.starter.config') + } + + commonConfig { + javaVersion = JavaVersion.VERSION_1_8 // workaround for http://issuetracker.google.com/issues/294137077 + } + """.trimIndent(), + ) + } androidModuleRoot = resolve("module1") { // language=groovy val script = diff --git a/android/src/test/kotlin/com/project/starter/quality/AndroidQualityPluginTest.kt b/android/src/test/kotlin/com/project/starter/quality/AndroidQualityPluginTest.kt index 0a8d563a..a1ec208e 100644 --- a/android/src/test/kotlin/com/project/starter/quality/AndroidQualityPluginTest.kt +++ b/android/src/test/kotlin/com/project/starter/quality/AndroidQualityPluginTest.kt @@ -103,7 +103,7 @@ internal class AndroidQualityPluginTest : WithGradleProjectTest() { } kotlin { - jvmToolchain(20) + jvmToolchain(21) } tasks.withType(JavaCompile).configureEach { diff --git a/build.gradle b/build.gradle index 8a87e86d..fbab3019 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ allprojects { } } kotlin { - jvmToolchain(20) + jvmToolchain(21) } } tasks.withType(Test).configureEach { @@ -35,8 +35,9 @@ allprojects { pluginManager.withPlugin("java") { if (project.hasProperty("skipJarVersion")) { + def projectName = project.name tasks.named("jar") { - archiveFile.set(new File(project.buildDir, "libs/${project.name}.jar")) + archiveFile.set(layout.buildDirectory.map {it.file("libs/${projectName}.jar")}) } } } diff --git a/gradle/plugins/build.gradle b/gradle/plugins/build.gradle index e4ca2022..521fa854 100644 --- a/gradle/plugins/build.gradle +++ b/gradle/plugins/build.gradle @@ -12,7 +12,7 @@ dependencies { } kotlin { - jvmToolchain(20) + jvmToolchain(21) } def targetJavaVersion = JavaVersion.VERSION_11 diff --git a/jvm/src/test/kotlin/com/project/starter/modules/KotlinLibraryPluginTest.kt b/jvm/src/test/kotlin/com/project/starter/modules/KotlinLibraryPluginTest.kt index 21ccb38d..8b9e0d37 100644 --- a/jvm/src/test/kotlin/com/project/starter/modules/KotlinLibraryPluginTest.kt +++ b/jvm/src/test/kotlin/com/project/starter/modules/KotlinLibraryPluginTest.kt @@ -35,7 +35,7 @@ internal class KotlinLibraryPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent(), @@ -57,7 +57,7 @@ internal class KotlinLibraryPluginTest : WithGradleProjectTest() { } dependencies { - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' } """.trimIndent(), diff --git a/quality/src/main/kotlin/com/project/starter/quality/plugins/QualityPlugin.kt b/quality/src/main/kotlin/com/project/starter/quality/plugins/QualityPlugin.kt index b668c1e2..e4e5d1bf 100644 --- a/quality/src/main/kotlin/com/project/starter/quality/plugins/QualityPlugin.kt +++ b/quality/src/main/kotlin/com/project/starter/quality/plugins/QualityPlugin.kt @@ -35,7 +35,7 @@ class QualityPlugin : Plugin { source += sourceSet.allSource } } - report.set(buildDir.resolve("reports/issue_comments.txt")) + report.set(layout.buildDirectory.map { it.file("reports/issue_comments.txt") }) githubToken.set(provider { properties["GITHUB_TOKEN"]?.toString() }) } onAndroid { diff --git a/quality/src/test/kotlin/com/project/starter/quality/QualityPluginTest.kt b/quality/src/test/kotlin/com/project/starter/quality/QualityPluginTest.kt index 33170882..6807488c 100644 --- a/quality/src/test/kotlin/com/project/starter/quality/QualityPluginTest.kt +++ b/quality/src/test/kotlin/com/project/starter/quality/QualityPluginTest.kt @@ -91,7 +91,7 @@ internal class QualityPluginTest : WithGradleProjectTest() { } kotlin { - jvmToolchain(20) + jvmToolchain(21) } def targetJavaVersion = JavaVersion.VERSION_11