title: Using profiles to control which Maven modules are built
body: <p>I have the following XML in my maven POM.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;profiles&gt;
    &lt;profile&gt;
       &lt;id&gt;default&lt;/id&gt;
       &lt;activation&gt;
          &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
          &lt;property&gt;
             &lt;name&gt;default&lt;/name&gt;
             &lt;value&gt;!disabled&lt;/value&gt;
          &lt;/property&gt;
       &lt;/activation&gt;
       &lt;modules&gt;
          &lt;module&gt;m1&lt;/module&gt;
          &lt;module&gt;m2&lt;/module&gt;
          &lt;module&gt;m3&lt;/module&gt;
       &lt;/modules&gt;
    &lt;/profile&gt;
    &lt;profile&gt;
       &lt;id&gt;x&lt;/id&gt;
       &lt;modules&gt;
          &lt;module&gt;m1&lt;/module&gt;
       &lt;/modules&gt;
    &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>What I'm trying to achieve is this:</p>
  
  <ol>
  <li><p>When I run <code>mvn install</code>, I want it to build m1, m2 and m3 projects.</p></li>
  <li><p>When I run <code>mvn install -Px</code>, I want it to <strong>only</strong> build m1.</p></li>
  </ol>
  
  <p>My current problem is that with the code above, option 2 builds all m1, m2 and m3.</p>