Hi again,
Just a very simple enhancement to add wildcards to the antfile attribute in
the ant task to allow running multiple subtasks. There's also a new
'cascadeFailed' attribute to specify if a subproject's failure should be
propagated to the parent project (defaults to true).
Regards,
Matthieu
*** jakarta-ant-1.5Beta1/src/main/org/apache/tools/ant/taskdefs/Ant.java
Tue Apr 30 19:45:50 2002
--- ./main/org/apache/tools/ant/taskdefs/Ant.java Fri May 10 10:58:31 2002
***************
*** 61,66 ****
--- 61,67 ----
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectHelper;
+ import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.util.FileUtils;
import java.io.File;
import java.io.PrintStream;
***************
*** 117,122 ****
--- 118,126 ----
/** should we inherit references from the parent ? */
private boolean inheritRefs = false;
+ /** should we fail if a called task fails ? */
+ private boolean cascadeFailed = true;
+
/** the properties to pass to the new project */
private Vector properties = new Vector();
***************
*** 148,153 ****
--- 152,166 ----
}
/**
+ * If true and the child task fails, the ant task will fail.
+ * If false, this task always succeeds and warnings are logged
+ * for child task failures.
+ */
+ public void setCascadeFailed(boolean value) {
+ cascadeFailed = value;
+ }
+
+ /**
* Creates a Project instance for the project to call.
*/
public void init() {
***************
*** 305,319 ****
File savedDir = dir;
String savedAntFile = antFile;
String savedTarget = target;
try {
if (newProject == null) {
reinit();
}
! if ((dir == null) && (inheritAll)) {
! dir = project.getBaseDir();
}
initializeProject();
if (dir != null) {
--- 318,346 ----
File savedDir = dir;
String savedAntFile = antFile;
String savedTarget = target;
+
try {
+ if ((dir == null) && (inheritAll)) {
+ dir = project.getBaseDir();
+ }
+
if (newProject == null) {
reinit();
}
! if (antFile == null) {
! antFile = "build.xml";
}
+ DirectoryScanner scanner=new DirectoryScanner();
+ scanner.setBasedir(dir);
+ scanner.setIncludes(new String[] { antFile });
+ scanner.scan();
+ String antFiles[]=scanner.getIncludedFiles();
+
+ for(int i=0;i<antFiles.length;i++) {
+ reinit();
+
initializeProject();
if (dir != null) {
***************
*** 325,335 ****
overrideProperties();
! if (antFile == null) {
! antFile = "build.xml";
! }
!
! File file = FileUtils.newFileUtils().resolveFile(dir, antFile);
antFile = file.getAbsolutePath();
log("calling target " + (target != null ? target : "[default]")
--- 352,358 ----
overrideProperties();
! File file = FileUtils.newFileUtils().resolveFile(dir,
antFiles[i]);
antFile = file.getAbsolutePath();
log("calling target " + (target != null ? target :
"[default]")
***************
*** 354,360 ****
--- 377,391 ----
+ "target");
}
+ try {
newProject.executeTarget(target);
+ } catch (BuildException e) {
+ if (cascadeFailed) throw e;
+ log("Target " + (target != null ? target : "[default]")
+ + " in build file " + antFile.toString()
+ + " failed: "+
e.getLocalizedMessage(),Project.MSG_WARN);
+ }
+ }
} finally {
// help the gc
newProject = null;
*** jakarta-ant-1.5Beta1/docs/manual/CoreTasks/ant.html Tue Apr 30 19:46:50 2002
--- docs/manual/CoreTasks/ant.html Fri May 10 16:00:40 2002
***************
*** 85,90 ****
--- 85,96 ----
new Ant project. Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td>
</tr>
+ <tr>
+ <td valign="top">cascadeFailed</td>
+ <td valign="top">If <code>true</code> and the new Ant project
+ fails, make the current project fail. Defaults to
<code>true</code>.</td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
***************
*** 163,168 ****
--- 169,176 ----
<ant inheritAll="false"
antfile="subproject/subbuild.xml">
<property name="output.type" value="html"/>
</ant>
+
+ <ant antfile="subproject/build_*.xml"/>
</pre>
<p>The build file of the calling project defines some
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>