Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Additional maven source folders such as src/main/javascript or src/main/css?

I've been developing a standard web app and its really annoying to have Eclipse show src/main/resources and src/main/java in such a convenient flat-package way, yet I have to frequently drill down into src/main/webapp and all its subdirectories to modify my css, js, and html files.

I've never seen a project use additional source folders for resources like those, but is it out of the question to try? Ideally I'd love to have a directory structure like

src/main/java
src/main/resources
src/main/jsp
src/main/javascript
src/main/css

Has anyone setup a project like this? Does it become more of a hassle to even try, breaking existing plugins and whatnot?

like image 509
ant-depalma Avatar asked Jun 11 '13 11:06

ant-depalma


1 Answers

Add resource folders this way.

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory>resource1</directory>
     </resource>
     <resource>
       <directory>resource2</directory>
     </resource>
     <resource>
       <directory>resource3</directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>

More information

However, if you want multiple web resources (WEB-INF directory in WAR file) than you need to configure Maven War plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <webResources>
          <resource>
            <directory>src/main/jsp</directory>
          </resource>
          <resource>
            <directory>src/main/javascript</directory>
          </resource>
          <resource>
            <directory>src/main/css</directory>
          </resource>
        </webResources>
      </configuration>
    </plugin>
  </plugins>
</build>
like image 194
Grzegorz Żur Avatar answered Sep 27 '22 01:09

Grzegorz Żur