From a1b898847e1e606b607f0ae827c6ee9689611145 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 21:02:06 +0200 Subject: [PATCH] Update dependency gradle to v8.4 (#376) * Update dependency gradle to v8.4 * Fix build issues for Gradle 8.x --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Giorgio Antonioli --- build-tools/build.gradle | 2 +- .../buildtools/AndroidCoveragePlugin.kt | 14 ++++++++------ .../kpermissions/buildtools/DeployPlugin.kt | 10 ++++------ .../fondesa/kpermissions/buildtools/SourceSets.kt | 1 - .../kpermissions/buildtools/WithAndroidPlugin.kt | 7 ------- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/build-tools/build.gradle b/build-tools/build.gradle index 0edc19d5..e383c9e6 100644 --- a/build-tools/build.gradle +++ b/build-tools/build.gradle @@ -33,7 +33,7 @@ apply plugin: "org.jlleitschuh.gradle.ktlint" kotlin.jvmToolchain(11) def warningsAsErrors = getProperty("kpermissions.warningsAsErrors") -tasks.withType(KotlinCompile) { +tasks.withType(KotlinCompile).configureEach { compilerOptions.allWarningsAsErrors = Boolean.valueOf(warningsAsErrors) } diff --git a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/AndroidCoveragePlugin.kt b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/AndroidCoveragePlugin.kt index e10524db..0dd3b903 100644 --- a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/AndroidCoveragePlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/AndroidCoveragePlugin.kt @@ -20,7 +20,9 @@ import com.android.build.api.variant.AndroidComponentsExtension import com.android.build.api.variant.ComponentIdentity import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.file.Directory import org.gradle.api.file.FileTree +import org.gradle.api.provider.Provider import org.gradle.testing.jacoco.plugins.JacocoPluginExtension import org.gradle.testing.jacoco.plugins.JacocoTaskExtension import org.gradle.testing.jacoco.tasks.JacocoReport @@ -28,14 +30,13 @@ import org.gradle.testing.jacoco.tasks.JacocoReport /** * Enables the unit tests coverage in an Android project. */ -@Suppress("UnstableApiUsage") class AndroidCoveragePlugin : Plugin { override fun apply(project: Project) = with(project) { pluginManager.apply("jacoco") extensions.configure(JacocoPluginExtension::class.java) { it.toolVersion = JACOCO_VERSION - it.reportsDirectory.set(file("$buildDir/coverageReport")) + it.reportsDirectory.set(layout.buildDirectory.dir("coverageReport")) } withAndroidPlugin { fixRobolectricCoverage() @@ -54,10 +55,10 @@ class AndroidCoveragePlugin : Plugin { xml.required.set(true) csv.required.set(false) } - val javaClassDirectories = fileTreeOf("$buildDir/intermediates/javac/${variant.name}/classes") - val kotlinClassDirectories = fileTreeOf("$buildDir/tmp/kotlin-classes/${variant.name}") + val javaClassDirectories = fileTreeOf(layout.buildDirectory.dir("intermediates/javac/${variant.name}/classes")) + val kotlinClassDirectories = fileTreeOf(layout.buildDirectory.dir("tmp/kotlin-classes/${variant.name}")) coverageTask.classDirectories.from(javaClassDirectories, kotlinClassDirectories) - coverageTask.executionData.from("$buildDir/jacoco/$testTaskName.exec") + coverageTask.executionData.from(layout.buildDirectory.file("jacoco/$testTaskName.exec")) variant.sourceSets(this).forEach { sourceSet -> coverageTask.sourceDirectories.from(sourceSet) } @@ -67,6 +68,7 @@ class AndroidCoveragePlugin : Plugin { } } + @Suppress("UnstableApiUsage") private fun AndroidCommonExtension.fixRobolectricCoverage() { testOptions.unitTests.all { test -> test.extensions.configure(JacocoTaskExtension::class.java) { @@ -78,7 +80,7 @@ class AndroidCoveragePlugin : Plugin { } } - private fun Project.fileTreeOf(dir: String): FileTree = fileTree(mapOf("dir" to dir, "excludes" to COVERAGE_EXCLUSIONS)) + private fun Project.fileTreeOf(dir: Provider): FileTree = fileTree(mapOf("dir" to dir, "excludes" to COVERAGE_EXCLUSIONS)) companion object { private const val JACOCO_VERSION = "0.8.7" diff --git a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/DeployPlugin.kt b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/DeployPlugin.kt index cb8b1ace..be67f00b 100644 --- a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/DeployPlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/DeployPlugin.kt @@ -85,7 +85,7 @@ class DeployPlugin : Plugin { ): TaskProvider { val copyTaskName = "copy${sourceTaskName.replaceFirstChar { it.uppercase() }}" return tasks.register(copyTaskName, Copy::class.java) { copyTask -> - copyTask.into("$buildDir/libs") + copyTask.into(layout.buildDirectory.dir("libs")) copyTask.rename { outputName } copyTask.dependsOn(sourceTaskName) } @@ -98,9 +98,9 @@ class DeployPlugin : Plugin { private fun Project.configureGitHubReleaseExtension() { rootProject.extensions.configure(GithubReleaseExtension::class.java) { gitHubRelease -> gitHubRelease.releaseAssets.from( - "$buildDir/outputs/aar/$archiveName.aar", - "$buildDir/libs/$archiveName-javadoc.jar", - "$buildDir/libs/$archiveName-sources.jar" + layout.buildDirectory.file("outputs/aar/$archiveName.aar"), + layout.buildDirectory.file("libs/$archiveName-javadoc.jar"), + layout.buildDirectory.file("libs/$archiveName-sources.jar") ) } } @@ -119,7 +119,6 @@ class DeployPlugin : Plugin { } } - @Suppress("UnstableApiUsage") private fun Project.configureMavenPublish() { extensions.configure(MavenPublishBaseExtension::class.java) { mavenPublish -> mavenPublish.publishToMavenCentral() @@ -135,7 +134,6 @@ class DeployPlugin : Plugin { val signingKey = findProperty("signingKey") ?: return@configure // Populated from the environment variable ORG_GRADLE_PROJECT_signingPassword. val signingPassword = findProperty("signingPassword") ?: return@configure - @Suppress("UnstableApiUsage") signing.useInMemoryPgpKeys(signingKeyId.toString(), signingKey.toString(), signingPassword.toString()) } } diff --git a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/SourceSets.kt b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/SourceSets.kt index ed6323d9..62fd6272 100644 --- a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/SourceSets.kt +++ b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/SourceSets.kt @@ -24,7 +24,6 @@ import java.io.File * Gets the source sets from the given variant. * The source sets are returned as files. */ -@Suppress("UnstableApiUsage") internal fun ComponentIdentity.sourceSets(project: Project): Collection { val buildType = requireNotNull(buildType) { "The build type is required." } val sourceSets = mutableSetOf("main", buildType) diff --git a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/WithAndroidPlugin.kt b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/WithAndroidPlugin.kt index c399a7a9..141fb10c 100644 --- a/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/WithAndroidPlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/kpermissions/buildtools/WithAndroidPlugin.kt @@ -22,19 +22,15 @@ import com.android.build.api.dsl.LibraryExtension import org.gradle.api.Project import com.android.build.gradle.LibraryExtension as LegacyLibraryExtension -@Suppress("UnstableApiUsage") internal typealias AndroidCommonExtension = CommonExtension<*, *, *, *> -@Suppress("UnstableApiUsage") internal typealias AndroidApplicationExtension = ApplicationExtension -@Suppress("UnstableApiUsage") internal typealias AndroidLibraryExtension = LibraryExtension /** * Executes the given action when an Android plugin is applied using the new API. */ -@Suppress("UnstableApiUsage") internal inline fun Project.withAndroidPlugin(crossinline config: AndroidCommonExtension.() -> Unit) { withAndroidApplicationPlugin(config) withAndroidLibraryPlugin(config) @@ -43,7 +39,6 @@ internal inline fun Project.withAndroidPlugin(crossinline config: AndroidCommonE /** * Executes the given action when an Android application plugin is applied using the new API. */ -@Suppress("UnstableApiUsage") internal inline fun Project.withAndroidApplicationPlugin(crossinline config: AndroidApplicationExtension.() -> Unit) { pluginManager.withPlugin("com.android.application") { androidPluginExtension().config() } } @@ -51,7 +46,6 @@ internal inline fun Project.withAndroidApplicationPlugin(crossinline config: And /** * Executes the given action when an Android library plugin is applied using the new API. */ -@Suppress("UnstableApiUsage") internal inline fun Project.withAndroidLibraryPlugin(crossinline config: AndroidLibraryExtension.() -> Unit) { pluginManager.withPlugin("com.android.library") { androidPluginExtension().config() } } @@ -63,5 +57,4 @@ internal inline fun Project.withAndroidLibraryLegacyPlugin(crossinline config: L pluginManager.withPlugin("com.android.library") { extensions.getByType(LegacyLibraryExtension::class.java).config() } } -@Suppress("UnstableApiUsage") private inline fun Project.androidPluginExtension() = extensions.getByType(T::class.java) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8707e8b5..309b4e18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists