3

I have a multiproject gradle build with the following subprojects: sample-api sample-common that depends on sample-api sample-server that depends on sample-api and sample-common.

I would like to avoid building/publishing sample-api.jar, sample-common.jar or sample-server.ear if the source code hasn't been changed (svn diff) since the previous release. sample-api.jar and sample-common.jar will be consumed by external clients and I want to avoid unnecessary builds/publicatios let' say to nexus repo. The whole project is build with gradle from jenkins.

Currently I know how to make sample-common depend on sample-api.jar if sample-api source code has no changes - and on sample-api project otherwise. But I also need to avoid sample-common build if sample-api and sample-common have no changes; same with sample-server - no build if nothing has changed in sample-api+sample-ocmmon+sample-server. I want it recursively.

There must be a pretty standard solution for this problem?

Thanks.

pavel
  • 377
  • 2
  • 11
  • 1
    It's not clear to me which problem you are trying to solve. You'd need to explain in more detail (concrete code/example helps). Also, please fix the title (it is way too generic). – Peter Niederwieser Aug 07 '14 at 00:49
  • The problem I want to solve is to avoid building (for instance) sample-api if no source code changes detected in this project. Imagine function bool hasCodeChangs(projectName) and I want to avoid building/publishing subproject if hasCodeChanges(subproject.name) is false. However I might have to build/publish sample-common or sample-server if they have code changes, if helium-api has no changes, they will depend on helium-api.jar from previous release. – pavel Aug 07 '14 at 01:15
  • building per se only consumes CPU resources, so yes - I'd like to avoid publishing. I guess I want to disable install task for every subproject that has no source code changes + it's dependencies have no changes? Are there any good examples? I guess the problem must be quite common. – pavel Aug 07 '14 at 01:17
  • 2
    Building is avoided automatically, albeit on a per-task level. There isn't currently an easy way to avoid publishing, as this is a harder problem and depends on how you are managing version numbers etc. What you'd typically want there is to never try to publish something that was published before (not just avoiding publishing if there were no changes from the previous build on the same box). And Nexus won't let you publish the same version twice anyway. – Peter Niederwieser Aug 07 '14 at 01:18
  • building is avoided automatically if I use the same directory, which is usually not the case when jenkins builds it in a clean directory tree. Which area should I dig around to find out how to avoid publishing? There must be standard solutions for projects that also want to avoid publishing releases without real changes – pavel Aug 07 '14 at 01:22
  • 1
    Different people have different requirements for "avoid republishing", and there is no easy/standard solution. – Peter Niederwieser Aug 07 '14 at 01:24
  • In my case I have 3 directories - src, build and install. If I can avoid copying artifacts to install/, that would be sufficient. – pavel Aug 07 '14 at 01:25
  • 1
    If the artifacts in `install` are up-to-date, they won't be copied again. For an install dir, you typically want to use `Sync` rather than `Copy`, to prevent stale files. – Peter Niederwieser Aug 07 '14 at 01:27
  • On every jenkins build, directories build and install will be created from scratch and therefore current build knows nothing about previous releases. However I can find from subversion which projects have changes and so I want to avoid copying to install modules that have no changes/updated dependencies. – pavel Aug 07 '14 at 01:30
  • 1
    Don't wipe out the workspace every time, or use multiple single-project builds and multiple build jobs instead of a single multi-project build and build job. – Peter Niederwieser Aug 07 '14 at 02:34

0 Answers0