Skip to content

Commit

Permalink
chore: migration from Groovy to KTS (#580)
Browse files Browse the repository at this point in the history
* chore: migration from Groovy to KTS

* chore: first version compiling

* chore: added gitignore

* fix: removed files from gitignore

* chore: updated jacoco plugin

* chore: updated gitignore

* chore: a bit more refactoring, and added dependency-analysis plugin

* chore: evaluate after release

* chore: removed targetSdk from libraries

* chore: removed item from catalogue

* chore: increased version

* fix: fix release script to modify the right file with the new version

* fix: removed unused versions
  • Loading branch information
kikoso authored Jun 11, 2024
1 parent 06d807d commit 603dd17
Show file tree
Hide file tree
Showing 21 changed files with 449 additions and 386 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/instrumentation-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Jacoco Report to PR
id: jacoco
uses: madrapps/[email protected]
uses: madrapps/[email protected].1
with:
paths: |
${{ github.workspace }}/app/build/reports/coverage/androidTest/debug/connected/report.xml
Expand Down
4 changes: 2 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins:
- - "@google/semantic-release-replace-plugin"
- replacements:
- files:
- "build.gradle"
from: "\\bversion = '.*'"
- "build.gradle.kts"
from: "\\bversion = \".*\""
to: "version = '${nextRelease.version}'"
- files:
- "README.md"
Expand Down
81 changes: 0 additions & 81 deletions app/build.gradle

This file was deleted.

79 changes: 79 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
alias(libs.plugins.compose.compiler)
}

android {
buildTypes {
getByName("debug") {
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
}
getByName("release") {
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
}
}

namespace = "com.google.maps.android.compose"
compileSdk = 34

defaultConfig {
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

buildFeatures {
buildConfig = true
compose = true
}

kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}

dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.activity)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.material)
implementation(libs.kotlin)
implementation(libs.material)
implementation(libs.androidx.compose.ui.preview.tooling)
debugImplementation(libs.androidx.compose.ui.tooling)

androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.espresso)
androidTestImplementation(libs.androidx.test.junit.ktx)
androidTestImplementation(libs.test.junit)
androidTestImplementation(libs.androidx.test.compose.ui)
androidTestImplementation(libs.coroutines)

// Instead of the lines below, regular apps would load these libraries from Maven according to
// the README installation instructions
implementation(project(":maps-compose"))
implementation(project(":maps-compose-widgets"))
implementation(project(":maps-compose-utils"))
}

secrets {
// To add your Maps API key to this project:
// 1. Add this line to your local.properties file, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
defaultPropertiesFileName = "local.defaults.properties"
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
2 changes: 2 additions & 0 deletions build-logic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/build
.gradle
26 changes: 26 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
`kotlin-dsl`
}

repositories {
google()
mavenCentral()
gradlePluginPortal()
}


dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.android.gradle.plugin)
implementation(libs.dokka.plugin)
implementation(libs.org.jacoco.core)
}

gradlePlugin {
plugins {
register("publishingConventionPlugin") {
id = "android.maps.compose.PublishingConventionPlugin"
implementationClass = "PublishingConventionPlugin"
}
}
}
108 changes: 108 additions & 0 deletions build-logic/convention/src/main/kotlin/PublishingConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// buildSrc/src/main/kotlin/PublishingConventionPlugin.kt
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
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.plugins.signing.SigningExtension
import org.gradle.api.publish.maven.*

class PublishingConventionPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.run {

applyPlugins()
configureJacoco()
configurePublishing()
configureSigning()
}
}

private fun Project.applyPlugins() {
apply(plugin = "com.android.library")
apply(plugin = "com.mxalbert.gradle.jacoco-android")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "signing")
}

private fun Project.configureJacoco() {
configure<JacocoPluginExtension> {
toolVersion = "0.8.7"

}

tasks.withType<Test>().configureEach {
extensions.configure(JacocoTaskExtension::class.java) {
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
}
}

private fun Project.configurePublishing() {
extensions.configure<com.android.build.gradle.LibraryExtension> {
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}
extensions.configure<PublishingExtension> {
publications {
create<MavenPublication>("aar") {
afterEvaluate {
from(components["release"])
}
pom {
name.set(project.name)
description.set("Jetpack Compose components for the Maps SDK for Android")
url.set("https://github.com/googlemaps/android-maps-compose")
scm {
connection.set("scm:[email protected]:googlemaps/android-maps-compose.git")
developerConnection.set("scm:[email protected]:googlemaps/android-maps-compose.git")
url.set("https://github.com/googlemaps/android-maps-compose")
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
organization {
name.set("Google Inc")
url.set("http://developers.google.com/maps")
}
developers {
developer {
name.set("Google Inc.")
}
}
}
}
}
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (project.version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = project.findProperty("sonatypeUsername") as String?
password = project.findProperty("sonatypePassword") as String?
}
}
}
}
}

private fun Project.configureSigning() {
configure<SigningExtension> {
sign(extensions.getByType<PublishingExtension>().publications["aar"])
}
}
}
14 changes: 14 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
include(":convention")
Loading

0 comments on commit 603dd17

Please sign in to comment.