java – Maven发布:准备目标
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – Maven发布:准备目标,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5379字,纯文字阅读大概需要8分钟。
内容图文
![java – Maven发布:准备目标](/upload/InfoBanner/zyjiaocheng/748/b3392db6ebc348f7978af60ef5beffa2.jpg)
我们的POM文件中有以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
这可确保在测试阶段不执行测试.测试仅在集成测试阶段执行.
但是,当我们准备发布(发布:准备)时,maven在测试阶段执行测试.这导致我们的构建失败,因为我们的测试只能在集成测试阶段运行(我们使用tomcat-maven插件在执行测试之前部署打包的war).
我知道我们可以通过传递参数(-DskipTests等)来跳过测试.我们不想跳过任何测试,我们只想要发布:准备执行就像任何其他maven目标一样.
任何建议/帮助都非常感谢.
解决方法:
尝试使用更通用的方法在测试阶段完全禁用maven-surefire-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<!-- Disable the default-test by putting it in phase none -->
<phase>none</phase>
</execution>
<execution>
<!-- Enable the test during integration-test phase -->
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
编辑
这是我的mvn版本的干运行输出:使用上面配置的surefire插件进行准备:
C:\Users\maba\Development\svn\local\stackoverflow\Q12840869>mvn release:prepare -DdryRun [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Q12840869-1.0-SNAPSHOT 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.0:prepare (default-cli) @ Q12840869 --- [INFO] Resuming release from phase 'scm-check-modifications' [INFO] Verifying that there are no local modifications... [INFO] Executing: cmd.exe /X /C "svn --non-interactive status" [INFO] Working directory: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869 [INFO] Checking dependencies and plugins for snapshots ... What is the release version for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) 1.0: : What is SCM release tag or label for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) Q12840869-1.0: : What is the new development version for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) 1.1-SNAPSHOT: : [INFO] Transforming 'Q12840869-1.0-SNAPSHOT'... [INFO] Not generating release POMs [INFO] Executing preparation goals - since this is simulation mode it is running against the original project, not the rewritten ones [INFO] Executing goals 'clean verify'... [WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance. [INFO] [INFO] Scanning for projects... [INFO] [INFO] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Building Q12840869-1.0-SNAPSHOT 1.0-SNAPSHOT [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] [INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ Q12840869 --- [INFO] [INFO] Deleting C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target [INFO] [INFO] [INFO] [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ Q12840869 --- [INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] [INFO] Copying 0 resource [INFO] [INFO] [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ Q12840869 --- [INFO] [INFO] Compiling 1 source file to C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\classes [INFO] [INFO] [INFO] [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ Q12840869 --- [INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] [INFO] skip non existing resourceDirectory C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\src\test\resources [INFO] [INFO] [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Q12840869 --- [INFO] [INFO] Compiling 1 source file to C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\test-classes [INFO] [INFO] [INFO] [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ Q12840869 --- [INFO] [INFO] Building jar: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\Q12840869-1.0-SNAPSHOT.jar [INFO] [INFO] [INFO] [INFO] --- maven-surefire-plugin:2.7.2:test (surefire-it) @ Q12840869 --- [INFO] [INFO] Surefire report directory: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\surefire -reports [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running com.stackoverflow.MainTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.041 sec [INFO] [INFO] Results : [INFO] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Total time: 5.102s [INFO] [INFO] Finished at: Thu Oct 11 17:10:29 CEST 2012 [INFO] [INFO] Final Memory: 13M/147M [INFO] [INFO] ------------------------------------------------------------------------
内容总结
以上是互联网集市为您收集整理的java – Maven发布:准备目标全部内容,希望文章能够帮你解决java – Maven发布:准备目标所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。