Skip to content

Commit 93849c3

Browse files
committed
Change the maven plugin to allow use attached artifact with classifier
as source. Fixes spring-projectsgh-7659.
1 parent e397466 commit 93849c3

File tree

1 file changed

+9
-8
lines changed
  • spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven

1 file changed

+9
-8
lines changed

spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Properties;
2424
import java.util.Set;
2525

26-
import org.apache.commons.io.FilenameUtils;
2726
import org.apache.maven.artifact.Artifact;
2827
import org.apache.maven.model.Dependency;
2928
import org.apache.maven.plugin.MojoExecutionException;
@@ -226,16 +225,18 @@ private void repackage() throws MojoExecutionException {
226225
}
227226

228227
private File getSourceFile() {
229-
File source = this.project.getArtifact().getFile();
228+
Artifact sourceArtifact = this.project.getArtifact();
229+
230230
if (this.classifier != null) {
231-
File sourceWithClassifier = new File(source.getParent(),
232-
FilenameUtils.getBaseName(source.getName()) + getClassifier() + "."
233-
+ FilenameUtils.getExtension(source.getName()));
234-
if (sourceWithClassifier.exists()) {
235-
source = sourceWithClassifier;
231+
for (Artifact attachedArtifact : this.project.getAttachedArtifacts()) {
232+
if (this.classifier.equals(attachedArtifact.getClassifier())) {
233+
sourceArtifact = attachedArtifact;
234+
break;
235+
}
236236
}
237237
}
238-
return source;
238+
239+
return sourceArtifact.getFile();
239240
}
240241

241242
private File getTargetFile() {

0 commit comments

Comments
 (0)