/** * 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; }
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(); }
Message.verbose("target build file already built, skipping: " + f); } else { Ant ant = new Ant(); Project project = (Project) IvyContext .peekInContextStack(IvyTask.ANT_PROJECT_CONTEXT_KEY); ant.setProject(project); ant.setTaskName("ant"); ant.setAntfile(f.getAbsolutePath()); ant.setInheritAll(false); String target = getTarget(); if (target != null) { ant.setTarget(target); String value = (String) atts.get(key); if (value != null) { Property p = ant.createProperty(); p.setName(prefix == null ? key : prefix + key); p.setValue(value); ant.execute(); } catch (BuildException e) { Message.verbose("Exception occurred while executing target " + target);
/** * Delegate the work to the ant task instance, after setting it up. * @throws BuildException on validation failure or if the target didn't * execute. */ public void execute() throws BuildException { if (callee == null) { init(); } if (!targetSet) { throw new BuildException( "Attribute target or at least one nested target is required.", getLocation()); } callee.setAntfile(getProject().getProperty("ant.file")); callee.setInheritAll(inheritAll); callee.setInheritRefs(inheritRefs); callee.execute(); }
Ant helper = new Ant(); helper.setTarget("someTarget"); helper.setAntFile("anotherBuildFile.xml"); helper.execute();
if (buildDir != null) antcall.setDir(buildDir); antcall.setAntfile(buildFile.getAbsolutePath()); antcall.setTarget(choosenTarget); antcalls.add(antcall);
ant.setAntfile(antfilename); targets.forEach(ant::addConfiguredTarget); log("Executing: " + antfilename, Project.MSG_INFO); ant.execute(); } catch (BuildException e) { if (failOnError || isHardError(e)) {
/** * 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; }
/** * Called in execute or createProperty (via getNewProject()) * if newProject is null. * * <p>This can happen if the same instance of this task is run * twice as newProject is set to null at the end of execute (to * save memory and help the GC).</p> * <p>calls init() again</p> * */ private void reinit() { init(); }
/** * Create a new Property to pass to the invoked target(s). * @return a <code>Property</code> object. */ public Property createParam() { if (callee == null) { init(); } return callee.createProperty(); }
public void init() { super.init(); savedNewProject = saveNewProject(); }
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(); }