根据pom中的活动配置文件更改包装 [英] Changing packaging based on active profile in pom
本文介绍了根据pom中的活动配置文件更改包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用maven编译的项目。我在pom.xml中声明了不同的配置文件。
对于其中一些配置文件,我更喜欢建立一个战争,而对于其他配置文件,我更喜欢一个jar。我用来手动编辑pom.xml文件并将打包变量更改为
I have a project which I compile with maven. I have different profiles declared in pom.xml. For some of these profiles, I prefer building a war, and for other profiles I prefer a jar. I use to manually edit the pom.xml file and change packaging variable to either
<packaging>war</packaging>
或
<packaging>jar</packaging>
在做之前
$ mvn clean package -Pchosenprofile
如何告诉mvn对应的包装每个配置文件,所以我不需要编辑pom.xml?
How can I tell mvn the packaging corresponding to each profile so I don't need to edit pom.xml?
推荐答案
如果你想使用配置文件你可以使用像:
If you want to use profile you can use something like:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
..
<packaging>${packaging.type}</packaging>
<profiles>
<profile>
<id>webapp</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<packaging.type>war</packaging.type>
</properties>
</profile>
<profile>
<id>batch</id>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
</profiles>
</project>
这篇关于根据pom中的活动配置文件更改包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文