/** * 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; }
/** * 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(); }
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(); }
ant.setInheritAll(false); String target = getTarget(); if (target != null) {