From 3f382ac05ac689d9acbc34277ca6db588b6a651e Mon Sep 17 00:00:00 2001 From: Christian Schmitz Date: Wed, 3 Jan 2024 11:32:58 +0100 Subject: [PATCH] build: configure Gradle with conventions --- astring/bom/build.gradle | 2 +- astring/build.gradle | 2 +- build.gradle | 50 +------------------- compose/build.gradle | 2 +- gradle/conventions/build.gradle | 5 ++ gradle/conventions/src/android-kotlin.gradle | 22 +++++++++ gradle/conventions/src/nexus-publish.gradle | 22 +++++++++ gradle/libs.versions.toml | 2 +- settings.gradle | 2 + widget/appcompat/build.gradle | 2 +- widget/binding/build.gradle | 2 +- widget/core/build.gradle | 2 +- widget/material/build.gradle | 2 +- 13 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 gradle/conventions/build.gradle create mode 100644 gradle/conventions/src/android-kotlin.gradle create mode 100644 gradle/conventions/src/nexus-publish.gradle diff --git a/astring/bom/build.gradle b/astring/bom/build.gradle index 1a96b66..9847b6f 100644 --- a/astring/bom/build.gradle +++ b/astring/bom/build.gradle @@ -1,4 +1,4 @@ plugins { id 'xyz.tynn.convention.bom' - id 'maven-publish' + id 'nexus-publish' } diff --git a/astring/build.gradle b/astring/build.gradle index 204e901..8e01695 100644 --- a/astring/build.gradle +++ b/astring/build.gradle @@ -1,6 +1,6 @@ plugins { alias libs.plugins.android - id 'maven-publish' + id 'nexus-publish' } android { diff --git a/build.gradle b/build.gradle index 4a330cc..3c5f944 100644 --- a/build.gradle +++ b/build.gradle @@ -4,57 +4,9 @@ plugins { alias libs.plugins.kotlin.kapt apply false alias libs.plugins.conventions alias libs.plugins.publish + id 'android-kotlin' } allprojects { group = 'xyz.tynn.astring' } - -subprojects { - pluginManager.withPlugin('xyz.tynn.convention.android') { - apply plugin: libs.plugins.kotlin.asProvider().get().pluginId - - java.toolchain.languageVersion.set JavaLanguageVersion.of(11) - - kotlin.explicitApi() - - android.kotlinOptions { - afterEvaluate { - if (!findProperty('isKotlinOnly')) freeCompilerArgs += [ - '-Xno-call-assertions', - '-Xno-param-assertions', - '-Xno-receiver-assertions', - ] - } - } - - dependencies { - testImplementation libs.bundles.testing - } - } - - pluginManager.withPlugin('maven-publish') { - publishing.publications.all { - pom { - description = 'A context aware string abstraction for Android' - developers { - developer { - id = 'tynn' - name = 'Christian Schmitz' - email = 'christian@tynn.xyz' - } - } - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - } - } - } -} - -nexusPublishing.repositories.sonatype { - nexusUrl.set uri('https://s01.oss.sonatype.org/service/local/') -} diff --git a/compose/build.gradle b/compose/build.gradle index cbf301b..fefb419 100644 --- a/compose/build.gradle +++ b/compose/build.gradle @@ -1,6 +1,6 @@ plugins { alias libs.plugins.android - id 'maven-publish' + id 'nexus-publish' } ext.isKotlinOnly = true diff --git a/gradle/conventions/build.gradle b/gradle/conventions/build.gradle new file mode 100644 index 0000000..8ac68e1 --- /dev/null +++ b/gradle/conventions/build.gradle @@ -0,0 +1,5 @@ +plugins { + id 'groovy-gradle-plugin' +} + +sourceSets.main.groovy.srcDirs 'src' diff --git a/gradle/conventions/src/android-kotlin.gradle b/gradle/conventions/src/android-kotlin.gradle new file mode 100644 index 0000000..4f589d0 --- /dev/null +++ b/gradle/conventions/src/android-kotlin.gradle @@ -0,0 +1,22 @@ +if (parent == null) subprojects { + pluginManager.withPlugin('xyz.tynn.convention.android') { + project.apply plugin: libs.plugins.kotlin.asProvider().get().pluginId + + kotlin.explicitApi() + java.toolchain.languageVersion.set JavaLanguageVersion.of(11) + + android.kotlinOptions { + afterEvaluate { + if (!findProperty('isKotlinOnly')) freeCompilerArgs += [ + '-Xno-call-assertions', + '-Xno-param-assertions', + '-Xno-receiver-assertions', + ] + } + } + + dependencies { + testImplementation libs.bundles.testing + } + } +} diff --git a/gradle/conventions/src/nexus-publish.gradle b/gradle/conventions/src/nexus-publish.gradle new file mode 100644 index 0000000..ed5f8d3 --- /dev/null +++ b/gradle/conventions/src/nexus-publish.gradle @@ -0,0 +1,22 @@ +plugins { + id 'maven-publish' +} + +publishing.publications.all { + pom { + description = 'A context aware string abstraction for Android' + developers { + developer { + id = 'tynn' + name = 'Christian Schmitz' + email = 'christian@tynn.xyz' + } + } + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e1609d1..29e5433 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ kotlin = "1.9.22" [plugins] android = { id = "com.android.library", version.ref = "android" } -conventions = "xyz.tynn.convention.project:0.0.4" +conventions = "xyz.tynn.convention.project:0.0.5" kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } publish = "io.github.gradle-nexus.publish-plugin:1.3.0" diff --git a/settings.gradle b/settings.gradle index bb7592c..8f934de 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,6 +3,8 @@ pluginManagement { gradlePluginPortal() google() } + + includeBuild 'gradle/conventions' } dependencyResolutionManagement { diff --git a/widget/appcompat/build.gradle b/widget/appcompat/build.gradle index 67c16e4..133da64 100644 --- a/widget/appcompat/build.gradle +++ b/widget/appcompat/build.gradle @@ -1,6 +1,6 @@ plugins { alias libs.plugins.android - id 'maven-publish' + id 'nexus-publish' } dependencies { diff --git a/widget/binding/build.gradle b/widget/binding/build.gradle index 06e1729..fb01667 100644 --- a/widget/binding/build.gradle +++ b/widget/binding/build.gradle @@ -1,7 +1,7 @@ plugins { alias libs.plugins.android alias libs.plugins.kotlin.kapt - id 'maven-publish' + id 'nexus-publish' } android { diff --git a/widget/core/build.gradle b/widget/core/build.gradle index e25d12a..63530f8 100644 --- a/widget/core/build.gradle +++ b/widget/core/build.gradle @@ -1,6 +1,6 @@ plugins { alias libs.plugins.android - id 'maven-publish' + id 'nexus-publish' } android { diff --git a/widget/material/build.gradle b/widget/material/build.gradle index 35c2635..0bcb2b7 100644 --- a/widget/material/build.gradle +++ b/widget/material/build.gradle @@ -1,6 +1,6 @@ plugins { alias libs.plugins.android - id 'maven-publish' + id 'nexus-publish' } android {