build-helper-maven-plugin add-test-resource error
2022-09-02 12:39:29
我有这个项目的结构:
/src
/main
/java
/resources
/test
/java
/resources
/it
/java
/resources
test
用于单元测试和集成测试。我正在使用build-helper-maven-plugin将其他测试源/资源添加到类路径中,以便以后使用maven-surfire-plugin进行运行,maven-failafe-plugin用于。it
unit tests
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>
这适用于(它们被正确地复制到 /target/test-classes),但不会复制 test 资源。我尝试过不同的组合:使用代替,使用特定的文件而不是目录...但两者都不起作用。test-sources
<configuration>
<resource>
<directory>
堆栈跟踪,出现错误:
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)
暂时,我已经修复了将集成测试资源添加到maven配置的问题:<build>
<build>
...
<testResources>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>
</build>
但是我宁愿将所有类路径修改集中在 .任何人都可以发布具有正确配置的示例吗?build-helper-maven-plugin
提前致谢。