diff --git a/build-tools/build.gradle b/build-tools/build.gradle index 7dd1feac..35da8c2a 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("recyclerViewDivider.warningsAsErrors") -tasks.withType(KotlinCompile) { +tasks.withType(KotlinCompile).configureEach { compilerOptions.allWarningsAsErrors = Boolean.valueOf(warningsAsErrors) } diff --git a/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/AndroidCoveragePlugin.kt b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/AndroidCoveragePlugin.kt index 2180b35e..ae289822 100644 --- a/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/AndroidCoveragePlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/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,13 @@ 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}") + fileTree() { + + } + 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 +71,7 @@ class AndroidCoveragePlugin : Plugin { } } + @Suppress("UnstableApiUsage") private fun AndroidCommonExtension.fixRobolectricCoverage() { testOptions.unitTests.all { test -> test.extensions.configure(JacocoTaskExtension::class.java) { @@ -78,7 +83,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/recyclerviewdivider/buildtools/DeployPlugin.kt b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/DeployPlugin.kt index d7a6b960..8c454c2d 100644 --- a/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/DeployPlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/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/recyclerviewdivider/buildtools/SourceSets.kt b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/SourceSets.kt index f879ff8a..d264c945 100644 --- a/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/SourceSets.kt +++ b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/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/recyclerviewdivider/buildtools/WithAndroidPlugin.kt b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/WithAndroidPlugin.kt index 53d39f83..65592dd5 100644 --- a/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/buildtools/WithAndroidPlugin.kt +++ b/build-tools/src/main/kotlin/com/fondesa/recyclerviewdivider/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