Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.8.3
-
Fix Version/s: None
-
Component/s: groovy-jdk
-
Labels:
-
Environment:winxp, jdk6
-
Number of attachments :
Description
config file is as below:
list('XX') {
one {
a = 100
b = 200
c {
x1 = "x1"
x2
}
}
two = "2000"
}
ConfigSlurper can parse correctly. But when call its writeTo method to a file, the file like this:
list="XX"
one."list.a"=100
one."list.b"=200
one"list.x1"="x1"
onex2."list.y1"=1
"list.two"="2000"
This output file cannot be re-parsed.
The error message in stdout as below:
[list:XX, one:[list.a:100, list.b:200, c:[list.x1:x1, x2:[list.y1:1]]], list.two:2000]
XX
2000
2000
100
x1
x1
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script13238783009061342328505.groovy: 4:
[list.x1] is a constant expression, but it should be a variable expression at line: 4 column: 13. File: script13238783009061342328505.groovy @ line 4, column 13.
one"list.x1"="x1"
^
1 error
I am having the same issues.
These occur, if my key is a String, which contains dots. '.'
e.g.
ConfigObject myConfig = new ConfigSlurper().parse(configFile.toURI().toURL())
String key = 'com.groovy.mykey'
String value = 'myvalue'
//this fails
myConfig[key] = value
If I replace all dots (.) with underscores (_) , I am fine:
String goodKey = key.replaceAll(/\./, '_')
//works
myConfig[goodKey] = value
Thanks for the help,
Jan
(Tested in Groovy 2.0.0Beta2, Mac OS X 10.6.8, 64 bit
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)