Add skip parameter to repackage goal

This commit adds a 'skip' parameter to the 'repackage' goal that is
false by default. When this parameter is enabled, the repackage goal
does not run at all.

This can be used when repackaging should occur conditionally or
when a particular module in a hierarchy should not use this feature.

Fixes gh-1424
pull/1442/merge
Stephane Nicoll 10 years ago
parent 8c030795c2
commit d1f4fd0ecb

@ -0,0 +1,32 @@
<?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>org.springframework.boot.maven.it</groupId>
<artifactId>jar-skip</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- There is no main class on purpose as we skip the whole execution so it shouldn't be necessary -->
<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,7 @@
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
File f = new File( basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar")
assertTrue 'output file should have been generated', f.exists()
File shouldNotExist = new File( basedir, "target/jar-skip-0.0.1.BUILD-SNAPSHOT.jar.original")
assertFalse 'repackage goal should not have run. .original should not exist', shouldNotExist.exists()

@ -81,6 +81,13 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
@Parameter(defaultValue = "${project.build.finalName}", required = true)
private String finalName;
/**
* Skip the execution.
* @since 1.Z
*/
@Parameter(property = "skip", defaultValue = "false")
private boolean skip;
/**
* Classifier to add to the artifact generated. If given, the artifact will be
* attached. If this is not given, it will merely be written to the output directory
@ -123,6 +130,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
getLog().debug("repackage goal could not be applied to pom project.");
return;
}
if (this.skip) {
getLog().debug("skipping repackaging as per configuration.");
return;
}
File source = this.project.getArtifact().getFile();
File target = getTargetFile();

Loading…
Cancel
Save