0

我已将 mojo 的插件 build-helper 添加到我的项目 pom 中,以便为我的集成测试生成一个新的测试源文件夹。当我运行阶段时,生成测试源

   mvn generate-test-sources

我可以看到下面的控制台输出显示已生成测试源文件夹,但是当我查看项目资源管理器时,我没有看到任何已创建的文件夹。

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for *******
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.google.guava:guava:jar -> version 18.0 vs ${guava.version} @ line 154, column 21
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.unitils:unitils-core:jar -> duplicate declaration of version 3.3 @ line 164, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building projectxxStaticAnalysisxxxxx versionxxxxx
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ StaticAnalysis ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ StaticAnalysis ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- build-helper-maven-plugin:1.9:add-test-source (add-integration-test-sources) @ StaticAnalysis ---
[INFO] Test Source directory: C:\{workspacepath}\src\integration-test\java added.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.421 s
[INFO] Finished at: 2014-11-25T11:26:59-06:00
[INFO] Final Memory: 9M/303M
[INFO] ------------------------------------------------------------------------    

下面是我的 pom 插件配置

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.9</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/integration-test/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
</plugin>

难道我做错了什么?。请帮忙。

谢谢

4

1 回答 1

1

我想我找到了我的问题的答案。我实际上期待 build-helper 插件为我创建测试文件夹。但事实是,它不会为您创建文件夹。

您必须创建测试文件夹并使用此 build-helper 插件告诉 maven 将您创建的文件夹视为测试文件夹,如我上面的 pom 所示。我可以通过创建一个新的测试文件夹并运行以下命令来解决我的问题

mvn generate-test-sources eclipse:eclipse

希望这对某人有帮助!

于 2014-11-25T19:51:36.077 回答