Skip to content

Commit 69b3040

Browse files
committed
Improved build file to require mavenUser mavenPassword only when publishing to Nosto repository
1 parent 86a2075 commit 69b3040

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ publishing {
156156
maven {
157157
url 'https://repo.nos.to/content/repositories/NostoDependencies/'
158158
credentials {
159-
username = "$mavenUser"
160-
password = "$mavenPassword"
159+
username = project.hasProperty('mavenUser') ? project.mavenUser : ""
160+
password = project.hasProperty('mavenPassword') ? project.mavenPassword : ""
161161
}
162162
}
163163
}
@@ -166,6 +166,14 @@ publishing {
166166
tasks.register('publishToNostoRepo') {
167167
dependsOn 'publishMavenPublicationToMavenRepository'
168168
}
169+
gradle.taskGraph.whenReady { taskGraph ->
170+
if (taskGraph.hasTask(':publishToNostoRepo')) {
171+
if (!project.hasProperty('mavenUser') || !project.hasProperty('mavenPassword')) {
172+
throw new GradleException("mavenUser and mavenPassword must be defined for publishToNostoRepo task")
173+
}
174+
}
175+
}
176+
169177

170178
afterReleaseBuild.dependsOn nexusPublishing
171179

0 commit comments

Comments
 (0)