views:

202

answers:

2

Hi,for a project I'm working on, I've defined a custom maven packaging, and the associated lifecycle (through the definition of a components.xml and the definition of a LifecycleMapping).

Obviously, this packaging corresponds to a specific development, for which a plugin has been created in Eclipse. What I would like to do is configure Eclipse according to my pom.xml content.

I've obviously looked at Customizable build lifecycle, but I'm more than confused by provided information.

From what I understand, I must define in my target project a build plugin, in which i'll add configuration elements specific to my project. As an example, having a configurator called mycompany.mydev.MyEclipseConfigurator, I'll have to write

  <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='mycompany.mydev.MyEclipseConfigurator'/>
          </configurators>
        </configuration>
      </plugin>
    </plugins>
  </build>

Am I right ?

A: 

In fact, previously mentionned documentation refers to deprecated version of maven eclipse plugin.

The most up-to-date version clearly states how to configure eclipse project from within maven pom.xml by specifying project's nature and builders.

Riduidel
+1  A: 

The problem I had with our custom packaging, is that Maven did not recognize the project as being Java-based, hence the Maven Eclipse Plugin did not generate the right entries in the .project file, and did not generate a .classpath.

The first thing can be corrected by adding the right build commands and natures in the POM, but that still does not give you a .classpath.

The solution is to add the following fragment to your components.xml:

  <component>
        <role>org.apache.maven.artifact.handler.ArtifactHandler
        </role>
        <role-hint>(fill in your own packaging)</role-hint>
        <implementation>
            org.apache.maven.artifact.handler.DefaultArtifactHandler
        </implementation>
        <configuration>
            <type>(fill in your own packaging)</type>
            <extension>(choose war or jar if required)</extension>
            <language>java</language>
            <addedToClasspath>true</addedToClasspath>
        </configuration>
    </component>

With this addition, the MEP will treat your project as a normal JAR or WAR project and generate the expected Eclipse configuration for it.

Janneman