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

Support for Add Filters on 'multi' add methods

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0-alpha-3
    • None
    • None
    • None

      When assembling Archives using methods like:
      archive.add(archive)
      archive.addPackages(true, Package.getPackage("org.junit"))

      it would be useful to have some sort of 'AcceptFilter' to minimize the work.

      Usecase -1:
      you want to add Package org.junit but NOT junit.org.runners.model. The way it works now is you have to add every single package 'around' the one you want don't want. This can be a pretty big list.

      Usecase-2:
      You want to merge two archives, but use your own descriptors..

      Possible impl..

      interface Filter<T> {
        boolean accept(T obj);
      }
      
          addPackage(Boolean recursive, Filter<Class<?>> filter, Package... packs) 
          {
            for(Class<?> class : package) 
            {
               if(filter.accept(class)) 
               {
                  addClass(class);
               }
            }
          }
      

      This way we could create archives like:

        archive.addPackage(
                       true, 
                      new RegExpExcludeFilter(".*/models/.*"), 
                     Package.getPackage("org.junit")
        )  
      
        archive.add(
                     otherArchive,
                     new RegExpIncludeFilter("/META-INF/*")
        )  
      
      

              arubinge@redhat.com Andrew Rubinger (Inactive)
              aslak@redhat.com Aslak Knutsen
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: