# HG changeset patch # User Da Risk # Date 1669929638 14400 # Node ID f165a9538ee34a25825ee92180d834e1649c4dd5 # Parent 0e233781410b2e7a6261dfb2f3d1bdca53f4c633 build: improve maven publication diff -r 0e233781410b -r f165a9538ee3 buildSrc/src/main/kotlin/VersionAlignment.kt --- a/buildSrc/src/main/kotlin/VersionAlignment.kt Tue Nov 29 19:38:26 2022 -0400 +++ b/buildSrc/src/main/kotlin/VersionAlignment.kt Thu Dec 01 17:20:38 2022 -0400 @@ -50,8 +50,8 @@ open class AlignmentRule : SameGroupAlignmentRule(platformName, "com.google.dagger") } -fun DependencyHandler.enforcedDaggerPlatform(version: String): Dependency { - return enforcedPlatform("${components.getOrCreatePlatform(DaggerPlatform)}:$version") +fun DependencyHandler.daggerPlatform(version: String): Dependency { + return platform("${components.getOrCreatePlatform(DaggerPlatform)}:$version") } open class PlatformFactory( diff -r 0e233781410b -r f165a9538ee3 config/android-maven-publication.gradle --- a/config/android-maven-publication.gradle Tue Nov 29 19:38:26 2022 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Geekdroid is a utility library for development on the Android - * Platform. - * - * Copyright (C) 2017-2022 by Frederic-Charles Barthelery. - * - * This file is part of Geekdroid. - * - * Geekdroid is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Geekdroid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Geekdroid. If not, see . - */ - -/** - * This configuration allows to publish android libraries into a maven repository. - * You need to define in your build.gradle the following variables : - * version = "1.0" // the version of your projects - * ext.artifactId="geny-widgets" // the maven artifact id - * Use ./gradlew tasks to see the name of the publishing tasks. - */ -if (plugins.hasPlugin("com.android.library")) { - - apply plugin: 'maven-publish' - - if (!project.ext.properties.containsKey("artifactId")) { - ext.artifactId = project.name - } - - publishing { - publications { - projectRelease(MavenPublication) { - artifactId project.artifactId - artifact "build/outputs/aar/${project.archivesBaseName}-release.aar" - } - - projectSnapshot(MavenPublication) { - artifactId project.artifactId - artifact "build/outputs/aar/${project.archivesBaseName}-debug.aar" - version getVersion() + "-SNAPSHOT" - } - } - } - - tasks.named("publishProjectReleasePublicationToMavenLocal") { - dependsOn "assembleRelease" - } - - tasks.named("publishProjectSnapshotPublicationToMavenLocal") { - dependsOn "assembleDebug" - } -} diff -r 0e233781410b -r f165a9538ee3 geekdroid-firebase/build.gradle.kts --- a/geekdroid-firebase/build.gradle.kts Tue Nov 29 19:38:26 2022 -0400 +++ b/geekdroid-firebase/build.gradle.kts Thu Dec 01 17:20:38 2022 -0400 @@ -8,9 +8,6 @@ `maven-publish` } -val archivesBaseName by extra("geekdroid-firebase") -val artifactId by extra (archivesBaseName) - android { val compileSdkInt: Int by rootProject.extra compileSdk = compileSdkInt @@ -33,13 +30,22 @@ abortOnError = false } + publishing { + singleVariant("release") { + withSourcesJar() + } + singleVariant("debug") { + withSourcesJar() + } + } + } dependencies { - implementation(enforcedPlatform(kotlin("bom"))) + implementation(platform(kotlin("bom"))) implementation(kotlin("stdlib-jdk8")) - implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")) + implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")) api("org.jetbrains.kotlinx:kotlinx-coroutines-core") api("org.jetbrains.kotlinx:kotlinx-coroutines-play-services") @@ -65,5 +71,39 @@ apply { from("$projectDir/../config/source-archive.gradle") - from("$projectDir/../config/android-maven-publication.gradle") } + +publishing { + publications { + val pomConfiguration: (MavenPom).() -> Unit = { + name.set("Geekdroid-Firebase") + description.set("An Android library used in various Android projects. ") + licenses { + license { + name.set("GPL-3.0-or-later") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + inceptionYear.set("2017") + } + + register("release") { + afterEvaluate { + from(components["release"]) + } + artifactId = "geekdroid-firebase" + pom(pomConfiguration) + } + + register("debugSnapshot") { + afterEvaluate { + from(components["debug"]) + } + artifactId = "geekdroid-firebase" + version = "$version-SNAPSHOT" + pom(pomConfiguration) + + } + } +} diff -r 0e233781410b -r f165a9538ee3 geekdroid/build.gradle.kts --- a/geekdroid/build.gradle.kts Tue Nov 29 19:38:26 2022 -0400 +++ b/geekdroid/build.gradle.kts Thu Dec 01 17:20:38 2022 -0400 @@ -20,7 +20,7 @@ * along with Geekdroid. If not, see . */ import com.geekorum.build.configureJavaVersion -import com.geekorum.build.enforcedDaggerPlatform +import com.geekorum.build.daggerPlatform plugins { id("com.android.library") @@ -31,8 +31,6 @@ `maven-publish` } -val archivesBaseName by extra("geekdroid") -val artifactId by extra (archivesBaseName) android { val compileSdkInt: Int by rootProject.extra @@ -60,6 +58,14 @@ enable = true } + publishing { + singleVariant("release") { + withSourcesJar() + } + singleVariant("debug") { + withSourcesJar() + } + } } dependencies { @@ -77,15 +83,15 @@ implementation("com.squareup.okhttp3:okhttp:4.10.0") val daggerVersion = "2.44.1" - implementation(enforcedDaggerPlatform(daggerVersion)) - kapt(enforcedDaggerPlatform(daggerVersion)) + implementation(daggerPlatform(daggerVersion)) + kapt(daggerPlatform(daggerVersion)) implementation("com.google.dagger:dagger:$daggerVersion") kapt("com.google.dagger:dagger-compiler:$daggerVersion") - implementation(enforcedPlatform(kotlin("bom"))) + implementation(platform(kotlin("bom"))) implementation(kotlin("stdlib-jdk8")) - implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")) + implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") implementation("androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1") @@ -102,5 +108,39 @@ apply { from("$projectDir/../config/source-archive.gradle") - from("$projectDir/../config/android-maven-publication.gradle") } + +publishing { + publications { + val pomConfiguration: (MavenPom).() -> Unit = { + name.set("Geekdroid") + description.set("An Android library used in various Android projects. ") + licenses { + license { + name.set("GPL-3.0-or-later") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + inceptionYear.set("2017") + } + + register("release") { + afterEvaluate { + from(components["release"]) + } + artifactId = "geekdroid" + pom(pomConfiguration) + } + + register("debugSnapshot") { + afterEvaluate { + from(components["debug"]) + } + artifactId = "geekdroid" + version = "$version-SNAPSHOT" + pom(pomConfiguration) + + } + } +}