Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add the directory to classpath with jetty-maven-plugin 9.x?

My Maven project was using jetty-maven-plugin version 7 and I used to add the directory to Jetty's classpath by specifying "extraClasspath" parameter in "webAppConfig", like here:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>7.0.1.v20091125</version>
  <configuration>
    <webAppConfig>
      <contextPath>/</contextPath>
      <extraClasspath>${basedir}/src/profiles/jetty</extraClasspath>
    </webAppConfig>
    <useTestClasspath>true</useTestClasspath>
  </configuration>
</plugin>

Today I decided to update to the recent version of jetty-maven-plugin and I found that there is no "extraClasspath" parameter anymore.

How could I add the directory to the classpath with last version of jetty-maven-plugin?

like image 371
Igor Bljahhin Avatar asked Jun 24 '13 17:06

Igor Bljahhin


2 Answers

Looks like it moved... this is how I got it working:

<webApp>
    <extraClasspath>${basedir}/local/properties</extraClasspath>
</webApp> 
like image 196
Steve Ardis Avatar answered Sep 28 '22 00:09

Steve Ardis


According to https://www.eclipse.org/jetty/documentation/9.3.0.v20150612/jetty-maven-plugin.html, this should work to add a resource directory in addition to webapp:

resourceBases

Use instead of baseResource if you have multiple dirs from which you want to serve static content. This is an array of dir names.

If you only wanted to change the base directory, you'd use:

baseResource

The path from which Jetty serves static resources. Defaults to src/main/webapp.

This is how I implemented resourceBases to include a directory in addition to src/main/webapp:

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty.version}</version>
    <configuration>
        <webApp>
            <contextPath>/pf</contextPath>
            <descriptor>${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml</descriptor>
            <resourceBases>
                <baseResource>src/main/webapp</baseResource>
                <baseResource>some/other/directory</baseResource>
            </resourceBases>
        </webApp>
    </configuration>
</plugin>
like image 42
meredith Avatar answered Sep 28 '22 00:09

meredith