On 10 Feb 2014, at 4:04 pm, Luke Daley <l...@ldaley.com> wrote:

> Hi,
> 
> Would you expect the following to pass?
> 
>        given:
>        file("a/b.txt") << "\$foo"
> 
>        when:
>        buildScript """
>            task c(type: Copy) {
>                from("a") {
>                    filesMatching("b.txt") {
>                        expand foo: "bar"
>                    }
>                    into "nested"
>                }
>                into "out"
>            }
>        """
> 
>        then:
>        succeeds "c"
> 
>        and:
>        file("out/nested/b.txt").text == "bar"
> 
> 
> It doesn't. It turns out that filesMatching matches the relative destination 
> path, so it needs to be filesMatching("nested/b.txt"). I find this a little 
> surprising.
> 
> It seems like it would be more predictable to use the relative path to the 
> file from the nearest 'from' statement. What's the rationale for the current 
> behaviour?

It’s just a bug, I would think. The pattern should be relative to the source 
path, not the destination path. An interesting question is what to do with 
those files whose name is transformed in some way (eg using rename()) - is the 
pattern applied before or after transformation?


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com



Reply via email to