本文整理了Java中groovy.util.AntBuilder
类的一些代码示例,展示了AntBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AntBuilder
类的具体详情如下:
包路径:groovy.util.AntBuilder
类名称:AntBuilder
[英]Allows Ant tasks to be used with a Groovy builder-style markup. Requires that {{ant.jar}} is on your classpath which will happen automatically if you are using the Groovy distribution but will be up to you to organize if you are embedding Groovy. If you wish to use the optional tasks you will need to add one or more additional jars from the ant distribution to your classpath - see the library dependencies for more details.
[中]允许Ant tasks与Groovy builder样式的标记一起使用。要求{ant.jar}}位于类路径上,如果您使用Groovy发行版,这将自动发生,但如果您嵌入Groovy,则由您来组织。如果您希望使用optional tasks,您将需要从ant发行版向类路径添加一个或多个附加JAR-有关详细信息,请参阅{$2$}。
代码示例来源:origin: stackoverflow.com
def ant = new AntBuilder() // create an antbuilder
ant.unzip( src:"your-src.zip",
dest:"your-dest-directory",
overwrite:"false" )
代码示例来源:origin: apache/groovy
protected Object createNode(final Object name, final Map attributes) {
final Attributes attrs = buildAttributes(attributes);
String tagName = name.toString();
String ns = "";
if (name instanceof QName) {
QName q = (QName) name;
tagName = q.getLocalPart();
ns = q.getNamespaceURI();
}
// import can be used only as top level element
if ("import".equals(name)) {
antXmlContext.setCurrentTarget(implicitTarget);
} else if ("target".equals(name) && !insideTask) {
return onStartTarget(attrs, tagName, ns);
} else if ("defineTarget".equals(name) && !insideTask) {
return onDefineTarget(attrs, "target", ns);
}
try {
antElementHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
}
catch (final SAXParseException e) {
log.log(Level.SEVERE, "Caught: " + e, e);
}
insideTask = true;
final RuntimeConfigurable wrapper = antXmlContext.getWrapperStack().lastElement();
return wrapper.getProxy();
}
代码示例来源:origin: apache/groovy
protected Object createNode(Object name, Map attributes, Object value) {
Object task = createNode(name, attributes);
setText(task, value.toString());
return task;
}
代码示例来源:origin: org.codehaus.gmaven/gmaven-mojo
/**
* Lazily initialize the AntBuilder, so we can pick up the log impl correctly.
*/
private AntBuilder getAnt() {
if (this.ant == null) {
AntBuilder ant = new AntBuilder();
BuildLogger logger = (BuildLogger) ant.getAntProject().getBuildListeners().get(0);
logger.setEmacsMode(true);
this.ant = ant;
}
return this.ant;
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public static void main(String[] args) {
final GroovyShell shell = new GroovyShell(new Binding());
final Groovy groovy = new Groovy();
for (int i = 1; i < args.length; i++) {
final Commandline.Argument argument = groovy.createArg();
argument.setValue(args[i]);
}
final AntBuilder builder = new AntBuilder();
groovy.setProject(builder.getProject());
groovy.parseAndRunScript(shell, null, null, null, new File(args[0]), builder);
}
代码示例来源:origin: stackoverflow.com
final AntBuilder ant = new AntBuilder();
ant.invokeMethod("echo", "copy & sync gestartet...");
ant.invokeMethod("sync", new Object[] { new HashMap<String, String>() {
{
this.put("todir", "./myordner2");
this.put("verbose", "yes");
}
}, new Closure<Object>(null) {
@Override
public Object call(Object... args) {
ant.invokeMethod("fileset", new Object[] {
new HashMap<String, String>() {
{
this.put("dir", "c:/myordner1/test");
}
}});
return null;
}
} });
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
protected Object createNode(final Object name, final Map attributes) {
final Attributes attrs = buildAttributes(attributes);
String tagName = name.toString();
String ns = "";
if (name instanceof QName) {
QName q = (QName) name;
tagName = q.getLocalPart();
ns = q.getNamespaceURI();
}
// import can be used only as top level element
if ("import".equals(name)) {
antXmlContext.setCurrentTarget(implicitTarget);
} else if ("target".equals(name) && !insideTask) {
return onStartTarget(attrs, tagName, ns);
}
try {
antElementHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
}
catch (final SAXParseException e) {
log.log(Level.SEVERE, "Caught: " + e, e);
}
insideTask = true;
final RuntimeConfigurable wrapper = (RuntimeConfigurable) antXmlContext.getWrapperStack().lastElement();
return wrapper.getProxy();
}
代码示例来源:origin: apache/groovy
private Target onStartTarget(final Attributes attrs, String tagName, String ns) {
final Target target = new Target();
target.setProject(project);
target.setLocation(new Location(antXmlContext.getLocator()));
try {
antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
// execute dependencies (if any)
final Vector<Target> targets = new Vector<Target>();
for (final Enumeration<String> deps = newTarget.getDependencies(); deps.hasMoreElements();) {
final String targetName = deps.nextElement();
targets.add(project.getTargets().get(targetName));
}
getProject().executeSortedTargets(targets);
antXmlContext.setCurrentTarget(newTarget);
return newTarget;
}
catch (final SAXParseException e) {
log.log(Level.SEVERE, "Caught: " + e, e);
}
return null;
}
代码示例来源:origin: apache/groovy
protected Object createNode(Object tagName) {
return createNode(tagName, Collections.EMPTY_MAP);
}
代码示例来源:origin: apache/groovy
public AntBuilder() {
this(createProject());
}
代码示例来源:origin: org.codehaus.gant/gant_groovy2.0
return super.invokeMethod(name, arguments);
代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-2.0
private AntBuilder createAntBuilder() {
AntBuilder ant = new AntBuilder();
Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
if (obj instanceof BuildLogger) {
BuildLogger logger = (BuildLogger)obj;
logger.setEmacsMode(true);
}
return ant;
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
public static void main(String[] args) {
final GroovyShell shell = new GroovyShell(new Binding());
final Groovy groovy = new Groovy();
for (int i = 1; i < args.length; i++) {
final Commandline.Argument argument = groovy.createArg();
argument.setValue(args[i]);
}
final AntBuilder builder = new AntBuilder();
groovy.setProject(builder.getProject());
groovy.parseAndRunScript(shell, null, null, null, new File(args[0]), builder);
}
代码示例来源:origin: snowindy/scriptlet4docx
public void prepare(File pathToDocx, String templateKey) throws IOException {
File dir = getTemplateUnzipFolder(templateKey);
if (pathToDocx.exists() && pathToDocx.isFile()) {
AntBuilder antBuilder = new AntBuilder();
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("src", pathToDocx);
params.put("dest", dir);
params.put("overwrite", "true");
antBuilder.invokeMethod("unzip", params);
} else {
throw new FileNotFoundException(String.format("Cannot find docx template: '%s'",
pathToDocx.getAbsolutePath()));
}
}
代码示例来源:origin: org.kohsuke.droovy/groovy
protected Object createNode(final Object name, final Map attributes) {
final Attributes attrs = buildAttributes(attributes);
String tagName = name.toString();
String ns = "";
if (name instanceof QName) {
QName q = (QName)name;
tagName = q.getLocalPart();
ns = q.getNamespaceURI();
}
// import can be used only as top level element
if ("import".equals(name)) {
antXmlContext.setCurrentTarget(implicitTarget);
}
else if ("target".equals(name)) {
return onStartTarget(attrs, tagName, ns);
}
try
{
antElementHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
}
catch (final SAXParseException e)
{
log.log(Level.SEVERE, "Caught: " + e, e);
}
final RuntimeConfigurable wrapper = (RuntimeConfigurable) antXmlContext.getWrapperStack().lastElement();
return wrapper.getProxy();
}
代码示例来源:origin: apache/groovy
private Target onDefineTarget(final Attributes attrs, String tagName, String ns) {
final Target target = new Target();
target.setProject(project);
target.setLocation(new Location(antXmlContext.getLocator()));
try {
antTargetHandler.onStartElement(ns, tagName, tagName, attrs, antXmlContext);
final Target newTarget = getProject().getTargets().get(attrs.getValue("name"));
antXmlContext.setCurrentTarget(newTarget);
definingTarget = newTarget;
return newTarget;
}
catch (final SAXParseException e) {
log.log(Level.SEVERE, "Caught: " + e, e);
}
return null;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
protected Object createNode(Object tagName) {
return createNode(tagName, Collections.EMPTY_MAP);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public AntBuilder() {
this(createProject());
}
代码示例来源:origin: org.codehaus.gant/gant_groovy1.8
return super.invokeMethod(name, arguments);
代码示例来源:origin: org.codehaus.mojo.groovy.runtime/groovy-runtime-1.1
private AntBuilder createAntBuilder() {
AntBuilder ant = new AntBuilder();
Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
if (obj instanceof BuildLogger) {
BuildLogger logger = (BuildLogger)obj;
logger.setEmacsMode(true);
}
return ant;
}
内容来源于网络,如有侵权,请联系作者删除!