我对如何向 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>
使用该命令mvn clean compile
构建完成正常,没有错误,但没有生成类。
我确定我做错了什么,但我无法弄清楚。