7

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.

gizmodus
  • 188
  • 1
  • 2
  • 10
  • 1
    possible duplicate of [How to configure custom maven project structure](http://stackoverflow.com/questions/13390239/how-to-configure-custom-maven-project-structure) – maba Nov 15 '12 at 12:13
  • The question is why do you need? – khmarbaise Nov 15 '12 at 12:21
  • 1
    maba: I know that you can configure it for the war plugin, but that does not help me because I also want to be able to test it with WTP in Tomcat directly from eclipse. – gizmodus Nov 15 '12 at 12:37
  • khmarbaise: yeah, good question. Problem is that it is already set up like that and if I moved the folder then I'd somehow lose the GIT history of the files within the folder, wouldn't I? – gizmodus Nov 15 '12 at 12:38
  • You asked: *Is it possible to define a different location for the webapp folder than the standard one ("/src/main/webapp/") in pom.xml?*. And I referred to a question where that has been addressed. Now you say that you know how to configure the war plugin. – maba Nov 15 '12 at 14:33
  • 1
    If you would have read the whole post then you would have understood what I wanted to know. But anyway, I think there is no way around moving the webapp folder to the place where it belongs. – gizmodus Nov 15 '12 at 14:51

1 Answers1

14

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>
Community
  • 1
  • 1
yorkw
  • 40,926
  • 10
  • 117
  • 130