title: Jenkins building a product consisting of many Maven projects? (with Jenkins Pipeline plugin?)
body: <p>We have a product that consists of many Maven projects that depend on each other.  All of these Maven projects come together in a single project which delivers the end product.</p>
  
  <p>The Maven projects share the same life cycle.  In other words, they are not managed by separate teams of people with explicit <code>&lt;dependency&gt;</code> changes to pick up newer versions of other projects.  Rather, when someone changes something in one of the projects, then the result should go directly into the end product without additional changes.</p>
  
  <p>We use Jenkins as our Continuous Integration tool.</p>
  
  <p>The main wishes we have are as follows:</p>
  
  <ul>
  <li>No need to copy all the inter-project dependencies to Jenkins configuration: these should be in a single place, ideally the <code>pom.xml</code> files.</li>
  <li>Avoid unnecessary builds: on an SCM change, only build the projects that are potentially affected.</li>
  <li>In case of <em>diamond dependencies</em> (C depends on both B1 and B2, which both depend on A), if the lowest (A) is changed, then the end product (C) should always use the version of A that was also used to build/test B1 and B2.</li>
  </ul>
  
  <p><strong>Question</strong>: What is the best approach to do this with Jenkins?</p>
  
  <p>We are currently thinking to use a single job using the Jenkins Pipeline plugin, which analyzes the Maven dependencies and the SCM changes, decides what needs to be built and in which order, and then actually build the projects.</p>