Grails: UI-Performance plugin - issue with encodings

After getting the UI-performance plugin to work, I started to address an issue I got with charsets and my js files.

I have some Swedish messages in some of my JavaScript files, and as such they have Swedish characters. While I was branching them I managed to change the charset of the files somehow, so they weren’t UTF-8. Easy enough to fix. However, after fixing them the error still occurred in the production environment.

After some tracking it turns out that the bundling process of the UI-performance plugin works with the system default character encoding in some parts of the files, and with a specified encoding in another. Non-bundled files are OK. The missing code is in the ResourceVersionHelper.groovy file on line 357 to 364.

private void concatenate(List files, String name, String subdir, String ext, File stagingDir) {     new File(stagingDir, "$subdir/${name}.$ext").withWriter { writer ->        files.each { file ->             writer.write new File(stagingDir, "$subdir/${file}.$ext").text             writer.write '\n'         }     } }

Fixing it could be like this, but adding the charset as a parameter will allow for better configuration.

private void concatenate(List files, String name, String subdir, String ext, File stagingDir) {     new File(stagingDir, "$subdir/${name}.$ext").withWriter( "utf-8", { writer ->         files.each { file ->             writer.write new File(stagingDir, "$subdir/${file}.$ext").getText('utf-8')             writer.write '\n'         }     }) }

Still nice work Burt.

Jira ticket: http://jira.codehaus.org/browse/GRAILSPLUGINS-1079

Update: This is resolved in version: 1.1.1 of the UI-Performance plugin