Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Project> {
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<JacocoPluginExtension> {
toolVersion = "0.8.7"
toolVersion = "0.8.11" // Compatible with newer JDKs
}

tasks.withType<Test>().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<JacocoReport>("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<MavenPublishBaseExtension> {
configure(
AndroidSingleVariantLibrary(
Expand All @@ -48,8 +67,10 @@ class PublishingConventionPlugin : Plugin<Project> {
publishJavadocJar = true
)
)

publishToMavenCentral()
signAllPublications()

pom {
name.set(project.name)
description.set("Jetpack Compose components for the Places SDK for Android")
Expand All @@ -66,17 +87,17 @@ class PublishingConventionPlugin : Plugin<Project> {
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")
}
}
}
}
}
}
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
mavenCentralAutomaticRelease=false
android.builtInKotlin=false
android.newDsl=false
4 changes: 1 addition & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[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"
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"
Expand Down Expand Up @@ -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" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-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
Expand Down
5 changes: 1 addition & 4 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions places-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ android {

buildTypes {
release {
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down
Loading