Maven 2 Maven一次性构建多个概要文件
我们的政策是只构建1个可部署jar。所有特定于环境的配置都是分开的,我们一次将它们构建在一起。因此,在我们当前的Ant过程中,我们为每个环境都有一个属性文件,循环它们,并为每个环境创建一组配置文件 在我当前的POM XML中,我只能构建命令行提供的一个概要文件。可以通过Maven实现吗 下面是POM.xml的一些相关部分Maven 2 Maven一次性构建多个概要文件,maven-2,maven,profiles,Maven 2,Maven,Profiles,我们的政策是只构建1个可部署jar。所有特定于环境的配置都是分开的,我们一次将它们构建在一起。因此,在我们当前的Ant过程中,我们为每个环境都有一个属性文件,循环它们,并为每个环境创建一组配置文件 在我当前的POM XML中,我只能构建命令行提供的一个概要文件。可以通过Maven实现吗 下面是POM.xml的一些相关部分 <!-- Define profiles here and make DEV as default profile --> <profiles>
<!-- Define profiles here and make DEV as default profile -->
<profiles>
<!-- dev Profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- qa Profile -->
<profile>
<id>qa</id>
<properties>
<env>qa</env>
</properties>
</profile>
<!-- prod Profile -->
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
...
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<filters>
<filter>env/${env}.properties</filter>
</filters>
<outputDirectory>${project.build.directory}/config/${env}
</outputDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/config/default
</directory>
<includes>
<include>*.xml</include>
<include>*.properties</include>
</includes>
</resource>
发展
真的
质量保证
质量保证
戳
戳
...
maven资源插件
2.4.3
验证
复制资源
env/${env}.properties
${project.build.directory}/config/${env}
真的
${basedir}/src/main/config/default
*.xml
*.物业
谢谢,
普拉布乔特和蚂蚁不一样。有了ant,你基本上可以在你想做的时候做你想做的事情。有了maven,就有了一个清晰且有文档记录的组件,它的目标是构建一个组件(并可能将其他工件附加到构建中) 然而,您计划做的是多次构建一个组件,但使用不同的参数。这不适合maven的生命周期。因此,您需要做的是使一些外部进程进行迭代,并使用不同的参数重复调用maven
实现这一点的经典方法是使用shell脚本,但也可以使用从Java或Maven上下文启动单独的进程。这里介绍了解决方法: