Good idea, thanks.

On Thu, Sep 29, 2011 at 12:31 PM, Luke Daley <[email protected]>wrote:

>
> On 29/09/2011, at 5:27 PM, Carlton Brown wrote:
>
> I'll make this correction on the list so others can see it... but there are
> 2 issues with this retrieve code... first, when defining the regexp, Groovy
> seems to choke on the backslash of the \w string..  I had to use the tilde
> constructor to make it work.    Also the regexp was too naive to cover all
> the dependency variations that exist in the wild.   Here's what I got to
> work:
>
> task retrieve(type: Copy) {
>        libsDir = "libs-gradle/compile"
>        delete libsDir
>        from configurations.compile
>        into libsDir
>        rename ~/^([a-z0-9-_]+[a-z0-9])-[0-9]+\..+\.(.+)$/, '$1.$2'
>        eachFile {
>            println "retrieved: $it.name"
>        }
> }
>
> The above code will simplify every naming convention I know of, but it does
> not account for retrieval conflicts.  For example, Ivy would display a
> warning if 2 different jars were simplified to the same name.
>
>
> Instead of using the delete, you should turn this into a sync task:
>
> task retrieve(type: Sync) {
>        libsDir = "libs-gradle/compile"
>        from configurations.compile
>        into libsDir
>        rename ~/^([a-z0-9-_]+[a-z0-9])-[0-9]+\..+\.(.+)$/, '$1.$2'
>        eachFile {
>            println "retrieved: $it.name"
>        }
> }
>
> Sync makes the destination dir exactly match the source, so will remove any
> old files.
>
> --
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>
>

Reply via email to