Skip to content

Commit fda5e8e

Browse files
authored
chore: migration to KTS (#1432)
* chore: migrated to KTS * chore: added release file * chore: updated .gitignore * chore: added headers * chore: header * chore: header
1 parent d915323 commit fda5e8e

12 files changed

+314
-242
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ project.properties
1111
.DS_Store
1212
.java-version
1313
secrets.properties
14+
.kotlin

.releaserc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ plugins:
77
- - "@google/semantic-release-replace-plugin"
88
- replacements:
99
- files:
10-
- "build.gradle"
10+
- "build.gradle.kts"
1111
from: "\\bversion = '.*'"
1212
to: "version = '${nextRelease.version}'"
1313
- files:
14-
- "build.gradle"
14+
- "build.gradle.kts"
1515
from: "com.google.maps.android:android-maps-utils:([0-9]+).([0-9]+).([0-9]+)"
1616
to: "com.google.maps.android:android-maps-utils:${nextRelease.version}'"
1717
- files:
@@ -23,7 +23,7 @@ plugins:
2323
publishCmd: "./gradlew publish --warn --stacktrace"
2424
- - "@semantic-release/git"
2525
- assets:
26-
- "build.gradle"
26+
- "build.gradle.kts"
2727
- "*.md"
2828
- "@semantic-release/github"
2929
options:

build-logic/.gitignore

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

build-logic/settings.gradle.kts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2024 Google LLC
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+
dependencyResolutionManagement {
18+
repositories {
19+
google()
20+
mavenCentral()
21+
}
22+
versionCatalogs {
23+
create("libs") {
24+
from(files("../gradle/libs.versions.toml"))
25+
}
26+
}
27+
}
28+
29+
rootProject.name = "build-logic"
30+
include(":convention")

0 commit comments

Comments
 (0)