无法使用mojo的build-helper查看生成的测试源文件夹

时间:2014-11-25 17:45:45

标签: java maven-plugin mojo build-helper-maven-plugin

我已将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>

我做错了吗?请帮忙。

由于

1 个答案:

答案 0 :(得分:1)

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

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

mvn generate-test-sources eclipse:eclipse

希望这有助于某人!