|
Hi all, Here are 2 small changes put in place for our specific needs
that may be beneficial to the whole group. 1) Multiple files: Added a project level variable called
nant.project.failure, such that a you can allow a task or group of tasks to
complete regardless of failure using failonerror=false, and then afterwards
check the value of nant.project.failure to determine if a failure occurred. Very
useful for batch nunit tests, and gathering a report of the tests before
checking if a failure occurred and throwing a fail. 2) Availabletask: modified to allow for wildcards, such that
it would be acceptable to determine if c:\temp\*.txt is available. Thanks, Jeff Hemry Index: src/NAnt.Core/Project.cs =================================================================== RCS file: /cvsroot/nant/nant/src/NAnt.Core/Project.cs,v retrieving revision 1.62 diff -u -r1.62 Project.cs --- src/NAnt.Core/Project.cs 19 Feb 2004 20:35:05
-0000 1.62 +++ src/NAnt.Core/Project.cs 26 Feb 2004 19:24:25 -0000 @@ -96,6 +96,7 @@ #region Internal Static Fields // named properties + internal const string NAntPropertyProjectFailure =
"nant.project.failure"; internal const string NAntPlatform =
"nant.platform"; internal const string NAntPlatformName =
NAntPlatform + ".name"; internal const string NAntPropertyFileName =
"nant.filename"; @@ -275,6 +276,14 @@ get { return _projectName; } } + /// <summary> + /// Gets or Sets whether there has been a failure
on the <see cref="Project" /> + /// </summary> + public bool Failure + { + get {return Boolean.Parse(
Properties[NAntPropertyProjectFailure] );} + set {Properties[NAntPropertyProjectFailure] =
value.ToString();} + } /// <summary> /// Gets or sets the base directory used for
relative references. /// </summary> @@ -1124,6 +1133,7 @@ // set here and in nant: Assembly ass = Assembly.GetExecutingAssembly(); + Properties.Add(NAntPropertyProjectFailure,
"false"); Properties.AddReadOnly(NAntPropertyFileName,
ass.CodeBase); Properties.AddReadOnly(NAntPropertyVersion,
ass.GetName().Version.ToString()); Properties.AddReadOnly(NAntPropertyLocation,
AppDomain.CurrentDomain.BaseDirectory); Index: src/NAnt.Core/Task.cs =================================================================== RCS file: /cvsroot/nant/nant/src/NAnt.Core/Task.cs,v retrieving revision 1.26 diff -u -r1.26 Task.cs --- src/NAnt.Core/Task.cs 19 Feb 2004 20:35:05
-0000 1.26 +++ src/NAnt.Core/Task.cs 26 Feb 2004 19:24:25 -0000 @@ -142,6 +142,7 @@ Project.OnTaskStarted(this, new
BuildEventArgs(this)); ExecuteTask(); } catch (Exception ex) { + Project.Failure = true; logger.Error(string.Format( CultureInfo.InvariantCulture, "{0} Generated
Exception", Index: src/NAnt.Core/Tasks/AttribTask.cs =================================================================== RCS file: /cvsroot/nant/nant/src/NAnt.Core/Tasks/AttribTask.cs,v retrieving revision 1.17 diff -u -r1.17 AttribTask.cs --- src/NAnt.Core/Tasks/AttribTask.cs 28 Dec 2003
15:44:39 -0000 1.17 +++ src/NAnt.Core/Tasks/AttribTask.cs 26 Feb 2004 19:24:25
-0000 @@ -196,6 +196,7 @@ throw new FileNotFoundException(); } } catch (Exception ex) { + Project.Failure
= true; string msg =
string.Format(CultureInfo.InvariantCulture, "Cannot set file attributes for
'{0}'.", path); if (FailOnError) { Index: src/NAnt.Core/Tasks/AvailableTask.cs =================================================================== RCS file:
/cvsroot/nant/nant/src/NAnt.Core/Tasks/AvailableTask.cs,v retrieving revision 1.19 diff -u -r1.19 AvailableTask.cs --- src/NAnt.Core/Tasks/AvailableTask.cs 4 Dec
2003 20:02:05 -0000 1.19 +++ src/NAnt.Core/Tasks/AvailableTask.cs 26 Feb 2004
19:24:26 -0000 @@ -215,8 +215,15 @@ /// </returns> private bool CheckFile() { try { - FileInfo fileInfo = new
FileInfo(Project.GetFullPath(Resource)); - return fileInfo.Exists; + if (
Resource.IndexOf("*") > -1 ) { + DirectoryScanner
scanner = new DirectoryScanner(); + scanner.Includes.Add(Resource); + scanner.Scan(); + return
( scanner.FileNames.Count > 0 ); + } else { + FileInfo
fileInfo = new FileInfo(Project.GetFullPath(Resource)); + return
fileInfo.Exists; + } } catch (ArgumentException ex) { throw new BuildException(string.Format( CultureInfo.InvariantCulture, Index: src/NAnt.Core/Tasks/DeleteTask.cs =================================================================== RCS file: /cvsroot/nant/nant/src/NAnt.Core/Tasks/DeleteTask.cs,v retrieving revision 1.23 diff -u -r1.23 DeleteTask.cs --- src/NAnt.Core/Tasks/DeleteTask.cs 28 Dec 2003
15:44:39 -0000 1.23 +++ src/NAnt.Core/Tasks/DeleteTask.cs 26 Feb 2004 19:24:26
-0000 @@ -204,6 +204,7 @@ Log(Level.Verbose, LogPrefix +
"Deleting file '{0}'.", file); System.IO.File.Delete(file); } catch (Exception ex) { + Project.Failure
= true; string msg =
string.Format(CultureInfo.InvariantCulture, "Cannot delete file
{0}.", file); if (FailOnError) { @@ -222,6 +223,7 @@ } catch (BuildException ex) { throw ex; } catch (Exception ex) { + Project.Failure
= true; string msg =
string.Format(CultureInfo.InvariantCulture, "Cannot delete directory
{0}.", path); if (FailOnError) { @@ -247,6 +249,7 @@ throw new FileNotFoundException(); } } catch (Exception ex) { + Project.Failure
= true; string msg =
string.Format(CultureInfo.InvariantCulture, "Cannot delete file '{0}'.",
path); if (FailOnError) { Index: src/NAnt.Core/Tasks/ExternalProgramBase.cs =================================================================== RCS file: /cvsroot/nant/nant/src/NAnt.Core/Tasks/ExternalProgramBase.cs,v retrieving revision 1.52 diff -u -r1.52 ExternalProgramBase.cs --- src/NAnt.Core/Tasks/ExternalProgramBase.cs 19
Feb 2004 20:39:00 -0000 1.52 +++ src/NAnt.Core/Tasks/ExternalProgramBase.cs 26
Feb 2004 19:24:26 -0000 @@ -244,6 +244,7 @@ Location); } } catch (BuildException e) { + Project.Failure = true; if (FailOnError) { throw; } else { Index: src/NAnt.Core/Tasks/TouchTask.cs =================================================================== RCS file:
/cvsroot/nant/nant/src/NAnt.Core/Tasks/TouchTask.cs,v retrieving revision 1.19 diff -u -r1.19 TouchTask.cs --- src/NAnt.Core/Tasks/TouchTask.cs 25 Feb 2004
21:57:02 -0000 1.19 +++ src/NAnt.Core/Tasks/TouchTask.cs 26 Feb 2004 19:24:26
-0000 @@ -173,6 +173,7 @@ } System.IO.File.SetLastWriteTime(path,
touchDateTime); } catch (Exception ex) { + Project.Failure = true; string msg =
string.Format(CultureInfo.InvariantCulture, "Cannot touch file '{0}'.",
path); |
- Re: [nant-dev] 2 small changes to consider Hemry, Jeff
- Re: [nant-dev] 2 small changes to consider Gert Driesen
- Re: [nant-dev] 2 small changes to consider Jaroslaw Kowalski
- RE: [nant-dev] 2 small changes to consider Nicklas Norling
- Re[2]: [nant-dev] 2 small changes to consider Ivan Tarasov
- Re: [nant-dev] 2 small changes to consider Martin Aliger
- RE: [nant-dev] 2 small changes to consider Randy Regnier
- RE: [nant-dev] 2 small changes to consider Clayton Harbour
