Kil*_*átó 2 plugins compilation helper maven
我更多地讨论了如何向MAVEN添加更多源文件夹,我选择使用MOJO的build-helper-maven-plugin插件.该pom.xml的是这样的:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.maven.tests</groupId>
<artifactId>helper</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-gen-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src-gen/gen/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-extra-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/extra/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<includes>
<include>src/main/java/**/*.java</include>
<include>src-gen/gen/java/**/*.java</include>
<include>src/extra/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
使用该命令mvn clean compile,构建完成正常,没有错误,但不生成任何类.
我确信我做错了但我无法弄明白.
The problem is your includes configuration of the maven-compiler-plugin. The maven-compiler-plugin will automatically pick up all source folders configured in your project - you don't need to define them via the includes tag.
So in your case it will automatically pick up src/main/java (standard maven source location) and the two that you have configured the build-helper-maven-plugin to add, src-gen/gen/java & src/extra/java.
您需要做的就是删除该includes部分,您的构建应该工作.所以你的pom中的maven-compiler-plugin就是:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12597 次 |
| 最近记录: |