Javascript – How to make the maven jetty plugin aware of an additional web directory

javascriptjettymaven

I would like to use src/main/javascript as the source directory for my javascript files while still using src/main/webapp for most other web files but the maven jetty:run plugin does not know about this directory by default.

The following is as far as I've gotten so far but it does not seem to make Jetty aware of my javascript directory:

<build>
  <plugins>
    <plugin>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>maven-jetty-plugin</artifactId>
      <version>6.1.12</version>
      <configuration>
        <webAppConfig>
          <contextPath>/${project.artifactId}</contextPath>
          <extraClasspath>target/classes/:src/main/javascript</extraClasspath>
        </webAppConfig> 
        <webResources>
          <resource>
            <directory>src/main/webapp</directory>
            <directory>src/main/javascript</directory>
          </resource>
        </webResources>
      </configuration>
    </plugin>

How do I make the maven jetty plugin aware of this addtional web directory?

Best Answer

Looks like this could help you:

So i'd amend your configuration as follows:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.12</version>
  <configuration>
    <webAppConfig>
      <contextPath>/${project.artifactId}</contextPath>
      <!-- Javascript files are not java class files, so you can skip this
      <extraClasspath>target/classes/:src/main/javascript</extraClasspath>
      -->
      <baseResource implementation="org.mortbay.resource.ResourceCollection">
        <resourcesAsCSV>src/main/webapp,src/main/javascript</resourcesAsCSV>
      </baseResource>
    </webAppConfig> 
  </configuration>
</plugin>