From d2e34e6b07ce0c5d09a0d870beb01a9226e4d654 Mon Sep 17 00:00:00 2001 From: Marc Rohlfs Date: Thu, 20 Jun 2019 13:45:59 +0200 Subject: [PATCH] Make layout parameter available as a user property This commit allows the layout parameter of the Maven repackage goal to be set from the command line. See gh-17277 --- .../invoker.properties | 1 + .../src/it/repackage-layout-default/pom.xml | 30 +++++++++++++++++++ .../main/java/org/test/SampleApplication.java | 23 ++++++++++++++ .../it/repackage-layout-default/verify.groovy | 4 +++ .../invoker.properties | 1 + .../src/it/repackage-layout-property/pom.xml | 30 +++++++++++++++++++ .../main/java/org/test/SampleApplication.java | 23 ++++++++++++++ .../repackage-layout-property/verify.groovy | 4 +++ .../boot/maven/RepackageMojo.java | 2 +- 9 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/invoker.properties create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/pom.xml create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/src/main/java/org/test/SampleApplication.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/verify.groovy create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/invoker.properties create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/pom.xml create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/src/main/java/org/test/SampleApplication.java create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/verify.groovy diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/invoker.properties new file mode 100644 index 0000000000..f6e40a283d --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/invoker.properties @@ -0,0 +1 @@ +invoker.goals=package \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/pom.xml new file mode 100644 index 0000000000..3e48e4f979 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + org.springframework.boot.maven.it + repackage-layout-default + 0.0.1.BUILD-SNAPSHOT + + UTF-8 + @java.version@ + @java.version@ + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + package + + repackage + + + + + + + diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/src/main/java/org/test/SampleApplication.java new file mode 100644 index 0000000000..7ff035e400 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/src/main/java/org/test/SampleApplication.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.test; + +public class SampleApplication { + + public static void main(String[] args) { + } +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/verify.groovy new file mode 100644 index 0000000000..7c6bfa8c61 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-default/verify.groovy @@ -0,0 +1,4 @@ +import static org.junit.Assert.assertFalse + +def file = new File(basedir, "build.log") +assertFalse file.text.contains("Layout:") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/invoker.properties new file mode 100644 index 0000000000..034be12754 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/invoker.properties @@ -0,0 +1 @@ +invoker.goals=package -Dspring-boot.repackage.layout=ZIP \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/pom.xml new file mode 100644 index 0000000000..3e48e4f979 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + org.springframework.boot.maven.it + repackage-layout-default + 0.0.1.BUILD-SNAPSHOT + + UTF-8 + @java.version@ + @java.version@ + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + package + + repackage + + + + + + + diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/src/main/java/org/test/SampleApplication.java new file mode 100644 index 0000000000..7ff035e400 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/src/main/java/org/test/SampleApplication.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.test; + +public class SampleApplication { + + public static void main(String[] args) { + } +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/verify.groovy new file mode 100644 index 0000000000..74a5ff22db --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/repackage-layout-property/verify.groovy @@ -0,0 +1,4 @@ +import static org.junit.Assert.assertTrue + +def file = new File(basedir, "build.log") +assertTrue file.text.contains("Layout: ZIP") 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 3ce4eff58f..d57f51d3db 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 @@ -139,7 +139,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { * archive type. * @since 1.0.0 */ - @Parameter + @Parameter(property = "spring-boot.repackage.layout") private LayoutType layout; /**