Cannot filter files bigger than 64K

While attempting to migrate our first project from Maven to Gradle we are running in the following issue.

Here is a simple gradle script:

task filterBigFile(type: Copy) {
 from '.'
 into 'build/big_file_filtered.txt'
 include 'big_file.txt'
 expand(expand_me: 'test')
}

If ‘big_file’ is bigger than 64K, the copy task will fail with the following stacktrace: https://gist.github.com/anonymous/20b64ee5992c312bc01d

Reproduced with Gradle 2.0 and 1.12.

Filtering with maven is working as expected.

Any feedback is welcome.

Thanks, Marc

expand() just won’t work on a file this big. The filter() methods will work though, and will be more efficient.

Hello Luke, thanks for the hint!

However, it seems that the filter method as other shortcomings: - Using the ReplaceTokens ant filter (as proposed in the documentation) requires a Hashtable, which does not accept null as key or value. So, I cannot directly use the HashMap project.properties. - ReplaceTokens only allows a single character delimiter, in turn, we cannot use the maven default syntax (${…}) for filtering (we have some shared resource files that are used both by maven and gradle).

The documentation only sparingly describes the differences between expand and filter. The 64k limit should really be explicitly stated IMHO.

I could probably work around these limitations one way or another, but I will submit a ticket on the subject I think. (filtering is such an important feature, we should at least have parity with maven)

Hi Marc,

Can you try with Gradle 2.0 please to see if this is fixed by the newer Groovy version.

If it doesn’t work what we might look at doing is use https://github.com/mbjarland/groovy-streaming-template-engine as the basis for this templating to get around this limit.

btw, this is the Groovy issue: http://jira.codehaus.org/browse/GROOVY-3457

Sorry, just saw that you have already tried with 1.12.

The project from Matias on GitHub that you refer to looks suitable but unfortunately, it is licensed under GNU.