Maven编译多个src目录

有没有办法在单个Maven项目中编译多个Java源目录?



千万里不及你
浏览 1193回答 3
3回答

至尊宝的传说

您可以使用build-helper添加新的源目录:<build>&nbsp; &nbsp; <plugins>&nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.codehaus.mojo</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>build-helper-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>generate-sources</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>add-source</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <sources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source>src/main/generated</source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </sources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>&nbsp; &nbsp; </plugins></build>

子衿沉夜

通过定义资源标签,这也适用于maven。您可以随意命名src文件夹名称。&nbsp; &nbsp; <resources>&nbsp; &nbsp; &nbsp; &nbsp; <resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <directory>src/main/java</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.java</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.properties</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.xml</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </includes>&nbsp; &nbsp; &nbsp; &nbsp; </resource>&nbsp; &nbsp; &nbsp; &nbsp; <resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <directory>src/main/resources</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.java</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.properties</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.xml</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </includes>&nbsp; &nbsp; &nbsp; &nbsp; </resource>&nbsp; &nbsp; &nbsp; &nbsp; <resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <directory>src/main/generated</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.java</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.properties</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/*.xml</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </includes>&nbsp; &nbsp; &nbsp; &nbsp; </resource>&nbsp; &nbsp; </resources>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java