@@ -4,8 +4,8 @@ plugins {
44 id ' com.diffplug.spotless' version ' 6.2.0'
55 id ' signing'
66 id ' maven-publish'
7- id ' net.researchgate.release' version ' 3.0.2'
87 id ' io.github.gradle-nexus.publish-plugin' version ' 1.3.0'
8+ id ' net.researchgate.release' version ' 3.0.2'
99}
1010
1111wrapper {
@@ -67,8 +67,8 @@ nexusPublishing {
6767 repositories {
6868 sonatype {
6969 nexusUrl. set(uri(" https://oss.sonatype.org/service/local/" ))
70- username = project. findProperty(' sonatypeUser ' ) ?: ' '
71- password = project. findProperty(' sonatypePassword ' ) ?: ' '
70+ username = project. findProperty(' ossSonatypeUsername ' ) ?: ' '
71+ password = project. findProperty(' ossSonatypePassword ' ) ?: ' '
7272 }
7373 }
7474}
@@ -115,22 +115,13 @@ publishing {
115115}
116116
117117release {
118- buildTasks = [' releaseBuild ' ]
118+ buildTasks = [' doRelease ' ]
119119 git {
120120 requireBranch. set(' main' )
121121 }
122122}
123123
124- task releaseBuild {
125- dependsOn(
126- ' checkLastVersionValue' ,
127- ' clean' ,
128- ' build' ,
129- project. getTasksByName(' publishToSonatype' , true )
130- )
131- }
132-
133- tasks. register(' checkLastVersionValue' ) {
124+ def checkLastVersionValueTask = tasks. register(' checkLastVersionValue' ) {
134125 doLast {
135126 if (version. endsWith(' SNAPSHOT' )) {
136127 throw new GradleException (" version '$version ' ends with SNAPSHOT, this is not a release build!" )
@@ -145,11 +136,22 @@ def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
145136 doLast {
146137 def propertiesFile = file(' gradle.properties' )
147138 def content = propertiesFile. text
148- content = content. replaceAll(" lastVersion=[0-9\\ .]+" , " lastVersion=" + version. replace(' -SNAPSHOT' , ' ' ))
139+ def newVersion = project. findProperty(' release.releaseVersion' ) ?: version. replace(' -SNAPSHOT' , ' ' )
140+ content = content. replaceAll(" lastVersion=[0-9a-z\\ .\\ -]+" , " lastVersion=" + newVersion)
149141 propertiesFile. text = content
150142 }
151143}
152144
145+ tasks. register(' doRelease' ) {
146+ dependsOn(
147+ checkLastVersionValueTask,
148+ ' initializeSonatypeStagingRepository' ,
149+ ' clean' ,
150+ ' build' ,
151+ project. getTasksByName(' publishToSonatype' , true )
152+ )
153+ }
154+
153155model {
154156 tasks. unSnapshotVersion {
155157 dependsOn updateLastVersionValueTask
0 commit comments