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.

On Tue, Sep 27, 2011 at 4:34 PM, Luke Daley <[email protected]>wrote:

>
> On 27/09/2011, at 8:33 PM, Carlton Brown wrote:
>
> One more question on the 'retrieve' code... I notice that the jars copied
> by Gradle have revision numbers in the filename.   Is there a way to access
> just the jar name without the revision number?   In Ivy this would be a
> simple matter of specifying the right retrieval pattern to the retrieve
> task.
>
>
> You'd do this at the level of files in Gradle, not at the Ivy level.
>
> task doTestRetrieve(type: Copy) {
>        from configurations.compile
>        into "myDependencies"
>        rename "(.+)-.+\\.(\w+)", '$1.$2'
>        eachFile {
>            println "retrieving dependency: $it.name"
>        }
> }
>
> Or if regexes aren't your thing there are other ways to do the rename.
>
> --
>
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>
>

Reply via email to