From 554dec1a3eeafe0c1ff4bf7182904aefcae5f674 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 29 Mar 2019 10:19:14 +0100 Subject: [PATCH 1/3] Document finalName alternative for repackage goal Closes gh-16334 --- .../site/apt/examples/repackage-name.apt.vm | 42 +++++++++++++++++++ .../src/site/apt/index.apt | 2 + .../src/site/site.xml | 1 + 3 files changed, 45 insertions(+) create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-name.apt.vm diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-name.apt.vm b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-name.apt.vm new file mode 100644 index 0000000000..3dbd580c23 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-name.apt.vm @@ -0,0 +1,42 @@ + ----- + Repackage classifier + ----- + Stephane Nicoll + ----- + 2019-03-29 + ----- + + If you need the repackage jar to have a different local name than the one defined by + the <<>> attribute of the project, simply use the standard <<>> + as shown in the following example: + +--- + + ... + + my-app + + ... + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + repackage + + repackage + + + + ... + + ... + + ... + + ... + +--- + + This configuration will generate the repackaged artifact in <<>>. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/index.apt b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/index.apt index 2c0d71d3de..64cd7a049a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/index.apt +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/index.apt @@ -46,6 +46,8 @@ Spring Boot Maven Plugin * {{{./examples/repackage-classifier.html}Custom repackage classifier}} + * {{{./examples/repackage-name.html}Custom repackage name}} + * {{{./examples/repackage-disable-attach.html}Local repackaged artifact}} * {{{./examples/exclude-dependency.html}Exclude a dependency}} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml index c393e2ceb6..6711b55c15 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml @@ -8,6 +8,7 @@ + From 6ab942f2958a3e6237b1dca5908f73d23dfbb40d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 29 Mar 2019 10:19:43 +0100 Subject: [PATCH 2/3] Polish --- .../src/site/apt/examples/repackage-disable-attach.apt.vm | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-disable-attach.apt.vm b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-disable-attach.apt.vm index 0d39255532..dcd4dfa142 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-disable-attach.apt.vm +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/repackage-disable-attach.apt.vm @@ -23,6 +23,7 @@ ${project.version} + repackage repackage From 04aadcdf2e1dc555447d2248ff53e1a2261da560 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 29 Mar 2019 10:40:41 +0100 Subject: [PATCH 3/3] Make sure custom finalName is ignored A read-only plugin parameter can still be set by the user which leads to an invalid repackaged archive. This commit actually ignores the field and uses the standard attribute instead. Closes gh-16202 --- .../java/org/springframework/boot/maven/RepackageMojo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 91c05fd09b..454995fe0f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -263,7 +263,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { if (!this.outputDirectory.exists()) { this.outputDirectory.mkdirs(); } - return new File(this.outputDirectory, this.finalName + classifier + "." + String finalName = this.project.getBuild().getFinalName(); + return new File(this.outputDirectory, finalName + classifier + "." + this.project.getArtifact().getArtifactHandler().getExtension()); }