2 Replies Latest reply on Jul 21, 2014 9:00 AM by matlach

    better way to filter arquillian/shrinkwrap test dependencies from war archive?

    matlach

      Hi,

       

      I'm using the Shrinkwrap Maven resolver to construct a War Archive packaging all my pom.xml dependencies.

      To get all the runtime dependencies I use:

       

      Maven.resolver()
        .loadPomFromFile("pom.xml")
        .importRuntimeDependencies().resolve()
        .withTransitivity()
        .asResolvedArtifact()
      

      which work perfectly.

       

      But then, I also need to add my test scoped dependencies:

      Maven.resolver()
        .loadPomFromFile("pom.xml")
        .importTestDependencies().resolve()
        .withTransitivity()
        .asResolvedArtifact()
      

      which lead to some "unwanted" results.

       

      By doing this I'll be pulling both all the Arquillian / Shrinkwrap dependency tree which is pretty impressive and all my other test scoped dependencies (like AssertJ and Logback Simple).

      To filter out the unwanted Arquillian / Shrinkwrap dependencies I'm relying on groupId and artifactId and disabling transitivity:

       

      Maven.resolver()
        .loadPomFromFile("pom.xml")
        .importTestDependencies().resolve()
        .withoutTransitivity()
        .asResolvedArtifact()
      
      MavenResolvedArtifact.getCoordinate().getArtifactId().contains("arquillian")
      MavenResolvedArtifact.getCoordinate().getGroupId().contains("arquillian")
      MavenResolvedArtifact.getCoordinate().getArtifactId().contains("shrinkwrap")
      MavenResolvedArtifact.getCoordinate().getGroupId().contains("shrinkwrap")
      

       

      This technique is working fine though I find it very fragile.

      Is there a better way to filter out all the Arquillian and Shrinkwrap dependencies (with transitivity) so we could be able to only grab all the non Arquillian / Shrinkwrap test scoped dependencies (with transitivity) ?

       

      Thanks,