build-helper的add-test-sources功能的bug
2011-05-31 08:56
323 查看
最新在项目中需要修改Maven创建的目录结构,需要添加一些source目录。熟悉maven的同学都知道,如果需要修改目录结构,可以通过修改pom.xml完成。具体如下:
Maven能够按照标准化的方式来编译、打包等就是依赖于安装目录apache-maven-2.2.1\lib下的maven-2.2.1-uber.jar下面的org\apache\maven\project\pom-4.0.0.xml来完成的。那如果需要增加源代码包和测试源代码包该如何办呢? 使用build-helper来完成。
build-helper是maven的plugin, 官网:http://mojo.codehaus.org/build-helper-maven-plugin/, 使用说明:http://mojo.codehaus.org/build-helper-maven-plugin/usage.html
(1)增加源代码包
(2)添加测试源代码包
添加测试源代码包后,通过mvn eclipse:eclipse生成eclipse工程之后,却无法在eclipse的源代码build path中看到,而添加源代码包是可以的。查阅了官网的bug库,该bug至今处于open状态。参考:https://issues.sonatype.org/browse/MNGECLIPSE-2387
<build> <directory>${project.basedir}/target</directory> <outputDirectory>${project.build.directory}/classes</outputDirectory> <finalName>${project.artifactId}-${project.version}</finalName> <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory> <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> <!-- TODO: MNG-3731 maven-plugin-tools-api < 2.4.4 expect this to be relative... --> <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> <resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> <testResources> <testResource> <directory>${project.basedir}/src/test/resources</directory> </testResource> </testResources> </build>
Maven能够按照标准化的方式来编译、打包等就是依赖于安装目录apache-maven-2.2.1\lib下的maven-2.2.1-uber.jar下面的org\apache\maven\project\pom-4.0.0.xml来完成的。那如果需要增加源代码包和测试源代码包该如何办呢? 使用build-helper来完成。
build-helper是maven的plugin, 官网:http://mojo.codehaus.org/build-helper-maven-plugin/, 使用说明:http://mojo.codehaus.org/build-helper-maven-plugin/usage.html
(1)增加源代码包
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/junit/java</source> <source>src/junit/resources</source> </sources> </configuration> </execution> </executions> </plugin>
(2)添加测试源代码包
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>add-test-source</id> <phase>generate-test-sources</phase> <goals> <goal>add-test-source</goal> </goals> <configuration> <sources> <source>some directory</source> ... </sources> </configuration> </execution> </executions> </plugin>
添加测试源代码包后,通过mvn eclipse:eclipse生成eclipse工程之后,却无法在eclipse的源代码build path中看到,而添加源代码包是可以的。查阅了官网的bug库,该bug至今处于open状态。参考:https://issues.sonatype.org/browse/MNGECLIPSE-2387
相关文章推荐
- 修复 Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (execution: add-source, phase: generate-sources)
- ASP.NET 2.0: Add build-in paging feature to repeater/为repeater添加内置分页功能
- Unable to load the mojo 'add-source' from the plugin 'org.codehaus.mojo:build-helper-maven-plugin:1.
- How to add MS Test to post build
- org.codehaus.mojo:build-helper-maven-plugin:1.4:add-source (execution: add-sourc
- ASP.NET 2.0: Add build-in paging feature to repeater/为repeater添加内置分页功能
- 【BUG】 ContainerBase.addChild---IDEA 和Tomcat部署非maven的web项目
- MySoft.Data v2.7.3 stable 版本发布,新增部分功能,并修复其中的已知的bug
- Surface用户千万不要升级Win10 build 14279:有冻屏BUG
- 金融类APP-手写签名ADD盖章功能实现
- ToolStripItemCollection类中Add方法的中的小BUG
- Python+Selenium框架设计篇之8-unittest执行脚本方法之addTest
- 常规功能和模块自定义系统—062快速架构(quickbuild)开源版发布
- 利用 test 命令的测试功能
- 一个发送邮件功能,用户反映没有收到邮件,如何处理bug
- Add touch listener to 3D object in unity(Unity中给3D物体添加按钮点击功能)
- bug_ _ android.view.WindowManager$BadTokenException: Unable to add window -- token
- python unittest框架中addCleanup函数详解
- Test一下源代码的显示功能
- 【Java-bug】No enclosing instance of type Test is accessible. Must qualify the allocation with an encl