From d1f4fd0ecbb7f3a3812919bca896b8fc548afd19 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sat, 23 Aug 2014 10:02:08 +0200 Subject: [PATCH] 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 --- .../src/it/jar-skip/pom.xml | 32 +++++++++++++++++++ .../src/it/jar-skip/verify.groovy | 7 ++++ .../boot/maven/RepackageMojo.java | 11 +++++++ 3 files changed, 50 insertions(+) create mode 100644 spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/pom.xml create mode 100644 spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/verify.groovy diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/pom.xml new file mode 100644 index 0000000000..114538f88e --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + org.springframework.boot.maven.it + jar-skip + 0.0.1.BUILD-SNAPSHOT + + UTF-8 + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + repackage + + + true + + + + + + + + diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/verify.groovy new file mode 100644 index 0000000000..2c2efb7d22 --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-skip/verify.groovy @@ -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() diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 0bfd9edacb..6edd33a36c 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -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();