5

I am setting up a maven web app project in eclipse, maven likes to put the webapp resources in src/main/webapp which is a pain to navigate to because I have to click three times to get to webapp contents.

  • click 1 expand src
  • click 2 expand main
  • click 3 expand webapp

Example of three levels of clicks needed to navigate to webapp

In a typical WTP eclipse project there is only WebContent and is a top level folder so only one click is needed to get into it.

Is there an eclipse or m2e trick to make the webapp show up as a top level element under the project.

ams
  • 60,316
  • 68
  • 200
  • 288

2 Answers2

5

If it makes your life easier, you can override the webapp directory location to hang directly off ${basedir}

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <warSourceDirectory>${basedir}/webapp</warSourceDirectory>
    </configuration>
  </plugin>
Alexander Pogrebnyak
  • 44,836
  • 10
  • 105
  • 121
4

Right click the webapp folder and select Build Path -> Use as Source Folder. The folder will be presented on top (in a hierarchical package presentation). It should have no side effects to the final war.

enter image description here

FrVaBe
  • 47,963
  • 16
  • 124
  • 157
  • 2
    I used to do this, but actually it is a bit ugly because webapp is then handled as a source folder for Java classes, so it's just a hack. According to http://stackoverflow.com/a/1664247/1620264 it must be possible to set it as a Web Resources folder, but I couldn't figure out how to do that yet – marcelj Feb 18 '14 at 11:08