我有这个项目结构:
/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 …Run Code Online (Sandbox Code Playgroud) java integration-testing maven-plugin maven build-helper-maven-plugin
最新版本的Build Helper Maven插件(目前为1.10)需要Java 1.7,这破坏了我的构建.插件文档页面仅显示最新版本的Java版本要求.
在我的 POM 文件中,我包括:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/avro</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
始终在 POM 文件中以红色显示这些内容
build-helper-maven-plugin
3.0.0
Run Code Online (Sandbox Code Playgroud)
我尝试了很多东西,例如,我使用Intellij IDEA右侧的MAVEN设置更新了MAVEN,但没有成功。当我编译时总是出现以下消息:
Could not transfer artifact org.codehaus.mojo:build-helper-maven-plugin:pom:3.0.0 from/to central (https://repo.maven.apache.org/maven2): /home/ameerb/.m2/repository/org/codehaus/mojo/build-helper-maven-plugin/3.0.0/build-helper-maven-plugin-3.0.0.pom.part.lock (No such file or directory)
Run Code Online (Sandbox Code Playgroud)
您能告诉我原因是什么以及解决方案是什么吗?
java intellij-idea maven-plugin maven build-helper-maven-plugin
这是我在 pom.xml 中的 build-helper-maven-plugin 配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>add-extra-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<directory>src/main/python</directory>
<!--<resource>src/main/python</resource>-->
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我运行 mvn install 时出现以下错误:
[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource (add-extra-resources) on project spookystuff: Unable to parse configuration of mojo org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource for parameter directory: Cannot find default setter in class org.apache.maven.model.Resource -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource (add-extra-resources) on project spookystuff: Unable to parse configuration of mojo org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource for parameter directory: Cannot …Run Code Online (Sandbox Code Playgroud)