diff --git a/src/main/java/com/jfrog/mavendeptree/Utils.java b/src/main/java/com/jfrog/mavendeptree/Utils.java index a54d33c..99e8d42 100644 --- a/src/main/java/com/jfrog/mavendeptree/Utils.java +++ b/src/main/java/com/jfrog/mavendeptree/Utils.java @@ -75,7 +75,7 @@ static void populateDependencyMap(DependencyNode node, Map configurations = new HashSet<>(); private final Set types = new HashSet<>(); + private String classifier; - public MavenDependencyNode(String configuration, String type) { + public MavenDependencyNode(String configuration, String type, String classifier) { if (configuration != null) { this.configurations.add(configuration); } if (type != null) { this.types.add(type); } + if (classifier != null) { + this.setClassifier(classifier); + } } public void addChild(String childName) { @@ -41,9 +45,13 @@ public void addType(String type) { types.add(type); } + public void setClassifier(String classifier) { + this.classifier = classifier; + } + @Override public int hashCode() { - return Objects.hash(children, configurations, types); + return Objects.hash(children, configurations, types, classifier); } @Override @@ -52,6 +60,8 @@ public boolean equals(Object obj) { return false; } MavenDependencyNode other = (MavenDependencyNode) obj; - return children.equals(other.children) && configurations.equals(other.configurations); + return children.equals(other.children) && + configurations.equals(other.configurations) && + Objects.equals(classifier,other.classifier); } } diff --git a/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java b/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java index c884ffc..8a63dbe 100644 --- a/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java +++ b/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java @@ -68,7 +68,7 @@ public void testMultiModule() throws VerificationException, IOException, ParserC assertEquals(root, "org.jfrog.test:multi3:3.7-SNAPSHOT"); } else { assertEquals(root, "org.jfrog.test:multi:3.7-SNAPSHOT"); - assertEquals(mavenDependencyTree.getNodes().get("junit:junit:3.8.1"), new MavenDependencyNode("test", "jar")); + assertEquals(mavenDependencyTree.getNodes().get("junit:junit:3.8.1"), new MavenDependencyNode("test", "jar", null)); } } } @@ -98,11 +98,16 @@ private void testMavenArchetype(String projectName) throws VerificationException // Check nodes Map nodes = mavenDependencyTree.getNodes(); - assertEquals(nodes.size(), 2); + assertEquals(nodes.size(), 3); MavenDependencyNode expectedFirstNode = new MavenDependencyNode(); expectedFirstNode.addChild("junit:junit:3.8.1"); - assertEquals(nodes.get("org.example:maven-archetype-simple:1.0-SNAPSHOT"), expectedFirstNode); - MavenDependencyNode expectedSecondNode = new MavenDependencyNode("test", "jar"); + expectedFirstNode.addChild("org.testng:testng:5.9-jdk15"); + MavenDependencyNode node1 = nodes.get("org.example:maven-archetype-simple:1.0-SNAPSHOT"); + assertEquals(node1, expectedFirstNode); + MavenDependencyNode expectedSecondNode = new MavenDependencyNode("test", "jar", null); assertEquals(nodes.get("junit:junit:3.8.1"), expectedSecondNode); + // with classifier + MavenDependencyNode expectedThirdNode = new MavenDependencyNode("test", "jar", "jdk15"); + assertEquals(nodes.get("org.testng:testng:5.9-jdk15"), expectedThirdNode); } } diff --git a/src/test/resources/integration/maven-archetype-dependency-management/pom.xml b/src/test/resources/integration/maven-archetype-dependency-management/pom.xml index 7daa0b9..a55ac25 100644 --- a/src/test/resources/integration/maven-archetype-dependency-management/pom.xml +++ b/src/test/resources/integration/maven-archetype-dependency-management/pom.xml @@ -25,6 +25,13 @@ junit test + + org.testng + testng + jdk15 + 5.9 + test + diff --git a/src/test/resources/integration/maven-archetype-simple/pom.xml b/src/test/resources/integration/maven-archetype-simple/pom.xml index e1ac5bd..18945de 100644 --- a/src/test/resources/integration/maven-archetype-simple/pom.xml +++ b/src/test/resources/integration/maven-archetype-simple/pom.xml @@ -26,6 +26,13 @@ 3.8.1 test + + org.testng + testng + jdk15 + 5.9 + test +