Maven生命周期的困境&x27;预集成测试&x27;
下午好 我目前正在修改POM,以便在编译代码的同时创建一个可以轻松在目标服务器上运行的部署包 父POM调用许多依次构建的模块。为了将这些模块中的所有构建构件放到一个已知位置,我添加了一个名为“distribution”的新模块,它有自己的POM。这个POM有Maven Assembly和Maven AntRun的插件 程序集插件连接到“包”生命周期中:Maven生命周期的困境&x27;预集成测试&x27;,maven,Maven,下午好 我目前正在修改POM,以便在编译代码的同时创建一个可以轻松在目标服务器上运行的部署包 父POM调用许多依次构建的模块。为了将这些模块中的所有构建构件放到一个已知位置,我添加了一个名为“distribution”的新模块,它有自己的POM。这个POM有Maven Assembly和Maven AntRun的插件 程序集插件连接到“包”生命周期中: <plugin> <artifactId>maven-assembly-plugin</artifactI
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>assembler.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<target>
<echo message="Calling ANT from Maven" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
正如你所看到的,我正在尝试使用antrun插件来完成这项工作。我现在正在做一个简单的测试,就是把一些东西输出到屏幕上
现在,当我运行mvn预集成测试时,
的“打包”阶段与以前一样工作,我看到了所有的输出。然而,当涉及到“预集成测试”阶段时,我会遇到缺少工件的问题
现在我认为,由于系统已经构建了代码,并且所有代码都在本地,那么它就不会寻找任何其他工件来引入。它正在寻找的工件位于已编译的模块之一中,因此不在本地或远程存储库中
因为我只想在“包”阶段的输出上做一些工作,所以我不需要下载任何东西,但我不确定如何才能做到这一点。我一直在网上四处寻找,试图找出如何绕过这个问题,但所有的例子似乎都显示出与我所做的类似的东西
如果有人对我做错了什么有任何指点,请让我知道。
我希望我已经提供了所有需要的信息,但是如果你还需要,请告诉我,我会很乐意提供
提前非常感谢
拉塞尔
更新:2012-02-08 1450
根据Andrews的建议,我稍微修改了分发POM,使AntRun插件成为同一“包”阶段的一部分。我无法将其附加到同一个目标,因为AntRun插件没有“single”作为目标,所以我将其保留为run
不幸的是,我看到了同样的问题,系统试图从已经构建的存储库下载一些东西。我得到的错误类型是:
Downloading: http://nexus/nexus/content/groups/public/com/example/fire/fire-apis/latest-SNAPSH
OT/fire-apis-latest-20120208.061113-108.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) com.example.fire:fire-apis:jar:latest-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.example.fire -DartifactId=fire-apis -Dversion=latest-20120208.0611
13-108 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.example.fire -DartifactId=fire-apis -Dversion=latest-20120208.061113
-108 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.example.fire:distribution:pom:latest-SNAPSHOT
2) com.example.fire:fire-apis:jar:latest-SNAPSHOT
----------
1 required artifact is missing.
for artifact:
com.example.fire:distribution:pom:latest-SNAPSHOT
from the specified remote repositories:
public-mirror (http://nexus/nexus/content/groups/public)
我对此感到困惑,因为我认为这将是实现这一目标的方法。我知道我错过了什么。如果有帮助的话,我可以发布日志,但它会很大
更新:2012-02-09 1130
为了让人们更好地了解我在做什么,我在Pastebin上发布了一些信息
亲本聚甲醛-
分配模块POM-
Maven调试日志-
这是与AntRun部分相关的主日志文件末尾的一个片段。(主日志文件超过11Mb!!)
要使用useAllReactorProjects
标志完成所有这些打包,我遵循了本页中的示例
谢谢。早上好
在花了一些时间研究这个问题之后,我想我已经找到了答案
正如我在上次更新中提到的,我在这个链接中遵循了这个示例。此页面显示了分发模块的POM示例,其中它具有一个依赖项,以确保其他模块在分发之前构建
我修改了它,以包括系统试图从存储库中获取的项目,如日志文件所示。我已经评论了这一点,现在我的AntRun工作正常
我唯一担心的是,现在的顺序可能不正确。我希望在列表的末尾有一个“分发”模块,那么它将在最后构建
谢谢你的帮助
Russell很高兴听到问题已经解决=)在我们的大多数项目中,我们都有“包”实用程序模块,它总是排在最后,并且依赖于其他模块。这种方法似乎效果不错。
Downloading: http://nexus/nexus/content/groups/public/com/example/fire/fire-apis/latest-SNAPSH
OT/fire-apis-latest-20120208.061113-108.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) com.example.fire:fire-apis:jar:latest-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.example.fire -DartifactId=fire-apis -Dversion=latest-20120208.0611
13-108 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.example.fire -DartifactId=fire-apis -Dversion=latest-20120208.061113
-108 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.example.fire:distribution:pom:latest-SNAPSHOT
2) com.example.fire:fire-apis:jar:latest-SNAPSHOT
----------
1 required artifact is missing.
for artifact:
com.example.fire:distribution:pom:latest-SNAPSHOT
from the specified remote repositories:
public-mirror (http://nexus/nexus/content/groups/public)