# HG changeset patch # User Da Risk # Date 1746146468 14400 # Node ID f6133d9381b2ce3d11983e92618fe1d7e11e69ff # Parent 581f0b7dc09d22115e93cb27ddf47b5ba453d4e6 build: configure maven publishing using gradle maven publish plugin diff -r 581f0b7dc09d -r f6133d9381b2 buildSrc/build.gradle.kts --- a/buildSrc/build.gradle.kts Mon Apr 28 13:35:53 2025 -0400 +++ b/buildSrc/build.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -66,7 +66,7 @@ implementation(libs.plugins.com.android.application.gav()) implementation(libs.plugins.org.jetbrains.kotlin.android.gav()) implementation("gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1") - + implementation(libs.plugins.com.vanniktech.maven.publish.gav()) implementation("com.geekorum.gradle.avdl:plugin:0.0.3") implementation("com.geekorum.gradle.avdl:flydroid:0.0.3") } diff -r 581f0b7dc09d -r f6133d9381b2 buildSrc/src/main/kotlin/MavenPublish.kt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildSrc/src/main/kotlin/MavenPublish.kt Thu May 01 20:41:08 2025 -0400 @@ -0,0 +1,68 @@ +/* + * AboutOss is a utility library to retrieve and display + * opensource licenses in Android applications. + * + * Copyright (C) 2023-2025 by Frederic-Charles Barthelery. + * + * This file is part of AboutOss. + * + * AboutOss 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. + * + * AboutOss 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 AboutOss. If not, see . + */ +package com.geekorum.build + +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.MavenPublishPlugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure + +internal fun Project.configureMavenPublish() { + apply() + + configure() { +// TODO +// publishToMavenCentral(SonatypeHost.DEFAULT) +// signAllPublications() + + // default pom info. each field can be overridden in specific project + pom { + name.set(project.name) + description.set("A library to retrieve and display opensource licenses in applications") + inceptionYear.set("2023") + val githubUrl = "https://github.com/fbarthelery/AboutOss/" + url.set(githubUrl) + scm { + url.set(githubUrl) + connection.set("scm:git:$githubUrl.git") + } + + licenses { + license { + name.set("GPL-3.0-or-later") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + + developers { + developer { + id.set("da_risk") + name.set("Frédéric Barthéléry") + email.set("da_risk@geekorum.com") + } + } + } + } + +} \ No newline at end of file diff -r 581f0b7dc09d -r f6133d9381b2 buildSrc/src/main/kotlin/maven-publish.gradle.kts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildSrc/src/main/kotlin/maven-publish.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -0,0 +1,24 @@ +/* + * AboutOss is a utility library to retrieve and display + * opensource licenses in Android applications. + * + * Copyright (C) 2023-2025 by Frederic-Charles Barthelery. + * + * This file is part of AboutOss. + * + * AboutOss 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. + * + * AboutOss 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 AboutOss. If not, see . + */ +package com.geekorum.build + +configureMavenPublish() \ No newline at end of file diff -r 581f0b7dc09d -r f6133d9381b2 core/build.gradle.kts --- a/core/build.gradle.kts Mon Apr 28 13:35:53 2025 -0400 +++ b/core/build.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -26,7 +26,7 @@ kotlin("multiplatform") id("com.geekorum.build.source-license-checker") alias(libs.plugins.org.jetbrains.kotlinx.serialization) - `maven-publish` + id("com.geekorum.build.maven-publish") } group = "com.geekorum.aboutoss" @@ -104,27 +104,7 @@ androidTestImplementation(libs.espresso.core) } -publishing { - publications { - val pomConfiguration: (MavenPom).() -> Unit = { - name.set("core") - description.set("A library to retrieve and display opensource licenses in Android applications") - 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("2023") - } +mavenPublishing { + coordinates(groupId = group.toString(), name, version.toString()) +} - register("release") { - afterEvaluate { - from(components["release"]) - } - artifactId = "core" - pom(pomConfiguration) - } - } -} diff -r 581f0b7dc09d -r f6133d9381b2 gradle/libs.versions.toml --- a/gradle/libs.versions.toml Mon Apr 28 13:35:53 2025 -0400 +++ b/gradle/libs.versions.toml Thu May 01 20:41:08 2025 -0400 @@ -89,6 +89,7 @@ org-jetbrains-kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "org-jetbrains-kotlin" } google-gms-oss-license = { id = "com.google.android.gms.oss-licenses-plugin", version = "0.10.6" } org-jetbrains-kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "org-jetbrains-kotlin" } +com-vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version = "0.31.0" } [bundles] diff -r 581f0b7dc09d -r f6133d9381b2 ui/common/build.gradle.kts --- a/ui/common/build.gradle.kts Mon Apr 28 13:35:53 2025 -0400 +++ b/ui/common/build.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -27,7 +27,7 @@ id("com.geekorum.build.source-license-checker") alias(libs.plugins.org.jetbrains.compose.multiplatform) alias(libs.plugins.org.jetbrains.kotlin.compose.compiler) - `maven-publish` + id("com.geekorum.build.maven-publish") } group = "com.geekorum.aboutoss" @@ -120,27 +120,10 @@ } } -publishing { - publications { - val pomConfiguration: (MavenPom).() -> Unit = { - name.set("ui-common") - description.set("A library to retrieve and display opensource licenses in Android applications") - 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("2023") - } - - register("release") { - afterEvaluate { - from(components["release"]) - } - artifactId = "ui-common" - pom(pomConfiguration) - } +mavenPublishing { + val artifactId = "ui-common" + coordinates(groupId = group.toString(), artifactId, version.toString()) + pom { + name = artifactId } } diff -r 581f0b7dc09d -r f6133d9381b2 ui/material2/build.gradle.kts --- a/ui/material2/build.gradle.kts Mon Apr 28 13:35:53 2025 -0400 +++ b/ui/material2/build.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -28,7 +28,7 @@ alias(libs.plugins.org.jetbrains.compose.multiplatform) alias(libs.plugins.org.jetbrains.kotlinx.serialization) id("com.geekorum.build.source-license-checker") - `maven-publish` + id("com.geekorum.build.maven-publish") } group = "com.geekorum.aboutoss" @@ -121,27 +121,10 @@ androidTestImplementation(libs.espresso.core) } -publishing { - publications { - val pomConfiguration: (MavenPom).() -> Unit = { - name.set("ui-material") - description.set("A library to retrieve and display opensource licenses in Android applications") - 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("2023") - } - - register("release") { - afterEvaluate { - from(components["release"]) - } - artifactId = "ui-material" - pom(pomConfiguration) - } +mavenPublishing { + val artifactId = "ui-material" + coordinates(groupId = group.toString(), artifactId, version.toString()) + pom { + name = artifactId } -} +} \ No newline at end of file diff -r 581f0b7dc09d -r f6133d9381b2 ui/material3/build.gradle.kts --- a/ui/material3/build.gradle.kts Mon Apr 28 13:35:53 2025 -0400 +++ b/ui/material3/build.gradle.kts Thu May 01 20:41:08 2025 -0400 @@ -28,7 +28,7 @@ alias(libs.plugins.org.jetbrains.compose.multiplatform) alias(libs.plugins.org.jetbrains.kotlinx.serialization) id("com.geekorum.build.source-license-checker") - `maven-publish` + id("com.geekorum.build.maven-publish") } group = "com.geekorum.aboutoss" @@ -127,27 +127,10 @@ } } -publishing { - publications { - val pomConfiguration: (MavenPom).() -> Unit = { - name.set("ui-material3") - description.set("A library to retrieve and display opensource licenses in Android applications") - 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("2023") - } - - register("release") { - afterEvaluate { - from(components["release"]) - } - artifactId = "ui-material3" - pom(pomConfiguration) - } +mavenPublishing { + val artifactId = "ui-material3" + coordinates(groupId = group.toString(), artifactId, version.toString()) + pom { + name = artifactId } -} +} \ No newline at end of file