groovyã®AntBuilderãJavaãã使ã£ã¦ã¿ã
groovyã®AntBuilderãJavaãã使ã£ããã©ããªãã試ãã¦ã¿ã¾ããã
groovyã®ãã®ã³ã¼ãã
def ant = new AntBuilder() ant.echo "hello" ant.copy( todir: "target" ){ fileset( dir: "src" ) { include( name: "**/*.java" ) } }
Javaã§æ¸ãç´ããããããªãã¾ããã
import groovy.lang.Closure; import groovy.util.AntBuilder; import java.util.HashMap; @SuppressWarnings("serial") public class AntBuilderSample { public static void main(String[] args) { final AntBuilder ant = new AntBuilder(); ant.invokeMethod("echo", "hello"); ant.invokeMethod("copy", new Object[] { new HashMap<String, String>() { { this.put("todir", "target"); } }, new Closure<Object>(null) { public Object call(Object... args) { ant.invokeMethod("fileset", new Object[] { new HashMap<String, String>() { { this.put("dir", "src"); } }, new Closure<Object>(null) { public Object call(Object... args) { ant.invokeMethod("include", new HashMap<String, String>() { { this.put("name", "**/*.java"); } }); return null; } } }); return null; } } }); } }
groovyãææ³ä¸ããã£ã¨ãåãå
¥ãã¦ããé¨åãç¡å¹åãã¦ããã®ã§ãããªãã¾ããã
ãããã«ããã§ã¯ä½¿ãã®ã¯ã¤ãããªã
ããã¦Mapãªãã©ã«ãããã°ãªã