title: 2 exec-maven-plugin defined in POM - not working
body: <p>I have two Java main classes that I need executed during different parts of a build process. One needs to execute ALWAYS as part of my standard build process during the <code>generate-sources</code> phase. The other needs to execute as part of a profile, but that profile should be execute at the end of the <code>process-classes</code> phase, which should also include the <code>generate-sources</code> phase prior to that.</p>
  
  <p>I was able to get the first plugin working correctly during the <code>generate-sources</code> phase of the standard build process:</p>
  
  <pre><code>            &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;generate-sources&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;java&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;com.example.MySourceGenerator&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>However when I added a second instance of the same plugin to the profile, the plugin defined as part of the standard build is no longer invoked during my build process, resulting in compile errors. This is the configuration in the profile:</p>
  
  <pre><code>&lt;profiles&gt;
          &lt;profile&gt;
              &lt;id&gt;initSchema&lt;/id&gt;
              &lt;build&gt;
                  &lt;plugins&gt;
                      &lt;plugin&gt;
                          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                          &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                          &lt;version&gt;1.2.1&lt;/version&gt;
                          &lt;executions&gt;
                              &lt;execution&gt;
                                  &lt;phase&gt;process-classes&lt;/phase&gt;
                                  &lt;goals&gt;
                                      &lt;goal&gt;java&lt;/goal&gt;
                                  &lt;/goals&gt;
                              &lt;/execution&gt;
                          &lt;/executions&gt;
                          &lt;configuration&gt;
                              &lt;mainClass&gt;com.example.SomeOtherClass&lt;/mainClass&gt;
                          &lt;/configuration&gt;
                      &lt;/plugin&gt;
                  &lt;/plugins&gt;
              &lt;/build&gt;
          &lt;/profile&gt;
      &lt;/profiles&gt;
  </code></pre>
  
  <p>This is what I run on the command line: <code>mvn process-classes -PinitSchema</code>. What is wrong with my configuration? I am expecting both plugins to execute during their respective phases.</p>
  
  <p>To clarify: the first exec-maven-plugin generates sources and the second one initialized my DB schema.</p>
  
  <p>EDIT: 
  Here is the output</p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO]                                                                         
  [INFO] ------------------------------------------------------------------------
  [INFO] Building ABC Web Application 1.0-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  ...
  [INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ web-app ---
  [INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/msg added.
  [INFO] 
  [INFO] --- maven-processor-plugin:2.0.6:process (process) @ web-app ---
  [INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt added
  [INFO] javac option: -cp
  ...
  [INFO] javac option: -proc:only
  [INFO] javac option: -processor
  [INFO] javac option: com.company.vocab.generator.VocabAnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
  [INFO] javac option: -d
  [INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
  [INFO] javac option: -s
  [INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt
  [INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
  [INFO] diagnostic /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/AccountDto.java:5: error: cannot find symbol
  import com.telos.xacta.util.Messages;
  ...
  (more similar messages)
  [INFO] 
  [INFO] --- jaxb2-maven-plugin:1.5:xjc (default) @ web-app ---
  [INFO] Generating source...
  [INFO] parsing a schema...
  [INFO] compiling a schema...
  ...
  [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ web-app ---
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] Copying 16 resources
  [INFO] 
  [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web-app ---
  [INFO] Changes detected - recompiling the module!
  [INFO] Compiling 281 source files to /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
  [INFO] -------------------------------------------------------------
  ...
  [ERROR] COMPILATION ERROR : 
  [INFO] -------------------------------------------------------------
  [ERROR] /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/ProjectHeadDto.java:[4,28] cannot find symbol
    symbol:   class Messages
    location: package com.company.util
  ...
  (more similar errors)
  ...
  [INFO] 29 errors 
  [INFO] -------------------------------------------------------------
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 8.817s
  [INFO] Finished at: Thu Aug 01 20:49:07 EDT 2013
  [INFO] Final Memory: 31M/282M
  [INFO] ------------------------------------------------------------------------
  </code></pre>