[java-identity-provider] 01/02: JPAR-175 Add a source pom filename to each artifact for later reporting
Rod Widdowson
rdw at steadingsoftware.com
Fri Jun 18 13:30:50 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch dev/JPAR-175
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=1db3455ea68d1e9725b82047a5b592a992b37ada
commit 1db3455ea68d1e9725b82047a5b592a992b37ada
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Thu Jun 17 16:15:24 2021 +0100
JPAR-175 Add a source pom filename to each artifact for later reporting
There maybe a better way to attach this to the parsed pom. But that is
lost when the output is written, so I think this is OK.
https://issues.shibboleth.net/jira/browse/JPAR-175
---
.../idp/dependencies/DependencyTest.java | 7 ++--
.../net/shibboleth/idp/dependencies/ParsedPom.java | 40 ++++++++++++++++------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
index 9eeb2ec38..2b65889e6 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
@@ -188,15 +188,16 @@ public class DependencyTest extends OpenSAMLInitBaseTestCase {
for (PomArtifact artifact : dependencies) {
final String id = artifact.getArtifactId();
final String ver = artifact.getVersion();
+ final String sourcePomFilename = artifact.getSourcePomFilename();
final String version = names.remove(id);
if (artifact.equals(last)) {
- report.format("%-22s\t: %-12s\tDUPLICATE artifact\n", id, ver);
+ report.format("%-22s\t: %-12s\tDUPLICATE artifact\t%-22s\n", id, ver, sourcePomFilename);
dupNames++;
} else if (version == null) {
- report.format("%-22s\t: %-12s\tNOT found in war\n", id, ver);
+ report.format("%-22s\t: %-12s\tNOT found in war\t%-22s\n", id, ver, sourcePomFilename);
nonUsed++;
} else if (version.equals(ver)) {
- report.format("%-22s\t: %-12s\tFound in war\n", id, ver);
+ report.format("%-22s\t: %-12s\tFound in war\t%-22s\n", id, ver, sourcePomFilename);
found++;
analyzeChild(dependencySource, artifact);
} else {
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
index ed7fb9ede..9e276be42 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
@@ -90,11 +90,12 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
throw new XMLParserException("Top level element was not <project>");
}
final List<Element> par = ElementSupport.getChildElementsByTagName(el, "parent");
+
if (!par.isEmpty()) {
- parseParent(par.get(0));
+ parseParent(par.get(0), pom.getFileName().toString());
}
- us = new PomArtifact(el, parent);
+ us = new PomArtifact(el, parent, pom.getFileName().toString());
if (parentPomProperties == null) {
return;
@@ -116,7 +117,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
final List<Element> dependencyMgt = ElementSupport.getChildElementsByTagName(el, "dependencyManagement");
if (!dependencyMgt.isEmpty()) {
final List<Element> dependencies = ElementSupport.getChildElementsByTagName(dependencyMgt.get(0), "dependencies");
- parseDependencies(dependencies.get(0));
+ parseDependencies(dependencies.get(0), pom.getFileName().toString());
}
}
@@ -133,8 +134,9 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
/**
* @param item
+ * @param pomSource the filename of the POM.
*/
- private void parseDependencies(Element item) {
+ private void parseDependencies(Element item, final String pomSource) {
final List<Element> dependencies = ElementSupport.getChildElementsByTagName(item, "dependency");
for (Element dependency : dependencies) {
@@ -142,7 +144,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
if (!types.isEmpty()) {
final String type = StringSupport.trimOrNull(types.get(0).getTextContent());
if ("pom".equals(type)) {
- bomDependencies.add(new PomArtifact(dependency));
+ bomDependencies.add(new PomArtifact(dependency,pomSource));
continue;
} else if (!"jar".equals(type)) {
// not for us
@@ -157,7 +159,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
continue;
}
}
- final PomArtifact dep = new PomArtifact(dependency);
+ final PomArtifact dep = new PomArtifact(dependency,pomSource);
compileDependencies.add(dep);
}
}
@@ -176,9 +178,10 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
/**
* @param item
+ * @param pomSource the filename of the POM this artifact is being extracted from.
*/
- private void parseParent(Element item) {
- parent = new PomArtifact(item);
+ private void parseParent(Element item, final String pomSource) {
+ parent = new PomArtifact(item, pomSource);
}
/**
@@ -219,6 +222,9 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
/** Encapsulation of a <dependency> element. */
public class PomArtifact implements Comparable<PomArtifact>{
+ /** Which physical POM this artifact is listed in.*/
+ @Nonnull private final String sourcePomFilename;
+
/** <groupId>.*/
@Nonnull private final String groupId;
@@ -235,9 +241,10 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
* Constructor.
*
* @param item element to interrogate.
+ * @param pomSource the filename of the POM this artifact is being extracted from.
*/
- public PomArtifact(Element item) {
- this(item, null);
+ public PomArtifact(final Element item, final String pomSource) {
+ this(item, null, pomSource);
}
/**
@@ -245,8 +252,12 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
*
* @param item element to interrogate.
* @param parentArtifact to inherit from
+ * @param pomSource the filename of the POM this artifact is being extracted from.
*/
- public PomArtifact(final Element item, final @Nullable PomArtifact parentArtifact) {
+ public PomArtifact(final Element item, final @Nullable PomArtifact parentArtifact,
+ final String pomSource) {
+
+ sourcePomFilename = pomSource;
final List<Element> grps = ElementSupport.getChildElementsByTagName(item, "groupId");
if (grps.size() > 0) {
@@ -307,6 +318,13 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
public String getVersion() {
return version;
}
+
+ /**
+ * @return the pom source.
+ */
+ public String getSourcePomFilename() {
+ return sourcePomFilename;
+ }
/**
* @return Returns the exclusions.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list