Skip to content

MagicLu550/GroovyDSLConfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GroovyDSLConfig

可以简化自定义DSL文件的解析

具体使用方法参见Example类

如代码案例所示,hello和items为父标签,一般如hello,items所示

package net.noyark.www.dsl.utils


class Example extends DSLParser {

    Example() {
        super(new File("test.groovy"),"UTF-8")
    }

    @Override
    void byProperty(String name, Object args,String stack) {
        println name+" : "+args
        println(stack)
    }

    @DSLMethod
    void hello(Closure closure){
        closure()
    }
    @DSLMethod
    void items(Closure closure){
        closure()
    }

    static void main(String[] args) {
        Example example = new Example()
    }
}

byProperty可以获取值标签,如url就是一个值标签,在Example中没有指定,会在byProperty中获取

items{
    hello{
      url "helloworld" 
    }
}

如上面代码执行为

url : [0]
items.hello

同样的,您可以在dsl上写groovy代码

items{
    hello{
      url "helloworld" 
      print "abc"
    }
}

About

DSLConfig - 可以简化自定义DSL文件的解析

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages