Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Change webapp folder in Maven pom.xml file

Is it possible to define a different location for the webapp folder than the standard one ("/src/main/webapp/") in pom.xml? I know that you can define your web folder with

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

in a file called "org.eclipse.wst.common.component". The problem is when I click Maven -> Update Project, this line is overwritten with the standard

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

And then I have problems testing my project with Tomcat7 within Eclipse. I'm very thankful for every hint.

like image 683
gizmodus Avatar asked Nov 15 '12 12:11

gizmodus


People also ask

How do I edit a pom xml file?

To open the POM Editor, click on a project's pom. xml file. If you've customized the editors for a pom. xml file, and the POM Editor is not the default editor, you may need to right-click on the file and choose "Open With... / Maven POM Editor".


1 Answers

Answers in How to configure custom maven project structure are sufficient for a purely Maven build, i.e. from commandline. When import the project into Eclipse (via m2e), you need tell m2e a little bit more so that it can create and maintain the project structure properly within Eclipse.

Actually, from Eclipse's perspective, it doesn't really care about how your project folder structure looks like, as long as the webapp folder is declared as a source folder or inside a source folder, however, by modifying .classpath doesn't make much sense as it's a auto-generated file and changed quite often.

It is highly recommended to obey the convention if you are able to, if not, using the following configuration for your customization:

<build>
  <resources>
    <resource>
      <directory>${basedir}/webapp</directory>
    </resource>
    ... ...
  </resources>
  ... ...
</build>
like image 118
yorkw Avatar answered Sep 25 '22 00:09

yorkw