File tree Expand file tree Collapse file tree 4 files changed +38
-20
lines changed
Expand file tree Collapse file tree 4 files changed +38
-20
lines changed Original file line number Diff line number Diff line change 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 }}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments