3

I have two projects as part of my multi- project build, ProjectA and ProjectB.

ProjectA has a compile dependency on ProjectB. I also have automatic build number increments, whereby each project contains a versions.json file containing the latest build number. I have gradle script that increments this build number on a gradle publish.

Now, when a change is made to ProjectA, and a gradle clean publish is performed, ProjectB is also deployed to Nexus, even though it hasn't changed. How can I stop this from happening?

Note that the build is always done from clean since this process happens by our CI server and is always done from a fresh clone, so a solution such as the following does not work:

publish {
  onlyIf { jar.didWork }
}

How can I ensure that an artifact is onlt published to Nexus if it is different to the latest copy upstream? Perhaps one way to solve this is to not run the publish on the dependent project. But how?

PCL
  • 421
  • 2
  • 7
  • 15
  • Is ProjectB version incrementing when you make a change to ProjectA? If no, does your hosted repository in NXRM allow redeploy? – joedragons Apr 13 '18 at 21:57
  • 1
    No, ProjectB version does not change and the artifact repository does not allow redeploy. I have a task that depends on `publish` that increments the build number. So when ProjectA gets published, ProjectB will also get published and the task will run, so the build number will be incremented. I need to not build/publish dependent projects, or stop the task from running on dependent projects somehow. – PCL Apr 14 '18 at 03:00
  • I see. If the build number is incremented as far as NXRM knows, this is new. IMO your problem lies before NXRM. – joedragons Apr 20 '18 at 17:57
  • Yes, you are right. So how do I stop the build from propagating down to publishing projects that may not have changed? – PCL Apr 23 '18 at 00:39

0 Answers0