Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

source-plugin vs, the initialize phase?

$
0
0
Hi.

I have a custom plugin that inserts some extra files into the jars
produced by the jar plugin. Because of the way the plugin works, it
will fail if it tries to make the modifications to a jar file that has
already had the modifications made. For reasons that aren't really
relevant here, modifying the plugin to cope with jars that have been
modified isn't feasible.

The simplest way to resolve this issue seems to be to have the clean
plugin delete any existing jar file unconditionally (so if the user
doesn't specify "clean" on the command line, the module is cleaned
anyway and the plugin doesn't have to receive an already-edited jar).

Anyway, the following pom file unconditonally runs the clean plugin
in the initialize phase:

<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.io7m.example</groupId>
<artifactId>init-test</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>

<prerequisites>
<maven>3.0.3</maven>
</prerequisites>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
</dependencies>

<build>
<plugins>
<!-- Clean all artifacts automatically at the start of the build. -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Create source jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

This would be fine, except that if you attempt to run the above pom with "mvn verify",
the maven-source-plugin will cause the maven-clean-plugin to be executed twice:

[INFO] Scanning for projects...
[INFO]
[INFO]

Viewing all articles
Browse latest Browse all 5648

Trending Articles