Chr*_*ies 5 java eclipse maven-3 maven
如果激活了某个配置文件(此处为“java8”),我们的 maven pom.xml 指定添加额外的源和测试源文件夹。pom的相应部分如下所示
<profile>
<id>java8</id>
....
<build>
<plugins>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>src/test/java8</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
根据http://mojo.codehaus.org/build-helper-maven-plugin/usage.html,这似乎是正确的规范。
运行时mvm install -P java8我发现附加测试已按预期执行。
但是,运行mvm eclipse:eclipse -P java8附加测试源文件夹不会出现在 eclipse 中.classpath。
问题:如何配置 maven 将测试源文件夹添加到 eclipse 配置中?上述行为是错误还是配置错误?
花了一些时间对此进行试验后,我可以对我自己的问题给出部分答案(希望节省其他开发人员的一些时间):
如果一个人使用
<phase>generate-sources</phase>
<goals><goal>add-test-source</goal></goals>
Run Code Online (Sandbox Code Playgroud)
代替
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
Run Code Online (Sandbox Code Playgroud)
然后将测试源文件夹添加到 eclipse .classpath (并将其添加为测试文件夹)。即我现在正在不同的阶段执行“add-test-source”。
换句话说,配置文件如下所示:
<profile>
<id>java8</id>
....
<build>
<plugins>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>src/test/java8</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
这看起来像是一个“解决方法”。它仍然与http://mojo.codehaus.org/build-helper-maven-plugin/usage.html上的规范相矛盾
| 归档时间: |
|
| 查看次数: |
8957 次 |
| 最近记录: |