Skip to content

Commit cadedb4

Browse files
committed
more jitpack improvements
1 parent e39a62d commit cadedb4

2 files changed

Lines changed: 58 additions & 37 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,24 @@ jobs:
3030
java-version: '11'
3131
distribution: 'temurin'
3232

33-
- name: Update version in build.gradle.kts
34-
run: |
35-
# Remove -SNAPSHOT suffix and set the release version
36-
sed -i "s/version = \".*\"/version = \"${{ github.event.inputs.version }}\"/" build.gradle.kts
37-
38-
# Show the updated version
39-
echo "Updated version to:"
40-
grep "^version = " build.gradle.kts
41-
4233
- name: Build with Gradle
4334
run: |
4435
chmod +x ./gradlew
45-
./gradlew clean build -x test
36+
# Pass version as property instead of modifying file
37+
./gradlew clean build -Pversion=${{ github.event.inputs.version }} -x test
38+
39+
echo "Building version ${{ github.event.inputs.version }}"
4640
4741
- name: Run tests
48-
run: ./gradlew test
42+
run: ./gradlew test -Pversion=${{ github.event.inputs.version }}
4943

5044
- name: Build JAR artifacts
5145
run: |
52-
./gradlew jar
53-
./gradlew androidJar
54-
./gradlew jvmJar
55-
./gradlew sourcesJar
56-
./gradlew javadocJar
46+
./gradlew jar -Pversion=${{ github.event.inputs.version }}
47+
./gradlew androidJar -Pversion=${{ github.event.inputs.version }}
48+
./gradlew jvmJar -Pversion=${{ github.event.inputs.version }}
49+
./gradlew sourcesJar -Pversion=${{ github.event.inputs.version }}
50+
./gradlew javadocJar -Pversion=${{ github.event.inputs.version }}
5751
5852
- name: List built artifacts
5953
run: |

build.gradle.kts

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ plugins {
77
}
88

99
group = "com.github.unicitynetwork"
10-
version = "1.1-SNAPSHOT"
10+
// JitPack will override this with the tag version via -Pversion
11+
version = project.findProperty("version") ?: "1.1-SNAPSHOT"
1112

1213
repositories {
1314
mavenCentral()
@@ -111,40 +112,66 @@ publishing {
111112

112113
from(components["java"])
113114

114-
// Add Android JAR as the main artifact (default)
115-
artifact(tasks["androidJar"]) {
116-
classifier = null
117-
}
115+
// Replace the default JAR with Android JAR as the main artifact
116+
artifacts.clear()
117+
artifact(tasks["androidJar"])
118118

119119
// Add JVM JAR as a classifier variant
120120
artifact(tasks["jvmJar"]) {
121121
classifier = "jvm"
122122
}
123123

124+
// Add sources and javadoc
125+
artifact(tasks["sourcesJar"])
126+
artifact(tasks["javadocJar"])
127+
124128
pom {
125129
name.set("Unicity State Transition SDK")
126130
description.set("Unicity State Transition SDK for Android and JVM")
131+
url.set("https://github.com/unicitynetwork/java-state-transition-sdk")
132+
133+
licenses {
134+
license {
135+
name.set("MIT License")
136+
url.set("https://opensource.org/licenses/MIT")
137+
}
138+
}
127139

128-
// Android-compatible dependencies for main artifact
140+
developers {
141+
developer {
142+
id.set("unicitynetwork")
143+
name.set("Unicity Network")
144+
}
145+
}
146+
147+
// Modify existing dependencies to use Android Guava
129148
withXml {
130-
val dependenciesNode = asNode().appendNode("dependencies")
149+
val root = asNode()
150+
val dependenciesNodes = root.children().filter { node ->
151+
(node as? groovy.util.Node)?.name()?.toString()?.endsWith("dependencies") == true
152+
}
131153

132-
configurations["implementation"].dependencies.forEach { dep ->
133-
if (dep.group != "com.google.guava") {
134-
val dependencyNode = dependenciesNode.appendNode("dependency")
135-
dependencyNode.appendNode("groupId", dep.group)
136-
dependencyNode.appendNode("artifactId", dep.name)
137-
dependencyNode.appendNode("version", dep.version)
138-
dependencyNode.appendNode("scope", "compile")
154+
dependenciesNodes.forEach { dependencies ->
155+
val depNode = dependencies as groovy.util.Node
156+
157+
// Find and update Guava dependency
158+
depNode.children().forEach { dep ->
159+
val dependency = dep as groovy.util.Node
160+
val groupIdNode = dependency.children().find {
161+
(it as? groovy.util.Node)?.name()?.toString()?.endsWith("groupId") == true
162+
} as? groovy.util.Node
163+
val artifactIdNode = dependency.children().find {
164+
(it as? groovy.util.Node)?.name()?.toString()?.endsWith("artifactId") == true
165+
} as? groovy.util.Node
166+
167+
if (groupIdNode?.text() == "com.google.guava" && artifactIdNode?.text() == "guava") {
168+
val versionNode = dependency.children().find {
169+
(it as? groovy.util.Node)?.name()?.toString()?.endsWith("version") == true
170+
} as? groovy.util.Node
171+
versionNode?.setValue("33.0.0-android")
172+
}
139173
}
140174
}
141-
142-
// Add Android-specific Guava for main artifact
143-
val guavaDep = dependenciesNode.appendNode("dependency")
144-
guavaDep.appendNode("groupId", "com.google.guava")
145-
guavaDep.appendNode("artifactId", "guava")
146-
guavaDep.appendNode("version", "33.0.0-android")
147-
guavaDep.appendNode("scope", "compile")
148175
}
149176
}
150177
}

0 commit comments

Comments
 (0)