Maven的码头插件的问题 [英] maven-jetty-plugin question

查看:100
本文介绍了Maven的码头插件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模块测试之前,我需要开始跳船.示例:

I need to start jetty before module tests. Example:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>jetty-test</groupId>
    <artifactId>jetty-test</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>1.0-beta-6</version>
            </extension>
        </extensions>
        <plugins>
                <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo>Hello world!</echo>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.26</version>
                <executions>
                    <execution>
                        <id>start-webapp-for-module-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-webapp-for-module-tests</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <daemon>true</daemon>
                    <stopPort>8181</stopPort>
                    <stopKey>stop-webapp</stopKey>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

一切正常,但是maven-antrun-plugin(或在测试编译阶段之前的任何其他插件)开始运行两次.我尝试使用运行一战",运行扩展"或部署一战"目标.结果是一样的.

Everything works, but maven-antrun-plugin (or any other plugin before test-compile phase) begins to run two times. I tried to use run-war, run-exploaded or deploy-war goals. Result is the same.

Maven输出:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - jetty-test:jetty-test:war:1.0
[INFO]    task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test-compile}]
[INFO] Executing tasks

main:
     **[echo] Hello world!**
[INFO] Executed tasks
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] Preparing jetty:run
[WARNING] Removing: run from forked lifecycle, to prevent recursive invocation.
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test-compile}]
[INFO] Executing tasks

main:
     **[echo] Hello world!**
[INFO] Executed tasks
[INFO] [jetty:run {execution: start-webapp-for-module-tests}]
[INFO] Configuring Jetty for project: Unnamed - jetty-test:jetty-test:war:1.0
[INFO] Webapp source directory = /home/chardex/projects/untitled/jetty-test/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /home/chardex/projects/untitled/jetty-test/target/classes does not exist
2010-12-24 16:50:17.254:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /jetty-test
[INFO] Tmp directory =  determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = /home/chardex/projects/untitled/jetty-test/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /home/chardex/projects/untitled/jetty-test/src/main/webapp
[INFO] Starting jetty 6.1.26 ...
2010-12-24 16:50:17.316:INFO::jetty-6.1.26
2010-12-24 16:50:17.416:INFO::No Transaction manager found - if your webapp requires one, please configure one.
[INFO] Started Jetty Server
[INFO] [jetty:stop {execution: stop-webapp-for-module-tests}]
2010-12-24 16:50:17.603:INFO::Started SelectChannelConnector@0.0.0.0:8080
[INFO] Stopping server 0
2010-12-24 16:50:17.637:INFO::Stopped SelectChannelConnector@0.0.0.0:8080
[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[jetty-test] in [/home/chardex/projects/untitled/jetty-test/target/jetty-test-1.0]
[INFO] Processing war project
[INFO] Copying webapp resources[/home/chardex/projects/untitled/jetty-test/src/main/webapp]
[INFO] Webapp assembled in[25 msecs]
[INFO] Building war: /home/chardex/projects/untitled/jetty-test/target/jetty-test-1.0.war
[INFO] [install:install {execution: default-install}]
...

我错了吗?

谢谢.

推荐答案

根据

此目标在Maven上原位使用 无需首先要求的项目 项目集结成一场战争, 在开发过程中节省时间 循环.该插件可以并行处理 生命周期,以确保编译" 阶段之前已经完成 调用码头.这意味着你做 无需明确执行"MVN 编译".这也意味着 "mvn clean jetty:run"将确保 完整的新鲜编译之前完成 调用码头.

This goal is used in-situ on a Maven project without first requiring that the project is assembled into a war, saving time during the development cycle. The plugin forks a parallel lifecycle to ensure that the "compile" phase has been completed before invoking Jetty. This means that you do not need to explicity execute a "mvn compile" first. It also means that a "mvn clean jetty:run" will ensure that a full fresh compile is done before invoking Jetty.

这说明了行为.

这篇关于Maven的码头插件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆