Zip expand problem - SimpleTemplateScript61.groovy: 1: String too long

(Povl Kvols) #1

Hi there.

Trying to make some property files for a system, based on replacing relatively few properties in a number of files for test, production, etc.

For that purpose I created a small task:

task filterProperties(type: Zip) {
    from fileTree('SystemPropertyFiles')
    archiveName "Config-${env}.zip"
    def properties= new Properties()
    file(configFile).withInputStream {

All worked well until a 350 KB XML file came along and Gradle failed with the error:

SimpleTemplateScript61.groovy: 1: String too long. The given string is 343682 Unicode code units long, but only a maximum of 65535 is allowed.

64 K seems like a thing of a distant past - is this issue being worked on? It’s really a great feature to filter files like this in Gradle, and I’d hate to go back to Ant for this!

Is there an easy work-around - e.g. filtering files line-by-line?

(Peter Niederwieser) #2

The ‘expand’ method is based on Groovy’s ‘SimpleTemplateEngine’, which has some known limitations. For more robust filtering, use one of the ‘filter’ methods (see Gradle Build Language Reference for details).

(Luke Daley) #3

This is GRADLE-3122.

(Povl Kvols) #4

Thank you both for the quick replies.

Regarding the “robustness” of the Ant-based filter, I really do not agree. The syntax for the templates is really lousy, and what’s even worse:

  • Unknown tokens are silently ignored!

  • No way of doing anything intelligent at the insertion!

  • Escaping ‘@’ characters?

I really hope this bug gets fixed in Groovy soon. The expand method is a great way of substituting properties in an intelligent way,