StackOverflow during simple file copy in Gradle 1.8

I have a task includes the following action

project.copy {
CopySpec cs ->
 cs.from('src/main/conf')
 cs.into('build/dist')
 cs.includeEmptyDirs = false
}

and which now produces a stackoverflow in this code

at org.gradle.api.internal.file.CompositeFileCollection$1.resolve(CompositeFileCollection.java:88)
        at org.gradle.api.internal.file.CompositeFileTree$FilteredFileTree.resolve(CompositeFileTree.java:91)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveNested(DefaultFileCollectionResolveContext.java:143)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:101)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveContext.java:182)
        at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)

This worked in gradle 1.0-1.6

Any idea what is going wrong or how to debug this?

I’m not able to reproduce this. Can you post a minimal self-contained example that allows to reproduce the issue?

It looks like it is related to use of GString, put the following in a build.gradle and run it using gradle 1.8

task doIt {
    ext {
        source = "a"
        dest = "b"
    }
    doLast {
        project.copy { CopySpec cs ->
            cs.from(source)
            cs.into(dest)
        }
    }
}

result = stackoverflow

If you pass source.toString() and dest.toString() instead and it works fine.

If you use gradle 1.7 instead (and pass the gstring referencess in), it also works fine hence is clearly a regression in 1.8 If you don’t use a reference and pass “a” in directly, it also works fine.

‘“a”’ and ‘“b”’ aren’t GStrings (they don’t contain a ‘$’).

As of 1.8, ‘source’ inside ‘project.copy’ gets resolved to ‘CopySpec.getSource()’. In earlier versions, it gets resolved to ‘doIt.ext.source’. Not sure which is right, but it needs to be investigated. Raised GRADLE-2902. Meanwhile, renaming ‘doIt.ext.source’ will solve the problem.

Ah OK, I simplified my example too far (my actual case contains $)

OK thanks. Quick fixes are good!