Is it possible to configure artifactory publications during the execution phase?

(Glenn) #1


I use the artifactory-publish plugin to publish artifacts to an ivy repository. In the artifactory configuration block, you can specify a list of default publications. ie.:

artifactory {
  contextUrl =
  publish {
    repository {
      repoKey = libs-snapshot-local
        ivy {
        maven = false
      defaults {
        publishIvy = true
          publications (‘A’, ‘B’, ‘C’)

I have a publication A for which I can only figure out at execution time whether it has any artifacts to publish. Publication A has its own versioning that differs from the version of the project. If there is nothing to publish, its version will be the same as in previous builds. If I mention A in the default publications though, then it will always try to upload an ivy.xml even if there are no other artifacts to publish. This results in a conflict, because ivy.xml already exists on the repository. If I leave A out, then it never gets published.

Is there a way to add A to the list of publications at execution time? I tried doing this in a task and add a dependency to it from artifactoryPublish, but either it’s not possible, or I didn’t find the correct syntax.

Any help appreciated,