问题
I am using the jetty-maven plugin to deploy a web-app for integration testing. I have a project which consists of a two POMs. One in the root, and one in a directory in the project root (call this the webapp directory). When I run the integration test from maven (which uses the jetty-maven plugin), in the webapp directory, it works perfectly fine. However, when I run it from the root directory, it goes inside the webapp directory and runs the test but for some reason it gets the paths wrong. (As a result, all resources cannot be found).
It concatenates the root directory path to the webapp resources path. It also does not understand the dot operator in a path.
For example: if it was to look for "./resources/resource.xml"
It would work fine if the test was run from the webapp directory, however if run from the root directory it will make the path: "c:/project/./resources/resource.xml". It is the jetty-maven plugin that is doing this but I am not sure why.
Is there a way to fix this?
Here is relevant part of my webapp directory POM
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>${basedir}/target/webappSNAPSHOT.war</webApp>
<extraClasspath>${project.build.testOutputDirectory}</extraClasspath>
<testClassesDirectory>${basedir}/target/test-classes</testClassesDirectory>
<useTestClasspath>true</useTestClasspath>
<stopPort>9929</stopPort>
<stopKey>stopKey</stopKey>
</configuration>
回答1:
Most likely you just need to specify ${basedir} in your web app resources path.
来源:https://stackoverflow.com/questions/6427600/maven-jetty-plugin-not-using-correct-paths