groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohan Radhakrishnan <>
Subject Executing dynamic DSL command
Date Tue, 16 Jan 2018 13:36:32 GMT

      I am reading the book 'Groovy in Action' and this code is based on

My base script stores 'DynamicXPath' like this.

abstract class AxesBaseScript extends Script {

    public DynamicXPath bootStrap(String initialPath ){
        this.binding.dxp.bootStrap initialPath

And here I want to execute a dynamic DSL command 'dsl '

by storing it in the binding as 'DslCommand'.

    def evaluatexpath( String dsl ){
        def binding = new Binding(
                dsp: new DynamicXPath(),
                DslCommand: dsl

        def shell = new GroovyShell(this.class.classLoader, binding)

        shell.evaluate '''
            import groovy.transform.BaseScript

Looks like the DSL string I pass 'bootStrap somestring' is returned as it
is as a string by evaluate.

Can I not execute 'bootStrap somestring' ?

The relevant section in the book is '*Listing 19.12 Using a custom base
script class'*

*My '*DslCommand' replaces 'move left' which you see at the end of the
I just want to pass my DSL commands to the evaluate method as parameters
through the binding.


View raw message