Java Code Examples for org.apache.tools.ant.taskdefs.Ant#setDir()
The following examples show how to use
org.apache.tools.ant.taskdefs.Ant#setDir() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CleanAll.java From netbeans with Apache License 2.0 | 4 votes |
public void execute () throws BuildException { if (topdirs == null && topdir != null) { topdirs = new File[1]; topdirs[0] = topdir; } if (topdir == null && topdirs == null) { throw new BuildException("You must set at least one topdir attribute", getLocation()); } if (resolvedependencies) resolveDependencies(); for (int j = 0; j < topdirs.length; j++) { topdir = topdirs[j]; for (String module : modules) { Ant ant = (Ant) getProject().createTask("ant"); ant.init (); ant.setLocation(getLocation()); File fl = new File(topdir.getAbsolutePath () + File.separatorChar + module + File.separatorChar + "build.xml"); if (! fl.exists()) { continue; } ant.setDir(new File(topdir, module)); ant.setTarget (targetname); try { log("Process '"+ module + "' location with '" + targetname + "' target", Project.MSG_INFO); ant.execute (); } catch (BuildException be) { if (failonerror) { throw new BuildException(be.getMessage(), be, getLocation()); } else { log("Target \"" + targetname + "\" failed in module \"" + module + "\"", Project.MSG_WARN); log(fl.getAbsolutePath()); log(be.getMessage()); String fname = fl.getAbsolutePath(); failedmodules.add(fname); } } } } if (failedmodules.size() > 0) { log("<cleanall> SOME MODULES FAILED TO BUILD, BUT THEIR BuildException WAS CAUGHT", Project.MSG_WARN); log("<cleanall> cleanfailedmodules=\"" + failedmodules.toString() + "\"", Project.MSG_WARN); } }
Example 2
Source File: ParseProjectXml.java From netbeans with Apache License 2.0 | 4 votes |
private File computeClasspathModuleLocation(ModuleListParser modules, String cnb, Set<File> clusterPath, Set<String> excludedModules, boolean runtime) throws BuildException { ModuleListParser.Entry module = modules.findByCodeNameBase(cnb); if (module == null && cnb.contains("-")) { final String alternativeCnb = cnb.replace('-', '_'); module = modules.findByCodeNameBase(alternativeCnb); if (module != null) { cnb = alternativeCnb; } } if (module == null) { throw new BuildException("No dependent module " + cnb, getLocation()); } File jar = module.getJar(); if (jar == null) return null; OK: if (module.getClusterName() != null && clusterPath != null) { File clusterF = jar.getParentFile(); while (clusterF != null) { if (clusterPath.contains(clusterF)) { break OK; } clusterF = clusterF.getParentFile(); } String msg = "The module " + cnb + " cannot be " + (runtime ? "run" : "compiled") + " against because it is part of the cluster " + jar.getParentFile().getParentFile() + " which is not part of cluster.path in your suite configuration.\n\n" + "Cluster.path is: " + clusterPath; throw new BuildException(msg, getLocation()); } if (excludedModules != null && excludedModules.contains(cnb)) { // again #68716 throw new BuildException("Module " + cnb + " excluded from the target platform", getLocation()); } if (!jar.isFile()) { File srcdir = module.getSourceLocation(); if (Project.toBoolean(getProject().getProperty(DO_NOT_RECURSE))) { log(jar + " missing for " + moduleProject + " but will not first try to build " + srcdir, Project.MSG_VERBOSE); return jar; } if (srcdir != null && srcdir.isDirectory()) { log(jar + " missing for " + moduleProject + "; will first try to build " + srcdir, Project.MSG_WARN); Ant ant = new Ant(); ant.setProject(getProject()); ant.setOwningTarget(getOwningTarget()); ant.setLocation(getLocation()); ant.setInheritAll(false); ant.setDir(srcdir); ant.execute(); } } if (!jar.isFile()) { throw new BuildException("No such classpath entry: " + jar, getLocation()); } return jar; }