[java-mvn-enforcer] 01/03: JMVN-25 Artifact deriver gives wrong version information for garnished jar names
Rod Widdowson
rdw at steadingsoftware.com
Mon Feb 7 15:17:41 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-mvn-enforcer.
View the commit online:
http://git.shibboleth.net/view/?p=java-mvn-enforcer.git;a=commit;h=a8d3f304d280ff67aaf5737f09c93f108a476787
commit a8d3f304d280ff67aaf5737f09c93f108a476787
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Feb 6 11:41:43 2022 +0000
JMVN-25 Artifact deriver gives wrong version information for garnished jar names
https://shibboleth.atlassian.net/browse/JMVN-25
Add Concept of <classifier> to the artifact class
---
.../shibboleth/mvn/enforcer/impl/ParsedPom.java | 53 ++++++++++++++++++----
1 file changed, 44 insertions(+), 9 deletions(-)
diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/ParsedPom.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/ParsedPom.java
index c923657..e39bc0b 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/ParsedPom.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/ParsedPom.java
@@ -368,13 +368,16 @@ public class ParsedPom {
/** <version>.*/
@Nonnull private final String version;
+ /** <classifier>.*/
+ @Nonnull private final String classifier;
+
/** <exclusions>. */
@Nonnull private final Set<Pair<String, String>> exclusions = new HashSet<>();
/**
* Constructor.
*
- * @param id the <artifactId>
+ * @param id the <artifactId>
* @param group the <groupId>
* @param ver the <version>
*/
@@ -382,8 +385,24 @@ public class ParsedPom {
artifactId = id;
groupId = group;
version = ver;
+ classifier = "";
}
-
+
+ /**
+ * Constructor.
+ *
+ * @param id the <artifactId>
+ * @param group the <groupId>
+ * @param ver the <version>
+ * @param clssfr the <classifier>
+ */
+ public PomArtifact(final String group, final String id, final String ver, final String clssfr) {
+ artifactId = id;
+ groupId = group;
+ version = ver;
+ classifier = clssfr;
+ }
+
/**
* Constructor.
*
@@ -414,7 +433,7 @@ public class ParsedPom {
final List<Element> arts = ElementSupport.getChildElementsByTagName(item, "artifactId");
Constraint.isGreaterThan(0, arts.size(), "<artifactId> should exist in dependency");
artifactId = getElementContent(arts.get(0));
-
+
final List<Element> vers = ElementSupport.getChildElementsByTagName(item, "version");
if (vers.size() > 0) {
version = getElementContent(vers.get(0));
@@ -428,7 +447,15 @@ public class ParsedPom {
version = BAD_VERSION;
}
}
-
+
+ final List<Element> clssfrs = ElementSupport.getChildElementsByTagName(item, "classifier");
+ Constraint.isLessThanOrEqual(0, clssfrs.size(), ") or 1 <classifier> elements should exist in dependency");
+ if (clssfrs.size() > 0) {
+ classifier = getElementContent(clssfrs.get(0));
+ } else {
+ classifier = "";
+ }
+
List<Element> excls = ElementSupport.getChildElementsByTagName(item, "exclusions");
if (excls.size() > 0) {
excls = ElementSupport.getChildElementsByTagName(excls.get(0), "exclusion");
@@ -464,7 +491,14 @@ public class ParsedPom {
public String getVersion() {
return version;
}
-
+
+ /**
+ * @return Returns the classifier.
+ */
+ public String getClassifier() {
+ return classifier;
+ }
+
/**
* @return the pom source.
*/
@@ -497,19 +531,20 @@ public class ParsedPom {
final PomArtifact him = (PomArtifact) obj;
return him.getArtifactId().equals(getArtifactId()) &&
him.getGroupId().equals(getGroupId()) &&
- him.getVersion().equals(getVersion());
+ him.getVersion().equals(getVersion()) &&
+ him.getClassifier().equals(getClassifier());
}
return false;
}
/** {@inheritDoc} */
public int hashCode() {
- return Objects.hash(artifactId, groupId, version);
+ return Objects.hash(artifactId, groupId, version, classifier);
}
/** {@inheritDoc} */
public String toString() {
- return artifactId + "-" + version;
+ return artifactId + "-" + classifier + version;
}
/** return the same artifact but with an amended version.
@@ -517,7 +552,7 @@ public class ParsedPom {
* @return an amended artifact.
*/
public PomArtifact withVersion(String ver) {
- return new PomArtifact(groupId, artifactId, ver);
+ return new PomArtifact(groupId, artifactId, ver, classifier);
}
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list