Be more lenient when repackage is invoked several times

This commit makes the repackager more lenient when it is invoked several
times in the same lifecycle.

Closes gh-15034
This commit is contained in:
Stephane Nicoll
2018-11-27 15:09:55 +01:00
parent d7fe3c73a3
commit bf88a7e466
2 changed files with 7 additions and 5 deletions

View File

@@ -179,11 +179,11 @@ public class Repackager {
if (this.layout == null) {
this.layout = getLayoutFactory().getLayout(this.source);
}
if (alreadyRepackaged()) {
return;
}
destination = destination.getAbsoluteFile();
File workingSource = this.source;
if (alreadyRepackaged() && this.source.equals(destination)) {
return;
}
if (this.source.equals(destination)) {
workingSource = getBackupFile();
workingSource.delete();

View File

@@ -245,7 +245,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
private Artifact getArtifact(String classifier) {
if (classifier != null) {
for (Artifact attachedArtifact : this.project.getAttachedArtifacts()) {
if (classifier.equals(attachedArtifact.getClassifier())) {
if (classifier.equals(attachedArtifact.getClassifier())
&& attachedArtifact.getFile() != null
&& attachedArtifact.getFile().isFile()) {
return attachedArtifact;
}
}
@@ -335,7 +337,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
if (this.attach) {
attachArtifact(source, target);
}
else if (source.getFile().equals(target)) {
else if (source.getFile().equals(target) && original.exists()) {
String artifactId = (this.classifier != null)
? "artifact with classifier " + this.classifier : "main artifact";
getLog().info(String.format("Updating %s %s to %s", artifactId,