diff --git a/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt b/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt index df909c8..01493cf 100644 --- a/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt @@ -3,43 +3,62 @@ import com.vanniktech.maven.publish.AndroidSingleVariantLibrary import com.vanniktech.maven.publish.MavenPublishBaseExtension import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.withType +import org.gradle.kotlin.dsl.* import org.gradle.testing.jacoco.plugins.JacocoPluginExtension +import org.gradle.api.tasks.testing.Test import org.gradle.testing.jacoco.plugins.JacocoTaskExtension +import org.gradle.testing.jacoco.tasks.JacocoReport class PublishingConventionPlugin : Plugin { override fun apply(project: Project) { project.run { + applyPlugins() configureJacoco() - configureMavenPublishing() + configureVanniktechPublishing() } } private fun Project.applyPlugins() { apply(plugin = "com.android.library") - apply(plugin = "com.mxalbert.gradle.jacoco-android") apply(plugin = "org.jetbrains.dokka") + apply(plugin = "org.gradle.jacoco") apply(plugin = "com.vanniktech.maven.publish") } private fun Project.configureJacoco() { configure { - toolVersion = "0.8.7" + toolVersion = "0.8.11" // Compatible with newer JDKs } - tasks.withType().configureEach { - extensions.configure(JacocoTaskExtension::class.java) { - isIncludeNoLocationClasses = true - excludes = listOf("jdk.internal.*") - } + // AGP 9.0+ built-in Jacoco support or manual configuration. + // We create a "jacocoTestReport" task to match the CI workflow. + + tasks.register("jacocoTestReport") { + // Dependencies + dependsOn("testDebugUnitTest") + + reports { + xml.required.set(true) + html.required.set(true) + } + + // Source directories + val mainSrc = "${layout.projectDirectory}/src/main/java" + sourceDirectories.setFrom(files(mainSrc)) + + // Class directories - we need to point to where Kotlin compiles to + val debugTree = fileTree("${layout.buildDirectory.get()}/tmp/kotlin-classes/debug") + classDirectories.setFrom(files(debugTree)) + + // Execution data from the unit test task + executionData.setFrom(fileTree(layout.buildDirectory.get()) { + include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec") + }) } } - private fun Project.configureMavenPublishing() { + private fun Project.configureVanniktechPublishing() { extensions.configure { configure( AndroidSingleVariantLibrary( @@ -48,8 +67,10 @@ class PublishingConventionPlugin : Plugin { publishJavadocJar = true ) ) + publishToMavenCentral() signAllPublications() + pom { name.set(project.name) description.set("Jetpack Compose components for the Places SDK for Android") @@ -66,17 +87,17 @@ class PublishingConventionPlugin : Plugin { developerConnection.set("scm:git@github.com:googlemaps/android-places-compose.git") url.set("https://github.com/googlemaps/android-places-compose") } - organization { - name.set("Google Inc") - url.set("http://developers.google.com/maps") - } developers { developer { id.set("google") name.set("Google Inc.") } } + organization { + name.set("Google Inc") + url.set("http://developers.google.com/maps") + } } } } -} +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index bbcb78e..2895b69 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { dependencies { - classpath(libs.jacoco.android.plugin) } } plugins { diff --git a/gradle.properties b/gradle.properties index 554b2a4..ffec2b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,4 +31,6 @@ mavenCentralPassword= # Add a property to enable automatic release to Maven Central (optional, but good for CI) # If true, publishToMavenCentral will also close and release the staging repository -mavenCentralAutomaticRelease=false \ No newline at end of file +mavenCentralAutomaticRelease=false +android.builtInKotlin=false +android.newDsl=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fee740a..9d2eb8d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] accompanistPermissions = "0.37.3" activityCompose = "1.12.1" -agp = "8.13.1" +agp = "9.1.0" appcompat = "1.7.1" composeBom = "2025.12.00" coreKtx = "1.17.0" @@ -9,7 +9,6 @@ dokka = "2.1.0" espressoCore = "3.7.0" gson = "2.13.2" hiltVersion = "2.57.2" -jacoco-plugin = "0.2.1" junit = "4.13.2" junitVersion = "1.3.0" kotlin = "2.2.21" @@ -60,7 +59,6 @@ google-truth = { group = "com.google.truth", name = "truth", version.ref = "trut gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hiltVersion" } hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltVersion" } -jacoco-android-plugin = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-plugin", version.require = "0.2.1" } junit = { group = "junit", name = "junit", version.ref = "junit" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlinReflect" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60..d997cfc 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2a84e18..c61a118 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-9.0.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index ef07e01..739907d 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index db3a6ac..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/places-compose/build.gradle.kts b/places-compose/build.gradle.kts index dee78f2..90b0164 100644 --- a/places-compose/build.gradle.kts +++ b/places-compose/build.gradle.kts @@ -23,6 +23,8 @@ android { buildTypes { release { + enableUnitTestCoverage = true + enableAndroidTestCoverage = true isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"),