Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating .settings/org.eclipse.wst.common.component file in a maven project

I working with a maven project in eclipse and am having trouble with getting the deployment to work without some manual editing of xml files.

When I build the project through maven I get a org.eclipse.wst.common.component xml file in my .settings folder. The file looks like the following:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="ins-web">           
        <wb-resource deploy-path="/" source-path="/WebContent"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/java"/>
        <property name="context-root" value="ins-web"/>
        <property name="java-output-path"/>
    </wb-module>
</project-modules>

The following line is causing the problem:

<wb-resource deploy-path="/" source-path="/WebContent"/>

Its looking to deploy everything below the WebContent folder when really it should be looking in src/webapp. The line should therefore look like this:

<wb-resource deploy-path="/" source-path="/src/webapp"/>

If I change it manually then it all works fine but I'd like to know if there is a way to avoid manually changing the file to make the build process easier for other people on my team.

like image 785
Gerard Avatar asked Jan 12 '10 12:01

Gerard


2 Answers

How are you generating your eclipse files. Are you using the m2eclipse Eclipse plugin or are your using the maven-eclipse-plugin? m2eclipse is a plugin for Eclipse, run inside Eclipse. the maven-eclipse-plugin is a Maven plugin run from the cmd line to generate Eclipse project files based on your pom.xml.

I have always had better success using the maven-eclipse-plugin. The authors of m2eclipse do not suggest you try to use both plugins together.

If you are using the maven-eclipse-plugin, you should check a couple of things.

  1. Use the latest maven-eclipse-plugin version 2.7.
  2. Make sure your project is a 'war' packaging'
  3. Configure the maven-war-plugin as well and set the war source directory as you see fit. Add the following snippet to your pom.xml. This is how the maven-eclipse-plugin determines where your webapp lives.
  <plugin>  
    <artifactId>maven-war-plugin</artifactId>  
    <version>2.1-beta-1</version>  
    <configuration>  
      <warSourceDirectory>src/webapp</warSourceDirectory>  
    </configuration>  
  </plugin>

After making these changes and running mvn eclipse:clean eclipse:eclipse again, you should see the expected value in your component file.

like image 184
Peter Lynch Avatar answered Oct 06 '22 02:10

Peter Lynch


In maven-eclipse-plugin config add...

<additionalConfig>
  <file>
    <name>.settings/org.eclipse.wst.common.component</name>
    <content>
      <![CDATA[Your file content here
      ]]>
    </content>
  </file>
</additionalConfig>
like image 25
James Gustard Avatar answered Oct 06 '22 00:10

James Gustard