You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 21:48:00 UTC

[jira] [Commented] (GROOVY-10470) Update from Groovy 3 to 4.0.0 breaks existing code

    [ https://issues.apache.org/jira/browse/GROOVY-10470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17486725#comment-17486725 ] 

Paul King commented on GROOVY-10470:
------------------------------------

This is expected behavior. It was alluded to in the Groovy 3 release notes (Under "{*}Module: groovy-ant{*}") which mentioned that you could leave out import to get the deprecated {{groovy.util}} version or add the import to get the {{groovy.ant}} version moving forward.:

[http://groovy-lang.org/releasenotes/groovy-3.0.html#Groovy3.0releasenotes-Splitpackages]

And again in the Groovy 4 release notes:

[https://groovy-lang.org/releasenotes/groovy-4.0.html#Groovy4.0-split-package-renaming]

 We did discuss adding things like "groovy.ant.AntBuilder" to the list of automatically imported classes but decided against that since folks can simply add the import or use Groovy's normal extension mechanism to add such an import themselves:
{code:groovy}
import org.codehaus.groovy.control.*
import org.codehaus.groovy.control.customizers.*
new GroovyShell(new CompilerConfiguration().tap {
    addCompilationCustomizers(new ImportCustomizer().addImports('groovy.ant.AntBuilder'))
}).evaluate '''
new AntBuilder()
'''
{code}


 

> Update from Groovy 3 to 4.0.0 breaks existing code
> --------------------------------------------------
>
>                 Key: GROOVY-10470
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10470
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 4.0.0
>            Reporter: Alexander Veit
>            Priority: Major
>
> After updating from Groovy 3 to 4.0.0 scripts that use {{AntBuilder}} without an {{import}} statement no longer work.
> This is probably caused by missing default includes for {{groovy.ant.*}} or {{groovy.ant.AntBuilder}}.
> The same problem exists for {{XmlSlurper}} and {{XmlParser}}.
> Example: The script below works with Groovy 3.0.9 but not with 4.0.0.
> {code:java}
> new AntBuilder()
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)