Hi,

At our company we're currently pretty far in switching to gradle. Really
liking the ease and brevity with wich you can do things compared to maven
(16668 lines with maven vs 3991 lines with gradle and nearly the same
functionality).

In preparation of completing the switch we did some more testing and ran
into an unexpected issue with the use of zipTree. For our distribution we
fold a number of zips (eclipse virgo distribution and yajsw) into one new
zip while relocating files on the fly, and also include our own artifacts.
This works all like a charm.

Our task looks like this (stripped down):

task dist(type: Zip, dependsOn: cleanDist) {
    description = "Build distribution ZIP"

    // make dist depend on the jar files of the sub projects
    subprojects {
        dependsOn(it.jar)
    }

    def virgoFileTree = zipTree(configurations.server.getSingleFile())
    def wrapperFileTree =
zipTree(configurations.serviceWrapper.getSingleFile())

    // docs
    def virgoDocPath = 'docs/virgo-' + virgo_version
    virgoFileTree.matching({include "**/docs/**/*"}).each {
        newPath = it.path.substring(it.path.indexOf('/docs/') + 5,
it.path.lastIndexOf('/'))
        from(it) { into (virgoDocPath + newPath) }
    }
   ....
}

The issue we now run into is that the include in the matching part works,
but the indexOf's fail due to it.path using slashes on unix and backslashes
on windows. I had expected things to be normalized to slashes. As I more or
less expected going on
http://gradle.org/current/docs/javadoc/org/gradle/api/file/FileTreeElement.html#getPath%28%29
.

So while I explore different approaches to the renaming, I ask the question
should the above work cross platform?

Thanks,

Ric

PS using milestone 3

Reply via email to