Eclipse自动运行maven目标

时间:2017-03-16 16:43:21

标签: eclipse maven m2eclipse m2e

在我的Eclipse / Maven项目中,如何调用buildHelper目标add-test-sourceadd-test-resourceadd-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时,测试文件将被复制。

0 个答案:

没有答案