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

2

6

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?

Mascot answered 24/6, 2013 at 17:54 Comment(0)
A
4

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

<webApp>
    <extraClasspath>${basedir}/local/properties</extraClasspath>
</webApp> 
Amersfoort answered 26/11, 2013 at 14:46 Comment(2)
I'm having a hard time with this. Somethings moved and Jetty not complains/warns about it.Pastel
#17949706Messmate
A
2

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>
Absorption answered 24/3, 2016 at 19:16 Comment(1)
The question is about adding the directory to classpath, not to the resources.Mascot

© 2022 - 2024 — McMap. All rights reserved.