You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Ittay Dror <it...@gmail.com> on 2008/10/19 12:32:19 UTC

archive task with "sparse" files

Hi,

I want to build a zip by picking out specific files.

Say my tree is
a/
  b/
    c/
      D.class
      E.class
    f/
      G.class
      H.class

I want to package D.class and G.class only.

What is the cleanest way of doing that?

The cleanest way seems to me if I could pass the task a base directory 
and a list of relative paths so it will include the paths in the zip 
(as-is) taken from expanding them with the base directory (e.g., 
zip('a/b/c/D.class', 'a/b/f/G.class', :base => compile.target, :as-is => 
true))

AFAIK, I can do:
zip.include("#{compile.target}/a/b/c/D.class", :as => 'a/b/c/D.class')
zip.include("#{compile.target}/a/b/f/G.class", :as => 'a/b/f/G.class')

or:
zip.path('a/b/c').include("#{compile.target}/a/b/c/D.class")
zip.path('a/b/f').include("#{compile.target}/a/b/f/G.class")

or:
['a/b/c/D.class', 'a/b/f/G.class'].each do |path|
  zip.include("#{compile.target}/#{path}", :as => path
end

All of which look "unclean" to me.

Thanks,
Ittay

-- 
--
Ittay Dror <it...@gmail.com>



Re: archive task with "sparse" files

Posted by Alex Boisvert <bo...@intalio.com>.
On Sun, Oct 19, 2008 at 3:32 AM, Ittay Dror <it...@gmail.com> wrote:

> Hi,
>
> I want to build a zip by picking out specific files.
>
> Say my tree is
> a/
>  b/
>   c/
>     D.class
>     E.class
>   f/
>     G.class
>     H.class
>
> I want to package D.class and G.class only.
>
> What is the cleanest way of doing that?
>
> The cleanest way seems to me if I could pass the task a base directory and
> a list of relative paths so it will include the paths in the zip (as-is)
> taken from expanding them with the base directory (e.g.,
> zip('a/b/c/D.class', 'a/b/f/G.class', :base => compile.target, :as-is =>
> true))
>
> AFAIK, I can do:
> zip.include("#{compile.target}/a/b/c/D.class", :as => 'a/b/c/D.class')
> zip.include("#{compile.target}/a/b/f/G.class", :as => 'a/b/f/G.class')
>
> or:
> zip.path('a/b/c').include("#{compile.target}/a/b/c/D.class")
> zip.path('a/b/f').include("#{compile.target}/a/b/f/G.class")


I agree it's not exactly good-looking.  It would be nice to be able to write
something like:

package(:jar).include_classes [ 'a.b.c.D', 'a.b.f.G', 'a.b.j.*' ]

alex

Re: archive task with "sparse" files

Posted by Assaf Arkin <ar...@intalio.com>.
On Sun, Oct 19, 2008 at 3:32 AM, Ittay Dror <it...@gmail.com> wrote:
> Hi,
>
> I want to build a zip by picking out specific files.
>
> Say my tree is
> a/
>  b/
>   c/
>     D.class
>     E.class
>   f/
>     G.class
>     H.class
>
> I want to package D.class and G.class only.
>
> What is the cleanest way of doing that?
>
> The cleanest way seems to me if I could pass the task a base directory and a
> list of relative paths so it will include the paths in the zip (as-is) taken
> from expanding them with the base directory (e.g., zip('a/b/c/D.class',
> 'a/b/f/G.class', :base => compile.target, :as-is => true))
>
> AFAIK, I can do:
> zip.include("#{compile.target}/a/b/c/D.class", :as => 'a/b/c/D.class')
> zip.include("#{compile.target}/a/b/f/G.class", :as => 'a/b/f/G.class')
>
> or:
> zip.path('a/b/c').include("#{compile.target}/a/b/c/D.class")
> zip.path('a/b/f').include("#{compile.target}/a/b/f/G.class")
>
> or:
> ['a/b/c/D.class', 'a/b/f/G.class'].each do |path|
>  zip.include("#{compile.target}/#{path}", :as => path
> end

:base would be easiest because you can specify multiple files/patterns
in a single include.

Assaf

>
> All of which look "unclean" to me.
>
> Thanks,
> Ittay
>
> --
> --
> Ittay Dror <it...@gmail.com>
>
>
>