title: Maven Project Aggregation and Variables
body: <p>Agregate Project 1:</p>
  
  <pre><code>    &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;builder&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;modules&gt;
          &lt;module&gt;../module-1&lt;/module&gt;
          &lt;module&gt;../module-2&lt;/module&gt;
      &lt;/modules&gt;
      &lt;properties&gt;
          &lt;project.parent.pom&gt;../builder-v1/pom.xml&lt;/project.parent.pom&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;lib.version&gt;2.5.1&lt;/lib.version&gt;
      &lt;/properties&gt;
  </code></pre>
  
  <p>Agregate Project 2:</p>
  
  <pre><code>    &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;builder&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;modules&gt;
          &lt;module&gt;../module-1&lt;/module&gt;
          &lt;module&gt;../module-4&lt;/module&gt;
          &lt;module&gt;../module-6&lt;/module&gt;
      &lt;/modules&gt;
      &lt;properties&gt;
          &lt;project.parent.pom&gt;../builder-v2/pom.xml&lt;/project.parent.pom&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;lib.version&gt;2.6.0&lt;/lib.version&gt;
      &lt;/properties&gt;
  </code></pre>
  
  <p>Module 1:</p>
  
  <pre><code>    &lt;parent&gt;
          &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
          &lt;artifactId&gt;builder&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;relativePath&gt;../builder-v1/pom.xml&lt;/relativePath&gt;
          &lt;!--&lt;relativePath&gt;${project.parent.pom}&lt;/relativePath&gt; not work--&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;module-1&lt;/artifactId&gt;
  </code></pre>
  
  <p>Section relativePath with variable from aggregate pom not work</p>
  
  <pre><code>&lt;relativePath&gt;../builder-v1/pom.xml&lt;/relativePath&gt;
  &lt;!--&lt;relativePath&gt;${project.parent.pom}&lt;/relativePath&gt; not work--&gt;
  </code></pre>
  
  <p>But I need diffrent ${lib.version} in aggregate projects. If I delete inheritance part from
  Module 1:</p>
  
  <pre><code>    &lt;!--&lt;parent&gt;
          &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
          &lt;artifactId&gt;builder&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;relativePath&gt;../builder-v1/pom.xml&lt;/relativePath&gt;
      &lt;/parent&gt;--&gt;
  
      &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;module-1&lt;/artifactId&gt;
  </code></pre>
  
  <p>Variables are not passed to the child modules and i got error:</p>
  
  <pre><code>'dependencies.dependency.version' for com.somelib:some-lib:jar must be a valid version but is '${lib.version}'.
  </code></pre>
  
  <p>How can I configure aggregate project and transfer variables into modules?</p>
  
  <p><strong>UPDATE with @Gab comments</strong></p>
  
  <p>Parent pom:</p>
  
  <pre><code>    &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;parent&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
  
      &lt;profiles&gt;
          &lt;profile&gt;
        &lt;id&gt;v1&lt;/id&gt;
              &lt;activation&gt;
                  &lt;property&gt;
                      &lt;name&gt;project.type&lt;/name&gt;
                      &lt;value&gt;v1&lt;/value&gt;
                  &lt;/property&gt;
              &lt;/activation&gt;
          &lt;properties&gt;
            &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;             
            &lt;lib.version&gt;2.5.1&lt;/lib.version&gt;
          &lt;/properties&gt;
          &lt;/profile&gt;
          ...
      &lt;/profiles&gt;
  </code></pre>
  
  <p>Module 1:</p>
  
  <pre><code>    &lt;parent&gt;
          &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
          &lt;artifactId&gt;parent&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;module-1&lt;/artifactId&gt;
  </code></pre>
  
  <p>Agregate Project 1:</p>
  
  <pre><code>    &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
      &lt;artifactId&gt;builder-v1&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;modules&gt;
          &lt;module&gt;../module-1&lt;/module&gt;
          &lt;module&gt;../module-2&lt;/module&gt;
      &lt;/modules&gt;
  </code></pre>
  
  <p>When execute builder-v1 goals activate profile <strong>project.type=v1</strong>:</p>
  
  <pre><code>mvn clean package --file=pom_v1.xml -Dproject.type=v1 -Dproject.main.module=module-1
  </code></pre>