Skip to content

Commit

Permalink
Update dependency gradle to v8.4 (#376)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
renovate[bot] and fondesa authored Oct 11, 2023
1 parent 0dff95f commit a1b8988
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ 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

/**
* Enables the unit tests coverage in an Android project.
*/
@Suppress("UnstableApiUsage")
class AndroidCoveragePlugin : Plugin<Project> {
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()
Expand All @@ -54,10 +55,10 @@ class AndroidCoveragePlugin : Plugin<Project> {
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)
}
Expand All @@ -67,6 +68,7 @@ class AndroidCoveragePlugin : Plugin<Project> {
}
}

@Suppress("UnstableApiUsage")
private fun AndroidCommonExtension.fixRobolectricCoverage() {
testOptions.unitTests.all { test ->
test.extensions.configure(JacocoTaskExtension::class.java) {
Expand All @@ -78,7 +80,7 @@ class AndroidCoveragePlugin : Plugin<Project> {
}
}

private fun Project.fileTreeOf(dir: String): FileTree = fileTree(mapOf("dir" to dir, "excludes" to COVERAGE_EXCLUSIONS))
private fun Project.fileTreeOf(dir: Provider<Directory>): FileTree = fileTree(mapOf("dir" to dir, "excludes" to COVERAGE_EXCLUSIONS))

companion object {
private const val JACOCO_VERSION = "0.8.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DeployPlugin : Plugin<Project> {
): TaskProvider<Copy> {
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)
}
Expand All @@ -98,9 +98,9 @@ class DeployPlugin : Plugin<Project> {
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")
)
}
}
Expand All @@ -119,7 +119,6 @@ class DeployPlugin : Plugin<Project> {
}
}

@Suppress("UnstableApiUsage")
private fun Project.configureMavenPublish() {
extensions.configure(MavenPublishBaseExtension::class.java) { mavenPublish ->
mavenPublish.publishToMavenCentral()
Expand All @@ -135,7 +134,6 @@ class DeployPlugin : Plugin<Project> {
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())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> {
val buildType = requireNotNull(buildType) { "The build type is required." }
val sourceSets = mutableSetOf("main", buildType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -43,15 +39,13 @@ 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<AndroidApplicationExtension>().config() }
}

/**
* 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<AndroidLibraryExtension>().config() }
}
Expand All @@ -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 <reified T : AndroidCommonExtension> Project.androidPluginExtension() = extensions.getByType(T::class.java)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a1b8988

Please sign in to comment.