Java 在maven中跨配置文件共享公共配置
我们的项目有一个父POM,它提供了很多配置。在我们的项目中,如果某个配置文件被激活,我们需要提供更多的配置。我们目前是这样做的Java 在maven中跨配置文件共享公共配置,java,maven,maven-profiles,Java,Maven,Maven Profiles,我们的项目有一个父POM,它提供了很多配置。在我们的项目中,如果某个配置文件被激活,我们需要提供更多的配置。我们目前是这样做的 <profiles> <profile> <id>prof1</id> <build> <pluginManagement> <plugins> <
<profiles>
<profile>
<id>prof1</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf1</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof2</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf2</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof3</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf3</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof4</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf4</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
prof1
com.somegroupId
一些人工制品
准公共
参数1
prof2
com.somegroupId
一些人工制品
准公共
参数2
prof3
com.somegroupId
一些人工制品
准公共
参数3
prof4
com.somegroupId
一些人工制品
准公共
paramProf4
这里的问题是我们到处重复整个构建过程。我想避免这种情况。我想通过属性传递paramProfX
。此处的插件配置不能移出配置文件,因为只有当且仅当四个配置文件中的一个被激活时,它才能被包括在内,否则不能
在这里,我可以使用paramProfX
将paramProfX
和另一个配置文件中的build
标记的其余部分移动为属性,并将paramProfX
作为属性传递给其他一些配置文件。但是,在这种情况下,我可能需要同时激活两个配置文件,我不想这样做,因为只激活四个配置文件中的一个将不会起任何作用,因此会产生误导
如果我想一次只激活一个配置文件,那么实现这一点的最佳方法是什么?你可以通过paramProfX@D.B。我不想这样做。你可以通过paramProfX@D.B。我不想这样做