Discussion:
[maven-war-plugin] Executing a goal after unpacking overlays and before repacking
Antonio Petrelli
2009-03-05 15:57:56 UTC
Permalink
Hi all,
Is there a way to execute a goal just after the overlays are unpacked,
but before the final WAR is produced?
What I want to do is to modify a configuration file that is present in
a ZIP dependency, through the use of the config-processor plugin:
http://code.google.com/p/maven-config-processor-plugin/

I tried attaching that plugin to the "package" phase, but the WAR file
has been created before the execution of the plugin.

Thanks in advance
Antonio
Olivier Lamy
2009-03-05 16:03:19 UTC
Permalink
Hi,
That's why the prepare-package will be a nice feature :-)
Try to attach to test phase.

--
Olivier
Post by Antonio Petrelli
Hi all,
Is there a way to execute a goal just after the overlays are unpacked,
but before the final WAR is produced?
What I want to do is to modify a configuration file that is present in
http://code.google.com/p/maven-config-processor-plugin/
I tried attaching that plugin to the "package" phase, but the WAR file
has been created before the execution of the plugin.
Thanks in advance
Antonio
---------------------------------------------------------------------
Antonio Petrelli
2009-03-05 16:07:16 UTC
Permalink
Post by Olivier Lamy
That's why the prepare-package will be a nice feature :-)
I agree :-D But the WAR plugin does the overlay unpacking in the
prepare-package phase in M2.1?
Post by Olivier Lamy
Try to attach to test phase.
It does not work, the ZIP is not unpacked (after a mvn clean).

Antonio
Antonio Petrelli
2009-03-05 16:58:12 UTC
Permalink
Post by Antonio Petrelli
Hi all,
Is there a way to execute a goal just after the overlays are unpacked,
but before the final WAR is produced?
What I want to do is to modify a configuration file that is present in
http://code.google.com/p/maven-config-processor-plugin/
I tried attaching that plugin to the "package" phase, but the WAR file
has been created before the execution of the plugin.
I solved the problem in another way.
I used a combination of the Dependency plugin (goal "unpack, phase
"generate-resources"), maven-config-processor-plugin (phase
"generate-resources") and AntRun plugin (goal "run", phase
"process-resources").
Moreover, I removed the Zip as an overlay :-(

But at least it works.

Thanks anyway
Antonio
Antonio Petrelli
2009-11-27 09:01:59 UTC
Permalink
As asked by a user, here I attach a snippet of my configuration:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.pronetics.jira.plugins</groupId>
<artifactId>backup-configuration</artifactId>
<version>1.0-SNAPSHOT</version>
<type>zip</type>
<classifier>webresources</classifier>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/webapp-unpack</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<copy todir="${project.build.directory}/${artifactId}">
<fileset dir="${project.build.directory}/processed-files" />
</copy>
<copy todir="${project.build.directory}/${artifactId}">
<fileset dir="${project.build.directory}/webapp-unpack" />
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-config-processor-plugin</groupId>
<artifactId>maven-config-processor-plugin</artifactId>
<version>1.4</version>
<configuration>
<outputDirectory>target/processed-files</outputDirectory>
<useOutputDirectory>true</useOutputDirectory>
<encoding>ISO-8859-1</encoding>
<lineWidth>200</lineWidth>
<indentSize>4</indentSize>
<transformations>
<transformation>
<type>properties</type>
<replacePlaceholders>true</replacePlaceholders>
<input>${project.build.directory}/webapp-unpack/exportConfiguration.properties</input>
<output>exportConfiguration.properties</output>
<config>src/main/assembly/properties/properties-processing.xml</config>
</transformation>
</transformations>
</configuration>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>


HTH
Antonio

Loading...