[java-mvn-enforcer] branch main updated: JMVN-89 Dependency check fails on idp-distiribution
Codeberg
noreply at shibboleth.net
Fri Oct 2 15:17:46 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-mvn-enforcer.
View the commit online:
https://codeberg.org/Shibboleth/java-mvn-enforcer/commit/5f41bccd9e9b6fc17b1c6fecfc762d5de85b27a1
The following commit(s) were added to refs/heads/main by this push:
new 5f41bcc JMVN-89 Dependency check fails on idp-distiribution
5f41bcc is described below
commit 5f41bccd9e9b6fc17b1c6fecfc762d5de85b27a1
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Oct 2 15:01:46 2026 +0100
JMVN-89 Dependency check fails on idp-distiribution
https://shibboleth.atlassian.net/browse/JMVN-89
Add classified to artifact ID when checking for duplicate versions and the like
---
.../mvn/enforcer/impl/DependencyChecker.java | 77 ++++++++++++++++------
1 file changed, 56 insertions(+), 21 deletions(-)
diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/DependencyChecker.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/DependencyChecker.java
index bc8375c..350c381 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/DependencyChecker.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/DependencyChecker.java
@@ -62,12 +62,12 @@ public class DependencyChecker {
/** The parent project, suitable digested. */
private final ProjectPomContext projectContext;
- /** The accumulated Name to Versions we have found. */
- private final Map<String, String> nameToVersion = new HashMap<>();
+ /** The accumulated <artifactId, classifier> to Versions we have found. */
+ private final Map<NameKey, String> nameToVersion = new HashMap<>();
/** The accumulated Map from artifactId to another Map from version to
* all the files that specify it. */
- private final Map<String, Map<String, Set<String>>> dependencySource = new HashMap<>();
+ private final Map<NameKey, Map<String, Set<String>>> dependencySource = new HashMap<>();
/** Accumulated count of jar files with the same name and different versions or sources. */
private int duplicateJars;
@@ -201,10 +201,11 @@ public class DependencyChecker {
DependencyPomArtifact last = null;
for (final DependencyPomArtifact artifact : dependencies) {
- final String id = artifact.getArtifactId();
+ final NameKey key = new NameKey(artifact);
+ final String id = key.toString();
final String ver = artifact.getVersion();
final String sourcePomFilename = "(from " + artifact.getSourcePomFilename() + ")";
- final String version = nameToVersion.remove(id);
+ final String version = nameToVersion.remove(key);
if (parentPom.getGeneratedArtifacts().contains(artifact)) {
if (!artifact.equals(last)) {
report.format("%-30s: %12s\tGenerated by parent war\n", id, ver);
@@ -239,29 +240,30 @@ public class DependencyChecker {
int noSource = 0;
report.format("Dependency sources for jars found but not explicitly defined as a dependency:\n\n");
- final List<String> contributedDeps = new ArrayList<>(nameToVersion.keySet());
- Collections.sort(contributedDeps);
+ final List<NameKey> contributedKeys = new ArrayList<>(nameToVersion.keySet());
+ Collections.sort(contributedKeys);
- for (final String dependency: contributedDeps) {
+ for (final NameKey dependency: contributedKeys) {
+ final String artifactId = dependency.getFirst();
final Map<String, Set<String>> map = dependencySource.get(dependency);
final String version = nameToVersion.get(dependency);
if (map == null) {
- if (!dependency.startsWith("idp-")) {
+ if (!artifactId.startsWith("idp-")) {
report.format("%-22s\t: %-12s\tNo source artifact found\n", dependency, version);
noSource++;
}
} else {
final Set<String> sources = map.remove(version);
if (sources == null) {
- report.format("%-22s\t: %-12s\tNO Dependency contributes this version\n", dependency, version);
+ report.format("%-22s\t: %-12s\tNO Dependency contributes this version (or \n", dependency, version);
noSource ++;
} else {
- reportContributions(dependency, version, sources);
+ reportContributions(dependency.toString(), version, sources);
}
final List<String> versions = new ArrayList<>(map.keySet());
Collections.sort(versions);
for (final String ver:versions) {
- reportContributions(dependency, ver, map.get(ver));
+ reportContributions(dependency.toString(), ver, map.get(ver));
}
}
}
@@ -300,14 +302,15 @@ public class DependencyChecker {
return;
}
final PomArtifact artifact = projectContext.splitFileName(jarPath);
- final String oldName = nameToVersion.put(artifact.getArtifactId(), artifact.getVersion());
- if (oldName == null) {
+ final NameKey key = new NameKey(artifact);
+ final String oldVersion = nameToVersion.put(key, artifact.getVersion());
+ if (oldVersion == null) {
return;
- } else if (oldName.equals(artifact.getVersion())) {
- report.format("File %s present in multiple locations\n", jarPath);
+ } else if (oldVersion.equals(artifact.getVersion())) {
+ report.format("File %s (for Artifact %s) present in multiple locations\n", jarPath, artifact);
} else {
- report.format("File %s present with versions %s and %s\n",
- artifact.getArtifactId(), oldName, artifact.getVersion());
+ report.format("File %s (for Artifact %s) present with version %s\n",
+ jarPath, artifact, oldVersion);
}
duplicateJars++;
}
@@ -402,7 +405,7 @@ public class DependencyChecker {
* @param fileName the file name of the dependency which was down-loaded
* @param artifact the artifact which provoked the download
*/
- private void addDep(final Map<String, Map<String, Set<String>>> dependencySources,
+ private void addDep(final Map<NameKey, Map<String, Set<String>>> dependencySources,
final String fileName,
final DependencyPomArtifact artifact) {
final PomArtifact nameAsArtifact = projectContext.splitFileName(fileName);
@@ -411,12 +414,13 @@ public class DependencyChecker {
// it's us. Not interesting
return;
}
+ final NameKey nameAsKey = new NameKey(nameAsArtifact);
// for each version, what contributed this dependency
- Map<String, Set<String>> depEntry = dependencySources.get(nameAsArtifact.getArtifactId());
+ Map<String, Set<String>> depEntry = dependencySources.get(nameAsKey);
if (depEntry == null) {
depEntry = new HashMap<>();
- dependencySources.put(nameAsArtifact.getArtifactId(), depEntry);
+ dependencySources.put(nameAsKey, depEntry);
}
Set<String> provider = depEntry.get(nameAsArtifact.getVersion());
if (provider == null) {
@@ -488,5 +492,36 @@ public class DependencyChecker {
}
return file;
}
+
+ /**
+ * Sortable Pair.
+ */
+ private static class NameKey extends Pair<String, String> implements Comparable<NameKey> {
+
+ /**
+ * Constructor.
+ *
+ * @param artifactId the artifactID (sorted on)
+ * @param classifier the classified (to distinguish)
+ */
+ public NameKey(final PomArtifact artifact) {
+ super(artifact.getArtifactId(), artifact.getClassifier());
+ }
+
+ /** {@inheritDoc} */
+ public int compareTo(NameKey o) {
+ return getFirst().compareTo(o.getFirst());
+ }
+
+
+ /** {@inheritDoc} */
+ public String toString() {
+ if (getSecond().isEmpty()) {
+ return getFirst();
+ }
+ return getFirst() + "(" + getSecond() + ")";
+ }
+
+ }
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list