Skip to content

Commit c71a672

Browse files
committed
Add checks for properties
1 parent 10f139f commit c71a672

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

build.gradle

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,28 @@ if (project.hasProperty("signing.keyId") && project.hasProperty("signing.passwor
232232
}
233233
}
234234

235+
if (project.hasProperty("sonatype_username") && project.hasProperty("sonatype_password"))
236+
{
235237
// Plugin that uses the New Maven Central Publishing (NMCP) API to publish Maven artifacts. https://github.com/GradleUp/nmcp
236-
nmcp {
237-
centralPortal {
238-
username = sonatype_username
239-
password = sonatype_password
240-
// publish manually from the portal
241-
publishingType = "USER_MANAGED"
238+
nmcp {
239+
centralPortal {
240+
username = sonatype_username
241+
password = sonatype_password
242+
// publish manually from the portal
243+
publishingType = "USER_MANAGED"
242244
// // or if you want to publish automatically
243245
// publishingType = "AUTOMATIC"
246+
}
244247
}
245248
}
246249

247250
project.tasks.register('publishRelease', DefaultTask) {
248251
DefaultTask task ->
249252
task.group = 'Publishing'
250253
task.description = 'Publish to Local repository and Maven Central'
251-
task.dependsOn(tasks.publish, tasks.publishLibsPublicationToCentralPortal)
254+
if (project.hasProperty("artifactory_user") && project.hasProperty("artifactory_password"))
255+
task.dependsOn(tasks.publish)
256+
if (project.hasProperty("sonatype_username") && project.hasProperty("sonatype_password"))
257+
task.dependsOn(tasks.publishLibsPublicationToCentralPortal)
252258
}
253259

0 commit comments

Comments
 (0)