Hey,

Here's one of the ways that should work:

    copy {
        from zipTree(configurations.additionalResources.singleFile).matching
{ include 'install/*.sql' }.files
        into "/target/database"
    }

matching() method gets the files you need, then getFiles() method
'flattens' them.

Cheers!
Szczepan

On Mon, May 2, 2011 at 11:22 AM, Baur, Thomas
<[email protected]> wrote:
>> Here is a way to achieve this:
>>
>> configurations {
>>   additionalResources
>> }
>>
>> dependencies {
>>   additionalResources "foo:bar:1.0"
>> }
>>
>> task copyAdditionalResources(type: Copy) {
>>   from { zipTree(configurations.additionalResources.singleFile) }
>>   into sourceSets.main.classesDir
>>   include ...
>> }
>>
>> classes.dependsOn(copyAdditionalResources)
>
> Thanks a lot, that basically solved the problem. But now...
>
> Is there any way I can address files in subdirectories of a FileTree created 
> with zipTree(), so that they do not retain their subdirectory position?
>
> If I do a
>
>    copy {
>        from zipTree(configurations.additionalResources.singleFile)
>        include 'install/*.sql'
>        into "/target/database"
>    }
>
> then the files matching the include-pattern end up in 
> /target/database/install, but I just want a flat copy like I could achieve 
> with an ant fileset. It seems that on file trees created using the 
> project.fileTree() method the files are referenced relative to the "dir" 
> passed in the argument map, but I cannot do that for zipTree(). Wouldn't it 
> be good to have an overloaded project.zipTree() method which too receives a 
> map or arguments to address a subdirectory in the zip-file directly?
>
> Thomas Baur
>
> ---------------------------------------
> Atos Worldline GmbH
> Pascalstr. 19
> 52076 Aachen
> Germany
> Phone: +49 (2408) 148 471
> Fax: +49 (2408) 148 204
> Mobile: +49 (175) 2252839
> eMail: [email protected]
> http://www.atosworldline.com
>
> Geschäftsführer: Wolf Kunisch
> Aufsichtsratsvorsitzender: Didier Dhennin
> Sitz der Gesellschaft: Frankfurt/M.
> Handelsregister: Frankfurt/Main HRB 40 417
>
> * * * * * * * * L E G A L    D I S C L A I M E R * * * * * * * *
> This e-mail and the documents attached are confidential and intended solely 
> for the addressee; it may also be privileged. If you receive this e-mail by 
> error, please notify the sender immediately and destroy it. As its integrity 
> cannot be secured on the internet, the Atos Origin group liability cannot be 
> triggered for the message content. Although the sender endeavours to maintain 
> a computer virus-free network, the sender does not warrant that this 
> transmission is virus-free and shall not be liable for any damages resulting 
> from any virus transmitted.
> * * * * * * * * L E G A L    D I S C L A I M E R * * * * * * * *
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to