2

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:

  1. At some phase maven-war-plugin is invoked. It automatically handles WAR-specific stuff and creates the WAR file

  2. 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 life cycle?

2
  • i don't understand your question. we do that all the time. you generate your jar/ear/war, then you run an assembly. is that not working for you?
    – jtahlborn
    Feb 17, 2011 at 12:26
  • My question is about execution flow. How do I exactly define that maven-war-plugin is to be invoked before ZIP archive is created at 'package' phase? If you did this multiple times could you please provide a working example?
    – ᄂ ᄀ
    Feb 17, 2011 at 13:43

3 Answers 3

1

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.

1

Can you try invoking the maven-assembly-plugin during the 'install' phase?

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.