Simulating "java-only" lifecycle mapping with m2e 0.9.9.200909092308

Skip to end of metadata
Go to start of metadata

Description.

Profile activation

m2e profile is activated by m2e.version property, which is set by m2e automatically. This profile will be used when working on the project in m2e workspace, but will be ignored during cli maven invocation.

Lifecycle mapping

org.maven.ide.eclipse.jdt.javaConfigurator project configurator enables m2e/jdt integration for the project. m2e will update Java project preferences based on pom.xml during project import and when updating maven project configuration. It will also manage Maven Dependencies classpath container for the project. Compilation of java classes is delegated to regular Eclipse JDT Java Builder.

maven-resources-plugin mojo execution tells m2e to run maven-resources-plugin during Eclipse full or incremental build. This will copy/filter if necessary resources.

m2e ignores all other mojos bound to the project build lifecycle.

resources plugin version

maven-resources-plugin version is locked to 2.4.3. When executed from m2e, this version will only process changed resources and it will notify m2e about resources copied to the project build output folder.

Code

    <profile>
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.maven.ide.eclipse</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>0.10.0</version>
            <configuration>
              <mappingId>customizable</mappingId>
              <configurators>
                <configurator id='org.maven.ide.eclipse.jdt.javaConfigurator' />
              </configurators>
              <mojoExecutions>
                <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
              </mojoExecutions>
            </configuration>
          </plugin>
        </plugins>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.4.3</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
mojoExecution element
<mojoExecution/> element value is a mask used to select goals from goals bound to the project execution lifecycle. The mask uses the following format

groupId:artifactId:[version]:[goal[,goal]*]

i.e., version and goal(s) parts are optional, while groupId, artifactId and colons are not. If version is omitted, the mask will match any version. Likewise, if goal is omitted, the mask will match any goal.

Additionally, <mojoExecution/> element supports boolean attribute boolean runOnIncremental, i.e. <mojoExecution runOnIncremental="false">. This attribute is true by default. If set to false, matching goal(s) will be executed during full workspace build only and will be ignored during incremental builds.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 23, 2010

    Fred Bricon says:

    In a similar way, for EAR projects which are not supposed to have a Java nature,...

    In a similar way, for EAR projects which are not supposed to have a Java nature, but where the WTP configurator is needed, you would use :

        <profiles>
            <profile>
              <id>m2e</id>
              <activation>
                <property>
                  <name>m2e.version</name>
                </property>
              </activation>
              <build>
                <plugins>
                  <plugin>
                    <groupId>org.maven.ide.eclipse</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>0.9.9-SNAPSHOT</version>
                    <configuration>
                      <mappingId>customizable</mappingId>
                      <configurators>
                        <configurator id='org.maven.ide.eclipse.configuration.wtp.configurator' />
                      </configurators>
                      <mojoExecutions>
                        <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
                      </mojoExecutions>
                    </configuration>
                  </plugin>
                </plugins>
                <pluginManagement>
                  <plugins>
                    <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-resources-plugin</artifactId>
                      <version>2.4</version>
                    </plugin>
                  </plugins>
                </pluginManagement>
              </build>
            </profile>   
        </profiles>

    In order to remove the Java nature from existing EAR projects, you will, from outside eclipse :

    * delete the .classpath file

    * remove the following lines from the .project file

            <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
                <arguments>
                </arguments>
            </buildCommand>

    and

           <nature>org.eclipse.jdt.core.javanature</nature>

    * delete the ./settings/org.eclipse.jdt.core.prefs file

    Once you have cleansed the files, refresh the ear project (F5) then update the maven project configuration

    Another more radical solution would be to logically delete the ear project from eclipse, physically delete .project, .classpath and .settings/, then reimport as an "existing maven project" in the workspace.

  2. Jan 27, 2010

    David Durham says:

    I'm using jboss 5.1 and eclipse wtp. Using this configuration in my project po...

    I'm using jboss 5.1 and eclipse wtp.

    Using this configuration in my project pom.xml solves some things for me:

    1 - the project configuration works (without this addition, the project config fails to add workspace dependencies and I see the following log message:)

    org.apache.maven.plugin.MojoExecutionException: Failed to copy /home/ddurham/work/ds-framework/management-console/client/target/classes
            at org.sonatype.flexmojos.war.CopyMojo.copy(CopyMojo.java:345)
            at org.sonatype.flexmojos.war.CopyMojo.execute(CopyMojo.java:154)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:547)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:317)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:239)

    2 - The resources are copied into web-inf/classes ... yay!

    Unfortunately have a small problem where no jar files from the classpath make it in my .war file for jboss deploy.  So problem remains.

    1. Feb 23, 2010

      Fred Bricon says:

      You should bring that up to the user mailing list or https://issues.sonatype.org...

      You should bring that up to the user mailing list or https://issues.sonatype.org/browse/MNGECLIPSE (attaching a sample project would be great).

      The solution\workaround to your problem might then be added back to this wiki.