title: Create dependency groups in Maven for reuse - including 'provided' dependencies
body: <p>I am new to Maven and am setting up my first maven project. I am also creating some maven assets in the form of some poms that can be inherited from or used as dependencies in any future projects as well. I want to group dependencies together and to be able to selectively add them to a project as needed. </p>
  
  <p>I read <a href="http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html" rel="noreferrer">this article</a> on pom best practices. I like the idea of grouping related dependencies together into poms and then adding the pom as a dependency to a project as needed. This approach works great for compile scoped dependencies. However it fails for provided scoped ones since as transitive dependencies, they get omitted. </p>
  
  <p>Here's an example of what I mean: Lets say I group together web dependencies for my projects into a web-deps pom.xml. These include <code>compile</code> scoped spring framework dependencies and also a <code>provided</code> scoped javaee one:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.xyz&lt;/groupId&gt;
  &lt;artifactId&gt;mvn-web-deps&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javaee&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
          &lt;version&gt;${javaee.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>I then add this pom as a dependency in another project:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.xyz&lt;/groupId&gt;
  &lt;artifactId&gt;project-a&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.xyz&lt;/groupId&gt;
      &lt;artifactId&gt;mvn-web-deps&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;type&gt;pom&lt;/type&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>The dependencies in <code>mvn-web-deps</code> now become <em>transitive</em>. Since the dependency reference above is <code>compile</code> scoped, the <code>provided</code> transitive dependency gets omitted.</p>
  
  <p>I want to avoid adding them to the <code>dependency</code> section of a parent since there can only be one parent and a project may need only some of these dependency groups, not all. I can perhaps add them to the <code>dependencyManagement</code> section, but then I will have to redeclare each dependency (sans the version) in each child project.</p>
  
  <p>What is the correct/better way of grouping dependencies while avoiding the issues like above? </p>