Java 在Maven中是否可以基于每个概要文件排除(或包括)类或资源?
我有两个maven概要文件P1和P2,我想做的是,根据我用于构建项目的概要文件,应该排除某些资源 比如说Java 在Maven中是否可以基于每个概要文件排除(或包括)类或资源?,java,maven,Java,Maven,我有两个maven概要文件P1和P2,我想做的是,根据我用于构建项目的概要文件,应该排除某些资源 比如说 <profiles> <profile> <id>P1</id> <properties> <app.home>Path to project home</app.home> <exclude>src/main
<profiles>
<profile>
<id>P1</id>
<properties>
<app.home>Path to project home</app.home>
<exclude>src/main/java/foo/*.*</exclude> <!-- need to exclude all files in src/main/java/foo in this profile -->
</properties>
</profile>
<profile>
<id>P2</id>
<properties>
<app.home>Path to project home</app.home>
<exclude>src/main/java/bar/*.*</exclude> <!-- need to exclude all files in src/main/java/bar in this profile-->
</properties>
</profile>
</profiles>
P1
项目主页的路径
src/main/java/foo/*.*
P2
项目主页的路径
src/main/java/bar/*.*
因此,这里我想做的是,当我使用P1配置文件构建时,排除src/main/java/foo/中的所有文件,当我使用P2配置文件构建时,排除src/main/java/bar中的所有文件
这可能吗?如果不可能,还有其他选择吗?您可以向您的配置文件中添加一个
build
,并在其中添加一个exclude
例如
P1
您应该使用两个单独的模块,这意味着要构建多模块。原因这违反了关注点分离。
<profile>
<id>P1</id>
<properties>
<app.home>Path to project home</app.home>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**src/main/java/foo/*.*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>