File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ publishing {
127127 maven {
128128 val releasesRepoUrl = " https://api.bintray.com/maven/openapi-processor/primary/${project.name} /;publish=1;override=0"
129129 val snapshotsRepoUrl = " https://oss.jfrog.org/oss-snapshot-local/"
130- url = uri(if (version.toString().endsWith( " SNAPSHOT " )) snapshotsRepoUrl else releasesRepoUrl)
130+ url = uri(if (hasSnapshotVersion( )) snapshotsRepoUrl else releasesRepoUrl)
131131
132132 credentials {
133133 username = project.ext.get(" bintrayUser" ).toString()
@@ -137,18 +137,25 @@ publishing {
137137 }
138138}
139139
140- if (project.hasProperty(" SNAPSHOT" )) {
141- tasks.publish {
142- onlyIf {
143- version.toString().endsWith(" SNAPSHOT" )
140+ registerPublishTask(" snapshot" ) { hasSnapshotVersion() }
141+ registerPublishTask(" release" ) { ! hasSnapshotVersion() }
142+
143+ fun registerPublishTask (type : String , condition : () -> Boolean ) {
144+ tasks.register(" publish${type.capitalize()} " ) {
145+ group = " publishing"
146+ description = " Publish only if the current version is a ${type.capitalize()} version"
147+
148+ if (condition()) {
149+ println (" enabling $type publishing" )
150+ dependsOn(tasks.withType<PublishToMavenRepository >())
151+ } else {
152+ doLast {
153+ println (" skipping - no $type version" )
154+ }
144155 }
145156 }
146157}
147158
148- if (project.hasProperty(" RELEASE" )) {
149- tasks.publish {
150- onlyIf {
151- ! version.toString().endsWith(" SNAPSHOT" )
152- }
153- }
159+ fun hasSnapshotVersion (): Boolean {
160+ return version.toString().endsWith(" SNAPSHOT" )
154161}
You can’t perform that action at this time.
0 commit comments