Groovy 2: Can't find JSonSlurper and XmlSlurper anymore

I upgraded to groovy 2 and now my build is broken.

Failed to import classes: groovy.json.JsonSlurper and XmlSlurper.

I checked http://groovy.codehaus.org/gapi/ and can no longer find these classes. Do they still exist in groovy 2? Or have they moved somewhere?

+6
source share
3 answers

groovy.jar , distributed with groovy 2, was divided into a minimum minimum, with all additional modules (XML, SQL, JSON, etc.) in separate banks. However, in the embeddable directory, you will find the groovy-all-2.0.0.jar jar file that contains groovy and all modules together, like previous versions. The easiest way to migrate is to use this jar file.

If you use Maven Central, you can use artifactId of groovy-all to get everything, or groovy (plus modules) to have finer control over your dependencies. Here is a list of modules available on Maven Central: http://search.maven.org/#search|ga|1|g%3A%22org.codehaus.groovy%22

+7
source

Nothing. You must enable groovy -xml and groovy -json jars. They were divided into groovy jar. See: http://www.infoq.com/articles/new-groovy-20

+5
source

When importing groovy -json-2.4.3 and groovy -xml-2.4.3, JsonSlurper is recognized.

Also refer to the new code refactor after version 1.8.0: Groovy JSON array analysis

0
source

Source: https://habr.com/ru/post/919241/


All Articles