From 549164e08251e4b73d7a2664d82a89dd4acc8736 Mon Sep 17 00:00:00 2001 From: Graeme Rocher Date: Tue, 14 Dec 2010 14:58:46 +0100 Subject: [PATCH] fix for GRAILS-6970 "Cannot use 'import' statement in Grails Config" --- scripts/Upgrade.groovy | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/Upgrade.groovy b/scripts/Upgrade.groovy index 50fec3ad032..04cb695ad8b 100755 --- a/scripts/Upgrade.groovy +++ b/scripts/Upgrade.groovy @@ -149,18 +149,15 @@ move it to the new location of '${basedir}/test/integration'. Please move the di // add reasonable defaults for them def configFile = new File(baseFile, '/grails-app/conf/Config.groovy') if (configFile.exists()) { - def configSlurper = new ConfigSlurper() - def configObject = configSlurper.parse(configFile.toURI().toURL()) - def defaultCodec = configObject.grails.views.default.codec - def gspEncoding = configObject.grails.views.gsp.encoding - - if (!defaultCodec || !gspEncoding) { - configFile.withWriterAppend { - it.writeLine '\n// The following properties have been added by the Upgrade process...' - if (!defaultCodec) it.writeLine 'grails.views.default.codec="none" // none, html, base64' - if (!gspEncoding) it.writeLine 'grails.views.gsp.encoding="UTF-8"' - } - } + def configText = configFile.text + configFile.withWriterAppend { + if(!configText.contains("grails.views.default.codec") ) { + it.writeLine 'grails.views.default.codec="none" // none, html, base64' + } + if(!configText.contains("grails.views.gsp.encoding") ) { + it.writeLine 'grails.views.gsp.encoding="UTF-8"' + } + } } if (new File("${basedir}/spring").exists()) {