Przeglądaj źródła

[android] Fix publishing to Maven Central

Mario Zechner 1 rok temu
rodzic
commit
5de003cb8f

+ 1 - 2
spine-android/app/build.gradle.kts

@@ -71,6 +71,5 @@ dependencies {
     debugImplementation(libs.androidx.ui.test.manifest)
     debugImplementation(libs.androidx.ui.test.manifest)
 
 
     implementation(project(":spine-android"))
     implementation(project(":spine-android"))
-    // Run `./gradlew publishToMavenLocal` in `spine-android` to use from local maven repo.
-//    implementation("com.esotericsoftware:spine-android:4.2")
+    // implementation("com.esotericsoftware.spine:spine-android:4.2.2-SNAPSHOT")
 }
 }

+ 1 - 1
spine-android/app/src/main/java/com/esotericsoftware/spine/AnimationStateEvents.kt

@@ -62,7 +62,7 @@ fun AnimationState(nav: NavHostController) {
             controller.skeleton.setScaleX(0.5f)
             controller.skeleton.setScaleX(0.5f)
             controller.skeleton.setScaleY(0.5f)
             controller.skeleton.setScaleY(0.5f)
 
 
-            controller.skeleton.findSlot("gun")?.color = Color(1f, 0f, 0f, 1f)
+            controller.skeleton.findSlot("gun")?.color?.set(Color(1f, 0f, 0f, 1f))
 
 
             controller.animationStateData.setDefaultMix(0.2f)
             controller.animationStateData.setDefaultMix(0.2f)
             controller.animationState.setAnimation(0, "walk", true).setListener(object : AnimationState.AnimationStateListener {
             controller.animationState.setAnimation(0, "walk", true).setListener(object : AnimationState.AnimationStateListener {

+ 5 - 5
spine-android/settings.gradle.kts

@@ -24,11 +24,11 @@ dependencyResolutionManagement {
 }
 }
 
 
 rootProject.name = "Spine Android Examples"
 rootProject.name = "Spine Android Examples"
-includeBuild("../spine-libgdx") {
-    dependencySubstitution {
-        substitute(module("com.esotericsoftware.spine:spine-libgdx")).using(project(":spine-libgdx"))
-    }
-}
+//includeBuild("../spine-libgdx") {
+//    dependencySubstitution {
+//        substitute(module("com.esotericsoftware.spine:spine-libgdx")).using(project(":spine-libgdx"))
+//    }
+//}
 //includeBuild("../../libgdx") {
 //includeBuild("../../libgdx") {
 //    dependencySubstitution {
 //    dependencySubstitution {
 //        substitute(module("com.badlogicgames.gdx:gdx")).using(project(":gdx"))
 //        substitute(module("com.badlogicgames.gdx:gdx")).using(project(":gdx"))

+ 58 - 4
spine-android/spine-android/build.gradle.kts

@@ -1,6 +1,7 @@
 plugins {
 plugins {
     alias(libs.plugins.androidLibrary)
     alias(libs.plugins.androidLibrary)
     `maven-publish`
     `maven-publish`
+    signing
 }
 }
 
 
 android {
 android {
@@ -39,16 +40,47 @@ dependencies {
     androidTestImplementation(libs.androidx.espresso.core)
     androidTestImplementation(libs.androidx.espresso.core)
 }
 }
 
 
+val libraryVersion = "4.2.2-SNAPSHOT" // Update this as needed
+
+tasks.register<Jar>("sourceJar") {
+    archiveClassifier.set("sources")
+    from(android.sourceSets["main"].java.srcDirs)
+}
+
 afterEvaluate {
 afterEvaluate {
     publishing {
     publishing {
         publications {
         publications {
-            create<MavenPublication>("mavenLocal") {
-                groupId = "com.esotericsoftware"
-                artifactId = "spine-android"
-                version = "4.2"
+            create<MavenPublication>("release") {
                 artifact(tasks.getByName("bundleReleaseAar"))
                 artifact(tasks.getByName("bundleReleaseAar"))
+                artifact(tasks.getByName("sourceJar"))
+
+                groupId = "com.esotericsoftware.spine"
+                artifactId = "spine-android"
+                version = libraryVersion
 
 
                 pom {
                 pom {
+                    packaging = "aar"
+                    name.set("spine-android")
+                    description.set("Spine Runtime for Android")
+                    url.set("https://github.com/esotericsoftware/spine-runtimes")
+                    licenses {
+                        license {
+                            name.set("Spine Runtimes License")
+                            url.set("http://esotericsoftware.com/spine-runtimes-license")
+                        }
+                    }
+                    developers {
+                        developer {
+                            name.set("Esoteric Software")
+                            email.set("[email protected]")
+                        }
+                    }
+                    scm {
+                        url.set(pom.url.get())
+                        connection.set("scm:git:${url.get()}.git")
+                        developerConnection.set("scm:git:${url.get()}.git")
+                    }
+
                     withXml {
                     withXml {
                         val dependenciesNode = asNode().appendNode("dependencies")
                         val dependenciesNode = asNode().appendNode("dependencies")
                         configurations.api.get().dependencies.forEach { dependency ->
                         configurations.api.get().dependencies.forEach { dependency ->
@@ -68,8 +100,30 @@ afterEvaluate {
                             }
                             }
                         }
                         }
                     }
                     }
+
+                }
+            }
+        }
+
+        repositories {
+            maven {
+                name = "SonaType"
+                url = uri(if (libraryVersion.endsWith("-SNAPSHOT")) {
+                    "https://oss.sonatype.org/content/repositories/snapshots"
+                } else {
+                    "https://oss.sonatype.org/service/local/staging/deploy/maven2"
+                })
+
+                credentials {
+                    username = project.findProperty("ossrhUsername") as String?
+                    password = project.findProperty("ossrhPassword") as String?
                 }
                 }
             }
             }
         }
         }
     }
     }
+
+    signing {
+        useGpgCmd()
+        sign(publishing.publications["release"])
+    }
 }
 }