You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Peter Schröder <ps...@blau.de> on 2009/12/23 08:43:31 UTC

include as is lazy?

sorry, i replied to a message...

Am 22.12.2009 um 21:22 schrieb Peter Schröder:

> hi,
> 
> i have some problem understanding the documentation of packaging:
> 
> snip---
> 
> You can also use :as=>'.' to include all files from the given directory. For example:
> 
> package(:zip).include 'target/docs/*'
> package(:zip).include 'target/docs', :as=>'.'
> 
> These two are almost identical. They both include all the files from the target/docs directory, but not the directory itself. But they operate differently. The first line expands to include all the files in target/docs. If you don’t already have files in target/docs, well, then it won’t do anything interesting. Your ZIP will come up empty. The second file includes the directory itself, but strips the path during inclusion. You can define it now, create these files later, and then ZIP them all up.
> 
> ---snip
> 
> i couldnt figure out where there is a difference between the two definitions. 
> 
> this is what i thought should create zips with different content:
> 
>  # this selects all files currently available in the include-directory (and sub-directory)
>  package(:file=>_(:target, 'direct_include.zip')).include('target/resources/*')
>  # this selects the same but not at definition-time but at execution-time
>  package(:file=>_(:target, 'lazy_include.zip')).include('target/resources', :as=>'.')
> 
>  # extend the build-task to write some additional file
>  build do
>    write('target/resources/additional.txt', 'content')
>  end
> 
> feel free to bash on my naive approach ;-)
> 
> happy christmas to everyone