I have a Maven pom that uses <packaging>war</packaging>
. But actually, I don't want build the war-file, I just want all the dependent jars collected and a full deployment directory created.
So I'm running the war:exploded
goal to generate the deploy directory:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <phase>package</phase> <configuration> <webappDirectory>target/${env}/deploy</webappDirectory> <archiveClasses>true</archiveClasses> </configuration> <goals> <goal>exploded</goal> </goals> </execution> </executions> </plugin>
The trouble is, the war file still gets built. Is there a simple way of having <packaging>war</packaging>
execute the war:exploded
goal instead of the war:war goal?
Or is there another simple way to do this?
WAR files are convenient because they are a single package that is easy to copy, and the contents of the WAR file are compressed making it quite a compact package. The second way is to deploy all the individual files that make up a web application. This is called an exploded deployment, or an exploded WAR.
war:war is the default goal invoked during the package phase for projects with a packaging type of war . It builds a WAR file. war:exploded is generally used to speed up testing during the developement phase by creating an exploded webapp in a specified directory.
war file as a classpath. Create a Maven module which contains the classes of project-orange with jar packaging. Now you can treat the new Maven module as normal dependency. Configure the maven-war-plugin such that it will build the .
The solution is quite simple. You need to override the default execution of the war plugin to disable it and add your own execution (for exploded):
<pluginManagement> <plugins> <plugin><!-- don't pack the war --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <id>default-war</id> <phase>none</phase> </execution> <execution> <id>war-exploded</id> <phase>package</phase> <goals> <goal>exploded</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement>
According builtin lifecycle bindings for war packaging in package phase war:war mojo is called.
You can call previous 'prepare-package' phase - all actions will be performed and after that call mojo war:exploded
mvn prepare-package war:exploded
The results will be the same as yours but no war created.
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