The artifactory gradle plugin ( https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin )
documents a property to skip publications.
artifactoryPublish.skip = true
However this doesnt fully disable artifactory. It still publishes a "Build" with no artifacts.
To conditionally skip a publication the following code block seems to work.
This is useful, for example, if you want the same build to run in a CI server and standalone
and/or if you want to run test or dev builds without publishing then rerun the same build
with only a property change to have it publish - reguardless of if artifactoryPublish task is invoked.
CI Servers like TeamCity will always pass artifactoryPublish if you enable artifactory for a build,
this allows the publication to be skipped conditionally.
Witout Line 63 the code snippet above the following results
Note that the build descriptor is actually published even though artifactoryPublish.skip = true
$ gradle build artifactoryPublish
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:startScripts UP-TO-DATE
:distTar UP-TO-DATE
:distZip UP-TO-DATE
:war UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:buildDashboard UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
:artifactoryPublish
Deploying build descriptor to: http://foobar.artifactoryonline.com/nexstra/api/build
Build successfully deployed. Browse it in Artifactory under http://foobar.artifactoryonline.com/nexstra/webapp/builds/myproduct/1451501182455
BUILD SUCCESSFUL
Total time: 2.349 secs
$
With line 62
$ gradle build artifactoryPublish
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:startScripts UP-TO-DATE
:distTar UP-TO-DATE
:distZip UP-TO-DATE
:war UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:buildDashboard UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
:artifactoryPublish SKIPPED
BUILD SUCCESSFUL
Total time: 2.23 secs
And to do a full publish
$ gradle build artifactoryPublish -Partifactory
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:startScripts UP-TO-DATE
:distTar UP-TO-DATE
:distZip UP-TO-DATE
:war UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:buildDashboard UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
:generateDescriptorFileForIvyJavaPublication
:generatePomFileForMavenJavaPublication
:artifactoryPublish
Deploying artifact: http://foobar.artifactoryonline.com/foobar/libs-snapshot-local/com/foobar/vendorserver/2.0.0-SNAPSHOT/vendorserver-2.0.0-SNAPSHOT.pom
Deploying artifact: http://foobar.artifactoryonline.com/foobar/libs-snapshot-local/com/foobar/vendorserver/2.0.0-SNAPSHOT/vendorserver-2.0.0-SNAPSHOT.war
Deploying artifact: http://foobar.artifactoryonline.com/foobar/libs-snapshot-local/com/foobar/vendorserver/ivy-2.0.0-SNAPSHOT.xml
Deploying build descriptor to: http://foobar.artifactoryonline.com/foobar/api/build
Build successfully deployed. Browse it in Artifactory under http://foobar.artifactoryonline.com/foobar/webapp/builds/vendorserver/1451501357555
BUILD SUCCESSFUL
Total time: 3.069 secs
$
I was running into this issue as well and found adding this to the publishTask will stop the artifacts and the build info from being published.
artifactory {
publish {
if (!rootProject.hasProperty("artifactory")) {
logger.lifecycle("Disabling publication settings.")
publishBuildInfo = false //Publish build-info to Artifactory (true by default)
publishArtifacts = false //Publish artifacts to Artifactory (true by default)
publishPom = false //Publish generated POM files to Artifactory (true by default).
publishIvy = false
}
}
}