Maven packaging based on maven-war-plugin
I am wondering about the steps required with Maven to implement custom packaging and bind it to the 'package' phase.
Basically what I need is to invoke standard maven-war-plugin and create ZIP archive of a specific structure that will contain created WAR file. While I know how to do these tasks separately, I do not quite understand how to tie them together.
I assume a sequence like this:
At some phase maven-war-plugin is invoked. It automatically handles WAR-specific stuff and creates the WAR file
During 'package' phase maven-assembly-plugin is invoked. It creates ZIP archive of the required structure.
What would be the most straightforward and proper way to define these tasks in POM file and bind them to the build l开发者_如何转开发ife cycle?
We generally just run the assembly during the package phase, using the standard assembly config:
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
if that is not working for you for some reason, an easy solution is to split the war and the zip into 2 submodules. generate the war in the first sub-module, then create a second sub-module of type "pom" which runs the assembly plugin.
Can you try invoking the maven-assembly-plugin during the 'install' phase?
You can change the phase of each task.
1) Create the War file during the prepare-package phase
<phase>prepare-package</phase>
2) Create the zip file during the package phase
<phase>package</phase>
精彩评论