views:

1801

answers:

2

I have two projects, one called my-lib, the other one is my-webapp. As I use Maven2, I set my-lib as a dependency of my-webapp.

In Eclipse, I need to have my-lib set as a "Java EE Module dependencies" for my-webapp.

Is there a way to make this dependency set when I run the mvn eclipse:clean eclipse:eclipse command? For the moment, everytime I run this command on my project, then my-lib is not defined as a Java EE Module Dependency of my-webapp, and then I need to set it manually.

+1  A: 

You can specify that the wtpmanifest property be set in configuration for the eclipse plugin. The documentation is a little vague, but it may do what you need as the EE Module dependencies are defined by modifying the Manifest.MF file.

From the documentation:

wtpmanifest:

Must the manifest files be written for java projects so that that the jee classpath for wtp is correct.

You can specify the Manifest yourself and have it included in the Eclipse configuration to ensure it contains all the required modules as follows:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-eclipse-plugin</artifactId>
  <configuration>
    <wtpmanifest>true</wtpmanifest>
    <wtpapplicationxml>true</wtpapplicationxml>
    <wtpversion>2.0</wtpversion>
    <manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
  </configuration>
</plugin>
Rich Seller
It does not seems to work. What I found is that the file containing the information is my-web/.settings/org.eclipse.wst.common.component. However, I don't know how to set the adequate information in it. With additionalConfig (http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html#additionalConfig), I can set the whole content but I cannot append something to the file...
romaintaz
Sorry that doesn't help. To be honest I find eclipse:eclipse to be far more trouble than it's worth. Instead I use m2eclipse, set my projects up with all the required content, then commit the eclipse metadata files to SCM
Rich Seller
I find that it works for some combinations of maven, eclipse and WTP but not all.
sal
A: 

You might need to adjust the maven-eclipse-plugin to add the little bits of magic to the dot-files. There is not short-cut here. You have to look at the working files and reverse engineer it into the maven config. And even then, there it is only likely to work with some combinations of Maven, Eclipse and WTP. My example might help if your need stuff added to your .project file. For .settings, this might help you start your search for the right bit of magic. This is one of those solutions where you end up holding your nose as you implement it.

  <plugin>
    <artifactId>maven-eclipse-plugin</artifactId>
      <configuration>
      <additionalProjectnatures>
      <projectnature>missing.magic.natures</projectnature>
      </additionalProjectnatures>
      <buildcommands>
       <buildcommand>missing.magic.builders</buildcommand>
      </buildcommands>
      <classpathContainers>
         <classpathContainer>magic.jre.stuff</classpathContainer>
      </classpathContainers>
      <additionalConfig>
       <file>
        <name>.settings/magic-file</name>
        <content>
        <![CDATA[
         <?xml version="1.0" encoding="UTF-8"?>
         <xyzzy>plugh</xyxxy>
         ]]>
        </content>
       </file>
      </additionalConfig>
     </configuration>
  </plugin>
sal