在我的Eclipse / Maven项目中,如何调用buildHelper目标add-test-source
,add-test-resource
和add-resource
?
这是我的方法:
pom.xml
:
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>add-test-source</goal>
<goal>add-test-resource</goal>
<goal>add-resource</goal>
</goals>
</pluginExecutionFilter>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compile-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
lifecycle-mapping-metadata.xml
(来自Eclipse配置):
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
</pluginExecutions>
</lifecycleMappingMetadata>
为了测试,我将一个空文件放入测试资源目录,更改源文件,保存并检查空文件是否在相应的target/
目录中。 不是。
当我手动运行compile test-compile
时,测试文件将被复制。