Skip to content

Commit 549164e

Browse files
committed
fix for GRAILS-6970 "Cannot use 'import' statement in Grails Config"
1 parent f4dd3a2 commit 549164e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

scripts/Upgrade.groovy

+9-12
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,15 @@ move it to the new location of '${basedir}/test/integration'. Please move the di
149149
// add reasonable defaults for them
150150
def configFile = new File(baseFile, '/grails-app/conf/Config.groovy')
151151
if (configFile.exists()) {
152-
def configSlurper = new ConfigSlurper()
153-
def configObject = configSlurper.parse(configFile.toURI().toURL())
154-
def defaultCodec = configObject.grails.views.default.codec
155-
def gspEncoding = configObject.grails.views.gsp.encoding
156-
157-
if (!defaultCodec || !gspEncoding) {
158-
configFile.withWriterAppend {
159-
it.writeLine '\n// The following properties have been added by the Upgrade process...'
160-
if (!defaultCodec) it.writeLine 'grails.views.default.codec="none" // none, html, base64'
161-
if (!gspEncoding) it.writeLine 'grails.views.gsp.encoding="UTF-8"'
162-
}
163-
}
152+
def configText = configFile.text
153+
configFile.withWriterAppend {
154+
if(!configText.contains("grails.views.default.codec") ) {
155+
it.writeLine 'grails.views.default.codec="none" // none, html, base64'
156+
}
157+
if(!configText.contains("grails.views.gsp.encoding") ) {
158+
it.writeLine 'grails.views.gsp.encoding="UTF-8"'
159+
}
160+
}
164161
}
165162

166163
if (new File("${basedir}/spring").exists()) {

0 commit comments

Comments
 (0)