maven-2maven-jetty-plugin

Multi-module Maven project and jetty:run


I'm trying to split a Maven WAR project into two modules, so that I can build a separate JAR file with command line tools. The result has the following structure:

If I run mvn commands from the root, everything works fine. I'd like to keep using mvn jetty:run, but for that I need to execute the command in the WAR subproject. If I do that, fails to find the project-jar subproject, so it won't run. Even mvn jetty:run-war with a completely assembled WAR file in the target directory fails, because it first tries to "build" the project. I've only managed to make it work by installing project-jar into the local Maven repository, which isn't very nice.

Is there a way to use the Jetty plugin in a multi-module Maven configuration?


Solution

  • There is no magical solution and the only one I know is a bit hacky and rely on the extraClasspath element that you can use to declare extra class directories, relatively. Like this (from JETTY-662):

    <plugin>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>7.0.1.v20091125</version>
      <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <webAppConfig>
          <contextPath>/my-context</contextPath>
          <extraClasspath>target/classes;../my-jar-dependency/target/classes</extraClasspath>
        </webAppConfig>
        <scanTargets>
          <scanTarget>../my-jar-dependency/target/classes</scanTarget>
        </scanTargets>
      </configuration>
    </plugin>