public static <T> T executeGroovyShellScript(final String script,
                                                 final Map<String, Object> variables,
                                                 final Class<T> clazz) {
        try {
            val binding = new Binding();
            val shell = new GroovyShell(binding);
            if (variables != null && !variables.isEmpty()) {
                variables.forEach(binding::setVariable);
            }
            if (!binding.hasVariable("logger")) {
                binding.setVariable("logger", LOGGER);
            }
            LOGGER.debug("Executing groovy script [{}] with variables [{}]", script, binding.getVariables());

            val result = shell.evaluate(script);
            return getGroovyScriptExecutionResultOrThrow(clazz, result);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
public static < T > T executeGroovyShellScript ( final String script , final Map < String , Object > variables , final Class < T > clazz ) { try { val binding = new Binding ( ) ; val shell = new GroovyShell ( binding ) ; if ( variables != null && ! variables . isEmpty ( ) ) { variables . forEach ( binding :: setVariable ) ; } if ( ! binding . hasVariable ( "logger" ) ) { binding . setVariable ( "logger" , LOGGER ) ; } LOGGER . debug ( "Executing groovy script [{}] with variables [{}]" , script , binding . getVariables ( ) ) ; val result = shell . evaluate ( script ) ; return getGroovyScriptExecutionResultOrThrow ( clazz , result ) ; } catch ( final Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } return null ; }
Execute groovy shell script t.

@param <T>       the type parameter
@param script    the script
@param variables the variables
@param clazz     the clazz
@return the t