diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-attach-disabled/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-attach-disabled/verify.groovy
index 676d04c4b63..7cfb5917059 100644
--- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-attach-disabled/verify.groovy
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-attach-disabled/verify.groovy
@@ -1,20 +1,18 @@
-import java.io.*;
import org.springframework.boot.maven.*
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertFalse
-Verify.verifyJar(
- new File( basedir, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main"
-);
-File main = new File( basedir, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar")
-File backup = new File( basedir, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar.original")
+File main = new File(basedir, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar")
+File backup = new File(basedir, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar.original")
+Verify.verifyJar(main, "some.random.Main")
assertTrue 'backup file should exist', backup.exists()
-
def file = new File(basedir, "build.log")
assertTrue 'main artifact should have been updated',
- file.text.contains("Updating artifact " + main + " to " + backup)
-return file.text.contains ("Installing "+backup)
-
-
+ file.text.contains("Updating main artifact " + main + " to " + backup)
+assertTrue 'main artifact should have been installed',
+ file.text.contains ("Installing " + backup + " to")
+assertFalse 'repackaged artifact should not have been installed',
+ file.text.contains ("Installing " + main + "to")
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/invoker.properties
new file mode 100644
index 00000000000..c0c3f7cc079
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/invoker.properties
@@ -0,0 +1 @@
+invoker.goals=clean install
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/pom.xml
new file mode 100644
index 00000000000..2156ea20708
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/pom.xml
@@ -0,0 +1,58 @@
+
+
+ 4.0.0
+ org.springframework.boot.maven.it
+ jar-classifier-main-attach-disabled
+ 0.0.1.BUILD-SNAPSHOT
+
+ UTF-8
+ @java.version@
+ @java.version@
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+
+ repackage
+
+
+ test
+ false
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ @maven-jar-plugin.version@
+
+
+
+ Foo
+
+
+
+
+
+
+
+
+ org.springframework
+ spring-context
+ @spring.version@
+
+
+ javax.servlet
+ javax.servlet-api
+ @servlet-api.version@
+ provided
+
+
+
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/src/main/java/org/test/SampleApplication.java
new file mode 100644
index 00000000000..24689463ea6
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/src/main/java/org/test/SampleApplication.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2012-2018 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
+ *
+ * http://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/jar-classifier-main-attach-disabled/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/verify.groovy
new file mode 100644
index 00000000000..1d9d2c46ae0
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main-attach-disabled/verify.groovy
@@ -0,0 +1,27 @@
+import org.springframework.boot.maven.*
+
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertFalse
+
+File repackaged = new File(basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar")
+File main = new File( basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar")
+File backup = new File( basedir, "target/jar-classifier-main-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar.original")
+
+new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
+assertTrue 'main artifact should exist', main.exists()
+assertFalse 'backup artifact should not exist', backup.exists()
+
+def file = new File(basedir, "build.log")
+assertFalse 'repackaged artifact should not have been attached',
+ file.text.contains("Attaching repackaged archive " + repackaged + " with classifier test")
+assertTrue 'repackaged artifact should have been created',
+ file.text.contains("Creating repackaged archive " + repackaged + " with classifier test")
+assertTrue 'main artifact should have been installed',
+ file.text.contains ("Installing " + main + " to")
+assertFalse 'repackaged artifact should not have been installed',
+ file.text.contains ("Installing " + repackaged + " to")
+assertFalse 'backup artifact should not have been installed',
+ file.text.contains ("Installing " + backup + "to")
+
+
+
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main/verify.groovy
index c42623c3ebd..7b3f18aadb8 100644
--- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main/verify.groovy
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-main/verify.groovy
@@ -1,20 +1,22 @@
-import java.io.*;
-import org.springframework.boot.maven.*;
+import org.springframework.boot.maven.*
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertFalse
File repackaged = new File(basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT-test.jar")
-new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
-
File main = new File( basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar")
-assertTrue 'main artifact should exist', main.exists()
-
File backup = new File( basedir, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar.original")
+
+new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
+assertTrue 'main artifact should exist', main.exists()
assertFalse 'backup artifact should not exist', backup.exists()
def file = new File(basedir, "build.log")
-assertTrue 'repackaged artifact should have been attached', file.text.contains("Attaching archive " + repackaged)
-assertTrue 'main artifact should have been installed', file.text.contains ("Installing "+main)
-assertTrue 'repackaged artifact should have been installed', file.text.contains ("Installing "+repackaged)
-
+assertTrue 'repackaged artifact should have been attached',
+ file.text.contains("Attaching repackaged archive " + repackaged + " with classifier test")
+assertFalse 'repackaged artifact should have been created',
+ file.text.contains("Creating repackaged archive " + repackaged + " with classifier test")
+assertTrue 'main artifact should have been installed',
+ file.text.contains ("Installing " + main + " to")
+assertTrue 'repackaged artifact should have been installed',
+ file.text.contains ("Installing " + repackaged + " to")
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/invoker.properties
new file mode 100644
index 00000000000..c0c3f7cc079
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/invoker.properties
@@ -0,0 +1 @@
+invoker.goals=clean install
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/pom.xml
new file mode 100644
index 00000000000..f52abcf1e19
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+ org.springframework.boot.maven.it
+ jar-classifier-source-attach-disabled
+ 0.0.1.BUILD-SNAPSHOT
+
+ UTF-8
+ @java.version@
+ @java.version@
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ @maven-jar-plugin.version@
+
+
+
+ jar
+
+ package
+
+ test
+
+
+ Foo
+
+
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+
+ repackage
+
+
+ test
+ false
+
+
+
+
+
+
+
+
+ org.springframework
+ spring-context
+ @spring.version@
+
+
+ javax.servlet
+ javax.servlet-api
+ @servlet-api.version@
+ provided
+
+
+
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/src/main/java/org/test/SampleApplication.java
new file mode 100644
index 00000000000..24689463ea6
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/src/main/java/org/test/SampleApplication.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2012-2018 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
+ *
+ * http://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/jar-classifier-source-attach-disabled/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/verify.groovy
new file mode 100644
index 00000000000..20944224874
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source-attach-disabled/verify.groovy
@@ -0,0 +1,21 @@
+import org.springframework.boot.maven.*
+
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertFalse
+
+File main = new File(basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar");
+File backup = new File( basedir, "target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar.original")
+
+new Verify.JarArchiveVerification(main, Verify.SAMPLE_APP).verify();
+assertTrue 'backup artifact should exist', backup.exists()
+
+def file = new File(basedir, "build.log")
+assertFalse 'repackaged artifact should not have been attached',
+ file.text.contains("Attaching repackaged archive " + main + " with classifier test")
+assertTrue 'test artifact should have been updated',
+ file.text.contains("Updating artifact with classifier test " + main + " to " + backup)
+assertTrue 'backup artifact should have been installed',
+ file.text.contains ("Installing " + backup + " to")
+assertFalse 'repackaged artifact should not have been installed',
+ file.text.contains ("Installing " + main + " to")
+
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source/verify.groovy
index 7ee8a990cc0..ab9a28b856c 100644
--- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source/verify.groovy
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-classifier-source/verify.groovy
@@ -1,33 +1,17 @@
-/*
- * Copyright 2012-2014 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
- *
- * http://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.
- */
-
-import java.io.*;
import org.springframework.boot.maven.*
import static org.junit.Assert.assertFalse
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertTrue
File repackaged = new File(basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar");
-new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
-
File backup = new File( basedir, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar.original")
+
+new Verify.JarArchiveVerification(repackaged, Verify.SAMPLE_APP).verify();
assertTrue 'backup artifact should exist', backup.exists()
def file = new File(basedir, "build.log")
-assertTrue 'repackaged artifact should have been replaced', file.text.contains("Replacing artifact with classifier test " + repackaged)
+assertTrue 'repackaged artifact should have been replaced',
+ file.text.contains("Replacing artifact with classifier test with repackaged archive")
assertFalse 'backup artifact should not have been installed', file.text.contains ("Installing "+backup)
assertTrue 'repackaged artifact should have been installed', file.text.contains ("Installing "+repackaged)
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/invoker.properties
new file mode 100644
index 00000000000..c0c3f7cc079
--- /dev/null
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/invoker.properties
@@ -0,0 +1 @@
+invoker.goals=clean install
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
index 07b375b51fc..ee90453e491 100644
--- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
+++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
@@ -1,7 +1,18 @@
-import java.io.*;
-import org.springframework.boot.maven.*;
+import org.springframework.boot.maven.*
-Verify.verifyJar(
- new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main"
-);
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertFalse
+
+File main = new File(basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar")
+File backup = new File(basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar.original")
+Verify.verifyJar(main, "some.random.Main")
+assertTrue 'backup file should exist', backup.exists()
+
+def file = new File(basedir, "build.log")
+assertTrue 'main artifact should have been replaced by repackaged archive',
+ file.text.contains("Replacing main artifact with repackaged archive")
+assertTrue 'main artifact should have been installed',
+ file.text.contains ("Installing " + main + " to")
+assertFalse 'backup artifact should not have been installed',
+ file.text.contains ("Installing " + backup + "to")
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 dd3d5167950..a08f0c8a194 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
@@ -336,14 +336,21 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
attachArtifact(source, target);
}
else if (source.getFile().equals(target)) {
- getLog().info("Updating artifact " + source.getFile() + " to " + original);
- this.project.getArtifact().setFile(original);
+ String artifactId = (this.classifier != null)
+ ? "artifact with classifier " + this.classifier : "main artifact";
+ getLog().info(String.format("Updating %s %s to %s", artifactId,
+ source.getFile(), original));
+ source.setFile(original);
+ }
+ else if (this.classifier != null) {
+ getLog().info("Creating repackaged archive " + target + " with classifier "
+ + this.classifier);
}
}
private void attachArtifact(Artifact source, File target) {
if (this.classifier != null && !source.getFile().equals(target)) {
- getLog().info("Attaching archive " + target + " with classifier "
+ getLog().info("Attaching repackaged archive " + target + " with classifier "
+ this.classifier);
this.projectHelper.attachArtifact(this.project, this.project.getPackaging(),
this.classifier, target);
@@ -351,7 +358,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
else {
String artifactId = (this.classifier != null)
? "artifact with classifier " + this.classifier : "main artifact";
- getLog().info(String.format("Replacing %s %s", artifactId, source.getFile()));
+ getLog().info("Replacing " + artifactId + " with repackaged archive");
source.setFile(target);
}
}