2010-05-17 57 views
0

我想在bootstrap.groovy的不同區域使用一些代碼部分。我如何「包含」這些部分並重用它?如何在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

你剛纔導入的文件並調用函數或實例其中定義

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() 
     } 
    } 
} 
相關問題