Skip to content

Commit 39f2cfe

Browse files
committed
chore: migrated to KTS
1 parent 895085f commit 39f2cfe

File tree

10 files changed

+262
-239
lines changed

10 files changed

+262
-239
lines changed

build-logic/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*/build
2+
.gradle
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
google()
7+
mavenCentral()
8+
gradlePluginPortal()
9+
}
10+
11+
12+
dependencies {
13+
implementation(libs.kotlin.gradle.plugin)
14+
implementation(libs.gradle)
15+
implementation(libs.dokka.gradle.plugin)
16+
implementation(libs.org.jacoco.core)
17+
}
18+
19+
gradlePlugin {
20+
plugins {
21+
register("publishingConventionPlugin") {
22+
id = "android.maps.utils.PublishingConventionPlugin"
23+
implementationClass = "PublishingConventionPlugin"
24+
}
25+
}
26+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// buildSrc/src/main/kotlin/PublishingConventionPlugin.kt
2+
import org.gradle.api.Plugin
3+
import org.gradle.api.Project
4+
import org.gradle.api.publish.PublishingExtension
5+
import org.gradle.api.publish.maven.MavenPublication
6+
import org.gradle.kotlin.dsl.*
7+
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
8+
import org.gradle.api.tasks.testing.Test
9+
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
10+
import org.gradle.plugins.signing.SigningExtension
11+
import org.gradle.api.publish.maven.*
12+
13+
class PublishingConventionPlugin : Plugin<Project> {
14+
override fun apply(project: Project) {
15+
project.run {
16+
17+
applyPlugins()
18+
configureJacoco()
19+
configurePublishing()
20+
configureSigning()
21+
}
22+
}
23+
24+
private fun Project.applyPlugins() {
25+
apply(plugin = "com.android.library")
26+
apply(plugin = "com.mxalbert.gradle.jacoco-android")
27+
apply(plugin = "maven-publish")
28+
apply(plugin = "org.jetbrains.dokka")
29+
apply(plugin = "signing")
30+
}
31+
32+
private fun Project.configureJacoco() {
33+
configure<JacocoPluginExtension> {
34+
toolVersion = "0.8.7"
35+
36+
}
37+
38+
tasks.withType<Test>().configureEach {
39+
extensions.configure(JacocoTaskExtension::class.java) {
40+
isIncludeNoLocationClasses = true
41+
excludes = listOf("jdk.internal.*")
42+
}
43+
}
44+
}
45+
46+
private fun Project.configurePublishing() {
47+
extensions.configure<com.android.build.gradle.LibraryExtension> {
48+
publishing {
49+
singleVariant("release") {
50+
withSourcesJar()
51+
withJavadocJar()
52+
}
53+
}
54+
}
55+
extensions.configure<PublishingExtension> {
56+
publications {
57+
create<MavenPublication>("aar") {
58+
afterEvaluate {
59+
from(components["release"])
60+
}
61+
pom {
62+
name.set(project.name)
63+
description.set("Handy extensions to the Google Maps Android API.")
64+
url.set("https://github.com/googlemaps/android-maps-utils")
65+
scm {
66+
connection.set("scm:[email protected]:googlemaps/android-maps-utils.git")
67+
developerConnection.set("scm:[email protected]:googlemaps/android-maps-utils.git")
68+
url.set("scm:[email protected]:googlemaps/android-maps-utils.git")
69+
}
70+
licenses {
71+
license {
72+
name.set("The Apache Software License, Version 2.0")
73+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
74+
distribution.set("repo")
75+
}
76+
}
77+
organization {
78+
name.set("Google Inc")
79+
url.set("http://developers.google.com/maps")
80+
}
81+
developers {
82+
developer {
83+
name.set("Google Inc.")
84+
}
85+
}
86+
}
87+
}
88+
}
89+
repositories {
90+
maven {
91+
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
92+
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
93+
url = if (project.version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
94+
credentials {
95+
username = project.findProperty("sonatypeToken") as String?
96+
password = project.findProperty("sonatypeTokenPassword") as String?
97+
}
98+
}
99+
}
100+
}
101+
}
102+
103+
private fun Project.configureSigning() {
104+
configure<SigningExtension> {
105+
sign(extensions.getByType<PublishingExtension>().publications["aar"])
106+
}
107+
}
108+
}

build-logic/settings.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
dependencyResolutionManagement {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
versionCatalogs {
7+
create("libs") {
8+
from(files("../gradle/libs.versions.toml"))
9+
}
10+
}
11+
}
12+
13+
rootProject.name = "build-logic"
14+
include(":convention")

build.gradle

Lines changed: 0 additions & 185 deletions
This file was deleted.

build.gradle.kts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright 2024 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
buildscript {
18+
val kotlinVersion by extra(libs.versions.kotlin.get())
19+
20+
repositories {
21+
google()
22+
mavenCentral()
23+
}
24+
25+
dependencies {
26+
classpath(libs.gradle)
27+
classpath(libs.jacoco.android)
28+
classpath(libs.secrets.gradle.plugin)
29+
classpath(libs.kotlin.gradle.plugin)
30+
classpath(libs.dokka.gradle.plugin)
31+
}
32+
}
33+
34+
tasks.register<Delete>("clean") {
35+
delete(rootProject.buildDir)
36+
}
37+
38+
39+
allprojects {
40+
group = "com.google.maps.android"
41+
version = "3.9.0"
42+
val projectArtifactId = if (project.name == "library") {
43+
"android-maps-utils"
44+
} else {
45+
null
46+
}
47+
}

0 commit comments

Comments
 (0)