title: Why can't I activate a Maven2 profile from another profile?
body: <p>I have a multimodule Maven2 project which builds a web application. The application is connected to a backend server and a DB. There are several server instances deployed in our environment, and there are also multiple backend and DB instances for development, UAT, production, etc. So practically, each application configuration needs these 3 coordinates:</p>
  
  <ul>
  <li>front-end server</li>
  <li>back-end server</li>
  <li>DB</li>
  </ul>
  
  <p>I am working on unifying and automating the application configuration. It is easy and obvious to represent these different configurations as profiles in Maven. Then I can create a specific configuration by activating one profile from each group, e.g.</p>
  
  <pre><code>mvn -Pserver.Server1,backend.prod,db.uat clean install
  </code></pre>
  
  <p>This is a bit tedious to type and error-prone - if a specific server is misconfigured to connect to the wrong DB, the price can be high. One obvious way to fix this would be to put all useful profile combinations into script files.</p>
  
  <p>But I thought I could be more clever than that by activating the necessary back-end and DB profile directly from the server profile. The server profiles are in the main pom, e.g.</p>
  
  <pre><code>&lt;profile&gt;
      &lt;id&gt;server.myserver&lt;/id&gt;
      &lt;properties&gt;
          &lt;jboss.home&gt;D:\Programs\jboss-4.2.1.GA&lt;/jboss.home&gt;
          &lt;server.name&gt;NightlyBuild&lt;/server.name&gt;
          &lt;hosttobind&gt;192.168.1.100&lt;/hosttobind&gt;
          &lt;servlet.port&gt;8080&lt;/servlet.port&gt;
          ...
          &lt;db&gt;dev02&lt;/db&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>And the backend and DB profiles are in the pom of the Config submodule, e.g.</p>
  
  <pre><code>&lt;profile&gt;
      &lt;id&gt;db.dev02&lt;/id&gt;
      &lt;activation&gt;
          &lt;property&gt;
              &lt;name&gt;db&lt;/name&gt;
              &lt;value&gt;dev02&lt;/value&gt;
          &lt;/property&gt;
      &lt;/activation&gt;
      &lt;properties&gt;
          &lt;jdbc.address&gt;jdbc:oracle:thin:@192.168.0.101:1521:dbdev02&lt;/jdbc.address&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>So in theory, since the <code>server.myserver</code> profile sets the <code>db</code> property to <code>dev02</code>, this should trigger the activation of the <code>db.dev02</code> profile in the child pom. However, this does not happen. (Nor if the two profiles are in the same pom, btw). If I set the property from the command line with </p>
  
  <pre><code>mvn -Ddb=dev02 help:active-profiles
  </code></pre>
  
  <p>then the profile is activated though, so apparently I haven't misspelled anything.</p>
  
  <p>Have I overlooked something? Is there any other way to make this work?</p>
  
  <p>I see that there exists a similar question: <a href="https://stackoverflow.com/questions/943411/can-i-make-one-maven-profile-activate-another">Can I make one maven profile activate another?</a><br>
  However, IMHO this is not a duplicate - I see that my approach is not working and I would like to understand why. (I have read the reference, but I might have overlooked something obvious).</p>