title: Activating Maven profile using system properties
body: <p>I'm working on a project that uses Maven profiles to differentiate between environment-specific configurations. I'm running version <strong>3.0.5</strong>. The goal is to be able to specify the environment by passing a system property to the initial run command from the shell that corresponds to an activation property, like so:</p>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;profiles&gt;
     ...
      &lt;profile&gt;&lt;!-- Local Dev Environment --&gt;
          &lt;id&gt;local&lt;/id&gt;
          &lt;activation&gt;
              &lt;property&gt;
                  &lt;name&gt;environment&lt;/name&gt;
                  &lt;value&gt;local&lt;/value&gt;
              &lt;/property&gt;
          &lt;/activation&gt;
          &lt;properties&gt;
              ...
          &lt;/properties&gt;
      &lt;/profile&gt;&lt;!-- End Local Dev Environment --&gt;
      ...
  &lt;/profiles&gt;
  </code></pre>
  
  <p><strong>Startup Command</strong></p>
  
  <p><code>mvn exec:java -Denvironment=local</code></p>
  
  <p>However, the profile isn't activated (confirmed using <code>help:active-profiles</code>, which produces no output). I'm pretty noobish with Maven, but shouldn't this work? </p>
  
  <p>It's my understanding that running <code>mvn</code> with the <code>-D</code> option allows me to set <em>system properties</em> (in this case: <code>environment</code> should equal <code>local</code>) which are then cross-referenced with the POM by Maven when running the application to determine which profile's activation criteria are met (per the required <code>activation properties</code>), and then running the application with those profiles active. Is there something that I'm not grokking here?</p>