我想在bootstrap.groovy的不同区域使用代码的某些部分。如何“包含”这些部件并重复使用?
def init = {
environments {
production {
include("bla.groovy)
include("blaFoo.groovy)
}
test {
include("blaFoo.groovy)
}
development {
include("bla.groovy)
include("bla1.groovy)
include("blaFoo.groovy)
}
}
}
答案 0 :(得分:0)
您只需导入文件并调用函数或实例化其中定义的类
import bla
import blaFoo
import bla1
def init = {
environments {
production {
// This function is defined in bla.groovy
blaFunc()
} test {
// This class is defined in blaFoo.groovy
new BlaFoo()
} development {
// This closure is defined in bla1.groovy
bla1.call()
}
}
}