Hi Alexey, it is possible that ant 1.6 will contain a try-catch feature. this might make your idea redundant - correct me if I am wrong ? Antoine ----- Original Message ----- From: "Alexey Solofnenko" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 26, 2003 10:10 PM Subject: [Proposal] adding "keep-going" to ANT.
> Hello, > > "keep-going" feature can be very useful, especially in automatic testing. > I have experimented with Project.executeTarget() method to implement this > functionality. It seems like a simple patch. The goal of the modification is > to execute all targets that do not depend on failed targets. If you think > the approach is correct, I can submit a diff patch. > > ============================== > This is the build file I executed (target "b" should be executed even if > target "a" failed, "main" should not be executed): > ============================== > > <?xml version="1.0"?> > <project default="main" basedir="."> > <target name="a"> > <echo message="A"/> > <fail message="something is wrong"/> > </target> > <target name="b"> > <echo message="B"/> > </target> > <target name="main" depends="a,b"> > <echo message="main"/> > </target> > </project> > > > ============================== > Build output: > ============================== > > Buildfile: build.xml > > a: > [echo] A > Target 'a' failed. > > b: > [echo] B > Cannot execute 'main' - 'a' was not executed. > > BUILD FAILED > D:\tools\apache-ant-1.6alpha\dist\build.xml:5: something is wrong > > Total time: 0 seconds > > ============================== > Modified Project.executeTarget() method: > ============================== > public void executeTarget(String targetName) throws BuildException { > > // sanity check ourselves, if we've been asked to build nothing > // then we should complain > > if (targetName == null) { > String msg = "No target specified"; > throw new BuildException(msg); > } > > // Sort the dependency tree, and run everything from the > // beginning until we hit our targetName. > // Sorting checks if all the targets (and dependencies) > // exist, and if there is any cycle in the dependency > // graph. > Vector sortedTargets = topoSort(targetName, targets); > Set executed=new HashSet(); > BuildException buildException=null; > > for (Enumeration iter=sortedTargets.elements(); > iter.hasMoreElements();) { > Target curtarget = (Target) iter.nextElement(); > boolean canExecute=true; > for (Enumeration dep_iter=curtarget.getDependencies(); > dep_iter.hasMoreElements();) { > String dependencyName=((String)dep_iter.nextElement()); > if (!executed.contains(dependencyName)) { > canExecute=false; > log(curtarget, "Cannot execute '"+curtarget.getName()+"' - > '"+dependencyName+"' was not executed.", MSG_ERR); > } > } > if (canExecute) { > try { > curtarget.performTasks(); > executed.add(curtarget.getName()); > } > catch (BuildException ex) { > log(curtarget, "Target '"+curtarget.getName()+"' failed.", > MSG_ERR); > if (buildException==null) { > buildException=ex; > } > else { > log(curtarget, "Extra error: "+ex.getMessage(), MSG_ERR); > } > } > } > if (curtarget.getName().equals(targetName)) // very strange exit > condition > break; > } > if (buildException!=null) > throw buildException; > } > > - Alexey. > > -- > { http://trelony.cjb.net/ } Alexey N. Solofnenko > Pleasant Hill, CA (GMT-8 usually) > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]