BillMan
BillMan

Reputation: 9934

Is there a way to add directories to the classpath in the maven jetty plugin from the command line

I am running jetty with maven using the jetty plugin using the command mvn jetty:run.

Is there a command line option to add an external directory to the classpath? Something like the java -cp option?

TIA

Upvotes: 1

Views: 3089

Answers (3)

jbylsma
jbylsma

Reputation: 21

If you define a Maven property for extraClasspath, you can pass a custom extraClasspath value with a command line system property. For example, if you're POM had the following:

<properties>
  <jetty.extraClasspath />
</properties>

...

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.14.v20181114</version>
  <configuration>
    <webApp>
      <extraClasspath>${jetty.extraClasspath}</extraClasspath>
    </webApp>
  </configuration>
</plugin>

You could specify the extra classpath with mvn jetty:run -Djetty.extraClasspath=../resources/.

Upvotes: 2

Juh_
Juh_

Reputation: 15549

From what is printed by mvn jetty:help -Ddetail=true -Dgoal=run, it looks like it is not possible from command line

Upvotes: 0

Peter Szanto
Peter Szanto

Reputation: 7722

Have you tried the solution suggested here:

Adding classpath to jetty running in maven integration-test

<webAppConfig>
  <contextPath>/nportal</contextPath>
  <!-- All I want to do here is add in the /etc/jetty/classes for runtime files. For some reason I have to also add back in the /target/classes directory -->
  <extraClasspath>${basedir}/target/classes/;${basedir}/etc/jetty/classes/</extraClasspath>
</webAppConfig> 

Upvotes: 1

Related Questions