Uploaded image for project: 'ShrinkWrap'
  1. ShrinkWrap
  2. SHRINKWRAP-298

Add "addAsLibraries(Archive<?>[]... archives)" to LibraryContainer

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • 1.0.0-beta-5
    • 1.0.0-beta-3
    • api
    • None

    Description

      Very often, I use the MavenDependencyResolver to obtain Maven dependencies. I use an interface for this purpose:

      public interface Dependencies {
          public static final Archive<?>[] SEAM_SOLDER = DependencyResolvers.use(MavenDependencyResolver.class)
                  .loadReposFromPom("pom.xml").artifact("org.jboss.seam.solder:seam-solder").exclusion("*")
                  .resolveAs(GenericArchive.class).toArray(new Archive<?>[0]);
      
          public static final Archive<?>[] SEAM_CATCH = DependencyResolvers.use(MavenDependencyResolver.class)
                  .loadReposFromPom("pom.xml").artifact("org.jboss.seam.catch:seam-catch").exclusion("*")
                  .resolveAs(GenericArchive.class).toArray(new Archive<?>[0]);
      
      ...
      }
      

      Every dependency is represented by an array of archives (Archive<?>[]) since it may also contain transitive dependencies. Therefore, when adding these libraries to (let's say) web archive, I have to call addAsLibraries() separately for every dependency:

      war.addAsLibraries(SEAM_SOLDER).addAsLibraries(SEAM_CATCH).addAsLibraries(SEAM_REST);
      

      I propose to extend the LibraryContainer interface and add the following method:

      T addAsLibraries(Archive[]<?>... archives) throws IllegalArgumentException;
      

      This would allow for maven dependencies to be added easily:

      war.addAsLibraries(SEAM_SOLDER, SEAM_CATCH, SEAM_REST);
      

      Attachments

        Activity

          People

            tommysdk Tommy Tynjä (Inactive)
            rhn-engineering-jharting Jozef Hartinger
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: