September 29, 2014

HOW-TO execute a maven plugin within eclipse?


If you're running maven with eclipse you've probably been frustrated by "Plugin execution not covered by lifecycle configuration" error. Well after while I finally managed to get it to do what I wanted. The key is that there is a org.eclipse.m2e:ifecycle-mapping maven plugin that does nothing but let eclipse know how you want to handle a specific goal. For instance in the following example
I've instructed to execute the hibernate3-maven-plugin:run goal.  If you take a look at the eclipse doc you'll see there is also an ignore option. For the longest time, I was just setting them to ignore but recently I learned about the execution option. This seems to work for me although for certain incremental builds its not re-executing the command.

It does however seem to alway run when I do an eclipse clean.




    <buld>
  <pluginManagement>
   <plugins>
    <plugin>
     <groupid>org.eclipse.m2e</groupid>
     <artifactid>lifecycle-mapping</artifactid>
     <version>1.0.0</version>
     <configuration>
      <lifecyclemappingmetadata>
       <pluginexecutions>
        <pluginexecution>
         <pluginexecutionfilter>
          <groupid>org.codehaus.mojo</groupid>
          <artifactid>hibernate3-maven-plugin</artifactid>
          <versionrange>[3.0,)</versionrange>
          <goals>
           <goal>run</goal>
          </goals>
         </pluginexecutionfilter>
         <action>
          <execute>
         </execute></action>
        </pluginexecution>
       </pluginexecutions>
      </lifecyclemappingmetadata>
     </configuration>
    </plugin>
   </plugins>      
         
          
         
        
       
      
     
    
   
  
 


No comments: