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> or
<packaging>jar</packaging> before doing a
$ mvn clean package -Pchosenprofile How can I tell mvn the packaging corresponding to each profile so I don't need to edit pom.xml?
1 Answer. Show activity on this post. The current core packaging values are: pom, jar, maven-plugin, ejb, war, ear, rar, par.
“pom” packaging is nothing but the container, which contains other packages/modules like jar, war, and ear. if you perform any operation on outer package/container like mvn clean compile install. then inner packages/modules also get clean compile install. no need to perform a separate operation for each package/module.
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> If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With