Convert String variable to a List [Groovy]
def l = Eval.me(ids) Takes the string of groovy code (in this case “[10,1,9]”) and evaluates it as groovy. This will give you a list of 3 ints.
def l = Eval.me(ids) Takes the string of groovy code (in this case “[10,1,9]”) and evaluates it as groovy. This will give you a list of 3 ints.
I’d just use the arithmetic operators, I think it’s much more obvious what’s going on: def a = [“foo”, “bar”, “baz”, “baz”] def b = [“foo”, “qux”] assert [“bar”, “baz”, “baz”, “qux”] == ((a – b) + (b – a))
Wow, another gotcha with putting Windows files paths in slashy strings. Nice catch. The gotcha I’ve encountered before was including a trailing backslash on the path, e.g. /C:\path\/, which results in an unexpected char: 0xFFFF error. Anyways, for the sake of an answer, given that Windows paths are case insensitive, why not exploit it for … Read more
You need to configure the JavaCompile tasks, so that Gradle passes this option to the Java compiler when compiling. Something like this should work: tasks.withType(JavaCompile).each { it.options.compilerArgs.add(‘–enable-preview’) } To run the app/tests we need to add jvmArgs. Example: test { jvmArgs([‘–enable-preview’]) }
Spock is all about expressiveness and clarity. Static is a Java keyword that only shows the internals of the class (that this field is the same for all instances) @Shared is a Spock feature that says to the reader that this variable is the same for all feature methods. It is an instruction specifically for … Read more
This is a known bug in the JRE that reports this as an warning. See bug reports here and here The issue happens only when you have xerces jar in your classpath, the xerces implementation does not recognize the property and throws an exception on org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.setProperty() which results in a warning log (to System.err) from … Read more
Solution: org.codehaus.groovy.runtime.StackTraceUtils.sanitize(new Exception()).printStackTrace() Original answer: A Google search returns the following information: Apparently, there is a method in org.codehaus.groovy.runtime.StackTraceUtils called printSanitizedStackTrace. There isn’t much documentation for the method, though there is a method called sanitize which is described as remove all apparently groovy-internal trace entries from the exception instance This modifies the original instance and … Read more