Fix disabling of publish task when env property is set (#574)

Because of Gradle's project lifecycle, disabling tasks in the script doesn't
work as expected, ./gradlew publish will still try to execute
:publishMavenJavaPublicationToMavenRepository and fail even if PUBLISH_ARTIFACTS
is set to false. To avoid that and make sure all publish tasks are disabled
script need to listen for tasks graph event to be ready and then disable the tasks.
This commit is contained in:
Alexey Nesterov
2018-03-13 09:31:55 +00:00
committed by Marcin Grzejszczak
parent a84c8643fa
commit 1e47d519af

View File

@@ -105,7 +105,9 @@ String publishArtifacts = getProp("PUBLISH_ARTIFACTS") ?: "true"
boolean publishEnabled = Boolean.parseBoolean(publishArtifacts)
publish.setEnabled(publishEnabled)
project.tasks.findAll { it.name.startsWith('publish') }*.setEnabled(publishEnabled)
gradle.taskGraph.whenReady { graph ->
graph.allTasks.findAll { it.name.startsWith("publish") }*.setEnabled(publishEnabled)
}
String getProp(String propName) {
return hasProperty(propName) ?