Skip to content

Commit 27c147d

Browse files
committed
Few more updates to script
1 parent 4d66a1f commit 27c147d

File tree

4 files changed

+38
-20
lines changed

4 files changed

+38
-20
lines changed

.github/workflows/deploy-snapshot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ jobs:
3333

3434
- name: Build
3535
run: ./gradlew build
36+
37+
- name: Publish package
38+
run: ./gradlew publishSnapshotToCentral
39+
env:
40+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
41+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

gradle/publishing.gradle

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,8 @@ publishing {
4444
def sonatypeUsername = System.getenv("SONATYPE_USER")
4545
def sonatypePassword = System.getenv("SONATYPE_PASSWORD")
4646
maven {
47-
name = "sonatypeSnapshot"
48-
url = "https://oss.sonatype.org/content/repositories/snapshots"
49-
credentials {
50-
username = sonatypeUsername
51-
password = sonatypePassword
52-
}
53-
}
54-
maven {
55-
name = "mavenCentral"
56-
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
47+
name = "centralSnapshot"
48+
url = "https://central.sonatype.com/api/v1/publisher/snapshots"
5749
credentials {
5850
username = sonatypeUsername
5951
password = sonatypePassword

gradle/publishing_aar.gradle

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,8 @@ afterEvaluate {
6262
def sonatypeUsername = System.getenv("SONATYPE_USER")
6363
def sonatypePassword = System.getenv("SONATYPE_PASSWORD")
6464
maven {
65-
name = "sonatypeSnapshot"
66-
url = "https://oss.sonatype.org/content/repositories/snapshots"
67-
credentials {
68-
username = sonatypeUsername
69-
password = sonatypePassword
70-
}
71-
}
72-
maven {
73-
name = "mavenCentral"
74-
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
65+
name = "centralSnapshot"
66+
url = "https://central.sonatype.com/api/v1/publisher/snapshots"
7567
credentials {
7668
username = sonatypeUsername
7769
password = sonatypePassword

gradle/sonatype-central.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,31 @@ tasks.register("uploadToSonatypeCentral") {
6969
}
7070
}
7171
}
72+
73+
// Task to publish snapshots to Sonatype Central Portal
74+
tasks.register("publishSnapshotToCentral") {
75+
description = "Publishes snapshot artifacts to Sonatype Central Portal"
76+
group = "publishing"
77+
78+
doFirst {
79+
// Ensure version ends with -SNAPSHOT
80+
if (!project.version.toString().endsWith('-SNAPSHOT')) {
81+
throw new GradleException("Version must end with -SNAPSHOT to publish as snapshot. Current version: ${project.version}")
82+
}
83+
}
84+
85+
dependsOn "publishAllPublicationsToCentralSnapshotRepository"
86+
}
87+
88+
// Task to publish artifacts to local Maven repository
89+
tasks.register("publishToLocalMavenRepository") {
90+
description = "Publishes all artifacts to local Maven repository (~/.m2/repository)"
91+
group = "publishing"
92+
93+
dependsOn "publishToMavenLocal"
94+
95+
doLast {
96+
println "Artifacts published to local Maven repository at: ${System.getProperty('user.home')}/.m2/repository"
97+
println "You can now use the artifacts in other local projects with version: ${project.version}"
98+
}
99+
}

0 commit comments

Comments
 (0)