TWiStErRob / net.twisterrob.libraries

1 stars 0 forks source link

Set up publishing #23

Open TWiStErRob opened 1 year ago

TWiStErRob commented 1 year ago

Quick start for Java modules:

Index: gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/dsl/base.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/dsl/base.kt b/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/dsl/base.kt
new file mode 100644
--- /dev/null   (revision fe26ca9f4d69937676fb26851bb6dd37b694e8e2)
+++ b/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/dsl/base.kt (revision fe26ca9f4d69937676fb26851bb6dd37b694e8e2)
@@ -0,0 +1,7 @@
+package net.twisterrob.libraries.build.dsl
+
+import org.gradle.api.Project
+import org.gradle.api.plugins.BasePluginExtension
+
+internal val Project.base: BasePluginExtension
+   get() = this.extensions.getByName("base") as BasePluginExtension
Index: gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/publishing.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/publishing.gradle.kts b/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/publishing.gradle.kts
--- a/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/publishing.gradle.kts   (revision 50212b3ed65abc41b5f742eb1fb4ea9fa1df3287)
+++ b/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/build/publishing.gradle.kts   (revision fe26ca9f4d69937676fb26851bb6dd37b694e8e2)
@@ -1,12 +1,16 @@
 package net.twisterrob.libraries.build

+import net.twisterrob.libraries.build.dsl.base
 import net.twisterrob.libraries.build.dsl.libs

 plugins {
    id("org.gradle.maven-publish")
 }

-group = "net.twisterrob"
+group = "net.twisterrob.lib"
+plugins.withId("org.gradle.base") {
+   base.archivesName.set("twister-lib-${project.name}")
+}
 version = libs.versions.project.get()

 // -Prelease to build a release version
@@ -15,10 +19,11 @@
 }

 publishing {
-   repositories {
-       mavenLocal {
-           if (System.getProperty("user.name") == "TWiStEr") {
-               url = file("p:\\repos\\maven").toURI()
+   plugins.withId("net.twisterrob.libraries.java.library") {
+       publications {
+           register<MavenPublication>("javaLibrary") {
+               from(components["java"])
+               artifactId = base.archivesName.get()
            }
        }
    }
TWiStErRob commented 1 year ago

Also revise

android.publishing { singleVariant("release") }
publishing.publications {
    release<MavenPublication> {
        afterEvaluate { from(components.release) }
        groupId = "net.twisterrob.libraries"
        artifactId = "mylibrary"
        version = "1.0"
        versionMapping {
            usage("java-api") {
                fromResolutionOf("releaseRuntimeClasspath")
            }
            usage("java-runtime") {
                fromResolutionResult()
            }
        }
    }
}
TWiStErRob commented 7 months ago

Remove renovate exclusions.