3 Replies Latest reply on May 13, 2013 12:55 PM by Michal Matloka

    How to create EAR with libraries which have same artifactId for different groups without file name clashing?

    Torsten Juergeleit Newbie

      Hi all,

       

      while I'm new to ShrinkWrap and Arquillian I'm wondering how create an EAR which contains libraries with non-unique artifactIds (same artifactId is used for different groups).

      With the Maven EAR plugin this is solved by customizing the file name mapping via <fileNameMapping>full</fileNameMapping>.

       

      My current workaround is to add the resolved Maven artifacts with a full-qualified name, e.g.

       

       

      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
      MavenResolvedArtifact[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve().withTransitivity().asResolvedArtifact();
      for (MavenResolvedArtifact lib : libs) {
          MavenCoordinate coordinate = lib.getCoordinate();
          String fullMavenArtifactName = coordinate.getGroupId() + "-" + coordinate.getArtifactId() + "-"
              + (coordinate.getClassifier() != null && coordinate.getClassifier().length() > 0 ? coordinate.getClassifier() + "-" : "")
              + coordinate.getVersion() + "." + coordinate.getType();
          ear.addAsLibrary(lib.asFile(), fullMavenArtifactName);
      }
      

       

      Is there a better solution for this?

       

      Thanks

      /Torsten