You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2022/01/06 09:45:38 UTC
[sling-slingfeature-maven-plugin] branch master updated: SLING-11044 : Update feature versions does not preserve metadata
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new ec72d45 SLING-11044 : Update feature versions does not preserve metadata
ec72d45 is described below
commit ec72d45c31d6a449d02863ec63975872918ba66d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jan 6 10:42:28 2022 +0100
SLING-11044 : Update feature versions does not preserve metadata
---
.../apache/sling/feature/maven/mojos/UpdateVersionsMojo.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
index dcb4244..6acdbd3 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/UpdateVersionsMojo.java
@@ -570,6 +570,7 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
container = rawFeature.getExtensions().getByName(update.extension.getName()).getArtifacts();
}
final int pos = container.indexOf(update.artifact);
+ final Artifact oldArtifact = pos == -1 ? null : container.get(pos);
if (!container.removeExact(update.artifact.getId())) {
// check if property is used
final Artifact same = container.getSame(update.artifact.getId());
@@ -599,13 +600,8 @@ public class UpdateVersionsMojo extends AbstractIncludingFeatureMojo {
}
iter.remove();
} else {
- if (pos == -1) {
- throw new MojoExecutionException("MIST " + update.artifact.getId().toMvnId());
- }
- final Artifact newArtifact = new Artifact(new ArtifactId(update.artifact.getId().getGroupId(),
- update.artifact.getId().getArtifactId(), update.newVersion,
- update.artifact.getId().getClassifier(), update.artifact.getId().getType()));
- newArtifact.getMetadata().putAll(update.artifact.getMetadata());
+ final Artifact newArtifact = new Artifact(update.artifact.getId().changeVersion(update.newVersion));
+ newArtifact.getMetadata().putAll(oldArtifact.getMetadata());
container.add(pos, newArtifact);
}
}