tro*_*oig 13 java integration-testing maven-plugin maven build-helper-maven-plugin
我有这个项目结构:
/src
/main
/java
/resources
/test
/java
/resources
/it
/java
/resources
Run Code Online (Sandbox Code Playgroud)
test用于单元测试和it集成测试.我使用的是建立辅助性Maven的插件添加额外的测试源/资源类路径中供以后使用Maven的surfire-插件的运行
unit tests和Maven的故障保护,插件的integration tests.
插件配置如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<directory>/src/it/resources</directory>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这适用于test-sources(它们正确地适应/ target/test-classes)但不复制测试资源.我尝试过不同的组合<configuration>:使用<resource>替代方法<directory>,使用特定文件而不是目录......但两者都不起作用.
Stacktrace出错:
Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.codehaus.mojo:build-helper-maven-plugin:1.9.1:add-test-resource for parameter directory: Cannot configure instance of org.apache.maven.model.Resource from src/it/resources
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:597)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
Run Code Online (Sandbox Code Playgroud)
暂时,我已经固定它添加集成测试资源Maven的<build>配置:
<build>
...
<testResources>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>
</build>
Run Code Online (Sandbox Code Playgroud)
但我更愿意集中所有类路径修改build-helper-maven-plugin.任何人都可以用正确的配置发布示例吗?
提前致谢.
Ren*_*ink 23
根据maven-build-helper-plugin的javadoc :add-test-resources.这resources是一个数组org.apache.maven.model.Resource.因此,您必须以这种方式配置它:
<configuration>
<resources>
<resource>
<directory>/src/it/resources</directory>
</resource>
</resources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
看看如何配置插件参数.
| 归档时间: |
|
| 查看次数: |
10060 次 |
| 最近记录: |