Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution point between prepare-package and package in Maven build-process

Tags:

The package phase of a project with packaging war, prepares an exploded-war in the target folder and packages this into the final war-file.

Is it possible to make some changes, editing files, removing files and so on, between prepare-package and package phases? I'm searching for an extension point (Maven execution-phase) where the resources are already copied and in the exploded-war structure.

  1. [maven phase] Copy resources and explode to target/{finalName}.
  2. [custom] Do some complex custom changes (e.g. implemented with maven-antrun).
  3. [maven phase] Package the changed stuff into the final war.

I thought this could be possible between the phases prepare-package and package. Unfortunately after the prepare-package no exploded war is available to be changed and packaged later.

Can you give me a hint how to achieve this? Thank you very much.

like image 645
Christopher Klewes Avatar asked Jan 28 '11 08:01

Christopher Klewes


People also ask

What are the 3 build lifecycle of Maven?

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.

Which of the following phase would execute when the package phase is run?

The clean and package arguments are build phases while the dependency:copy-dependencies is a goal. Here the clean phase will be executed first, followed by the dependency:copy-dependencies goal, and finally package phase will be executed.

What is the sequence of Maven build lifecycle?

Maven Lifecycle: Below is a representation of the default Maven lifecycle and its 8 steps: Validate, Compile, Test, Package, Integration test, Verify, Install and Deploy.

What is executions in Maven?

An <execution> causes the plugin to be executed during the maven build lifecycle, i.e. during your build. The <configuration> allows you to configure the plugin for how it should behave during execution. Many Maven plugins provide documentation about their configuration options, e.g. the maven-compiler-plugin.


1 Answers

This configuration calls the exploded goal in the prepare-package phase. This gives you the chance to work on the exploded war directory in subsequent plugin definitions e.g. maven-antrun.

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-war-plugin</artifactId>
   <version>2.1.1</version>
   <executions>
     <execution>
       <id>prepare-war</id>
       <phase>prepare-package</phase>
       <goals>
         <goal>exploded</goal>
       </goals>
     </execution>
   </executions>
</plugin>
like image 192
Christopher Klewes Avatar answered Jan 12 '23 01:01

Christopher Klewes