简体   繁体   中英

Maven failsafe: Start jetty in different directory

I have a maven project with different modules, one of them containing my web services container, another containing my integration tests looking something like this:

-ProjectRoot
--[...]
--WebService
--IntegrationTests

I would like to use the failsafe plugin to carry out the integration tests and start the jetty server in the pre-integration-test life cycle, but I can't figure out how to start the jetty server inside the WebService directory.

I carry out the test by mvn clean install in the ProjectRoot directory.

I included this in the pom.xml on the top-level:

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty.version}</version>
    <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <stopPort>8005</stopPort>
        <stopKey>STOP</stopKey>
        <stopWait>10</stopWait>
    </configuration>
    <executions>
        <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <daemon>true</daemon>
            </configuration>
    </execution>
        <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The path to the webapp can be configured like this:

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webAppSourceDirectory>path/to/webapp</webAppSourceDirectory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM