/** * Set target to execute. * @param target the name of the target to execute. */ public void setTarget(String target) { if (callee == null) { init(); } callee.setTarget(target); targetSet = true; }
/** * Returns the resolved file * @param extension the extension * @param project the project * @return the file resolved * @throws BuildException if the file cannot be resolved */ @Override public File resolve(final Extension extension, final Project project) throws BuildException { validate(); final Ant ant = new Ant(); ant.setProject(project); ant.setInheritAll(false); ant.setAntfile(antfile.getName()); try { final File dir = antfile.getParentFile().getCanonicalFile(); ant.setDir(dir); } catch (final IOException ioe) { throw new BuildException(ioe.getMessage(), ioe); } if (null != target) { ant.setTarget(target); } ant.execute(); return destfile; }
/** * Creates the <ant> task configured to run a specific target. * * @param directory : if not null the directory where the build should run * * @return the ant task, configured with the explicit properties and * references necessary to run the sub-build. */ private Ant createAntTask(File directory) { Ant antTask = new Ant(this); antTask.init(); if (subTarget != null && !subTarget.isEmpty()) { antTask.setTarget(subTarget); } if (output != null) { antTask.setOutput(output); } if (directory != null) { antTask.setDir(directory); } else { antTask.setUseNativeBasedir(true); } antTask.setInheritAll(inheritAll); properties.forEach(p -> copyProperty(antTask.createProperty(), p)); propertySets.forEach(antTask::addPropertyset); antTask.setInheritRefs(inheritRefs); references.forEach(antTask::addReference); return antTask; }
Ant helper = new Ant(); helper.setTarget("someTarget"); helper.setAntFile("anotherBuildFile.xml"); helper.execute();
public void execute() { Ant ant = new Ant(); Project project = getProject(); project.setProperty("...", ...); ant.setProject(project); File directory = new File("..."); ant.setDir(directory); ant.setAntfile("build.xml"); ant.setTarget("all"); ant.execute(); }
public void execute() { Ant ant = new Ant(); Project project = new Project(); project.setProperty("...", ...); ant.setProject(project); File directory = new File("..."); ant.setDir(directory); ant.setAntfile("build.xml"); ant.setTarget("all"); ant.execute(); }
private void executeAntTask() { /* if (callee == null) { */ callee = (Ant) getProject().createTask("ant"); callee.setOwningTarget(getOwningTarget()); callee.setTaskName(getTaskName()); callee.init(); /* } */ callee.setAntfile(getProject().getProperty("ant.file")); callee.setTarget(subTarget); callee.setInheritAll(inheritAll); callee.setInheritRefs(inheritRefs); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String val = (String) properties.get(key); Property prop = callee.createProperty(); prop.setName(key); prop.setValue(val); } callee.execute(); System.gc(); System.gc(); System.gc(); }
String target = getTarget(); if (target != null) { ant.setTarget(target);
antcall.setTarget(choosenTarget); antcalls.add(antcall);