Uploaded image for project: 'ShrinkWrap Resolvers'
  1. ShrinkWrap Resolvers
  2. SHRINKRES-190

implements equals and hashCode methods in MavenResolvedArtifactImpl / MavenArtifactInfoImpl

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 2.2.0-beta-1
    • 2.1.1
    • maven
    • None

      I'm currently to find an effective way to filter out many dependencies at once that I could provide within a "dummy" pom.xml.

      I'd like to do the following:

          public static List<MavenResolvedArtifact> resolveAllTestNonTransitiveDependencies() {
          	return Arrays.asList(
          			Maven.resolver()
      					.loadPomFromFile("pom.xml")
      					.importTestDependencies().resolve()
      					.withoutTransitivity()
      					.asResolvedArtifact());
          }
          
          public static List<MavenResolvedArtifact> resolveAllArquillianDependencies() {
          	return Arrays.asList(
          			Maven.resolver()
      					.loadPomFromFile("src/test/resources/arquillian.pom.xml")
      					.importTestDependencies().resolve()
      					.withoutTransitivity()
      					.asResolvedArtifact());
          }
          
          public static List<MavenResolvedArtifact> resolveAllTestNonTransitiveNonArquillianDependencies() {
          	List<MavenResolvedArtifact> testDependencies = resolveAllTestNonTransitiveDependencies();
          	
          	List<MavenResolvedArtifact> arquillianDependencies = resolveAllArquillianDependencies();
          	
          	List<MavenResolvedArtifact> filteredTestDependencies = new ArrayList<MavenResolvedArtifact>();
          	for (MavenResolvedArtifact testDependency : testDependencies) {
          		if (!arquillianDependencies.contains(testDependency)) {
          			filteredTestDependencies.add(testDependency);
          		}
          	}
          	return filteredTestDependencies;
          }
      

      The problem is that MavenResolvedArtifactImpl does not implements equals and hashCode needed for using Collection::contains method.

      I think it would be safe to delegate MavenResolvedArtifactImpl / MavenArtifactInfoImpl equals and hashCode methods to the one defined in MavenCoordinateImpl

      Thanks,

              kpiwko Karel Piwko
              mathieu@mathieulachance.com Mathieu Lachance (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: