You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2006/09/21 21:11:20 UTC
svn commit: r448637 - in /ant/antlibs/dotnet/trunk: docs/ src/etc/testcases/
src/main/org/apache/ant/dotnet/build/
src/tests/junit/org/apache/ant/dotnet/build/
Author: bodewig
Date: Thu Sep 21 12:11:19 2006
New Revision: 448637
URL: http://svn.apache.org/viewvc?view=rev&rev=448637
Log:
failonerror and errorproperty attributes for <nant> and <msbuild>, PR 40553
Modified:
ant/antlibs/dotnet/trunk/docs/msbuild.html
ant/antlibs/dotnet/trunk/docs/nant.html
ant/antlibs/dotnet/trunk/src/etc/testcases/msbuild.xml
ant/antlibs/dotnet/trunk/src/etc/testcases/nant.xml
ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/build/AbstractBuildTask.java
ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/MSBuildTaskTest.java
ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/NAntTaskTest.java
Modified: ant/antlibs/dotnet/trunk/docs/msbuild.html
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/docs/msbuild.html?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/docs/msbuild.html (original)
+++ ant/antlibs/dotnet/trunk/docs/msbuild.html Thu Sep 21 12:11:19 2006
@@ -54,6 +54,19 @@
Specify the framework to use.</td>
<td align="center">No.</td>
</tr>
+ <tr>
+ <td valign="top">failOnError</td>
+ <td valign="top">Stops the build if MSBuild returns with a code
+ indicating an error.</td>
+ <td align="center">No - defaults to true.</td>
+ </tr>
+ <tr>
+ <td valign="top">errorProperty</td>
+ <td valign="top">Name of the Ant property to set if MSBuild
+ indicated an error. Only useful if the failOnError attribute
+ is set to false.</td>
+ <td align="center">No.</td>
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
Modified: ant/antlibs/dotnet/trunk/docs/nant.html
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/docs/nant.html?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/docs/nant.html (original)
+++ ant/antlibs/dotnet/trunk/docs/nant.html Thu Sep 21 12:11:19 2006
@@ -54,6 +54,19 @@
Specify the framework to use.</td>
<td align="center">No.</td>
</tr>
+ <tr>
+ <td valign="top">failOnError</td>
+ <td valign="top">Stops the build if NAnt returns with a code
+ indicating an error.</td>
+ <td align="center">No - defaults to true.</td>
+ </tr>
+ <tr>
+ <td valign="top">errorProperty</td>
+ <td valign="top">Name of the Ant property to set if NAnt
+ indicated an error. Only useful if the failOnError attribute
+ is set to false.</td>
+ <td align="center">No.</td>
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
Modified: ant/antlibs/dotnet/trunk/src/etc/testcases/msbuild.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/etc/testcases/msbuild.xml?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/src/etc/testcases/msbuild.xml (original)
+++ ant/antlibs/dotnet/trunk/src/etc/testcases/msbuild.xml Thu Sep 21 12:11:19 2006
@@ -49,10 +49,37 @@
<target name="nested-task">
<property name="foo" value="bar"/>
- <dn:msbuild>
+ <dn:msbuild errorProperty="msbuild.failed">
<dn:build>
<Message Text="foo is ${foo}"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
+ </dn:build>
+ </dn:msbuild>
+ </target>
+
+ <target name="fail">
+ <dn:msbuild>
+ <dn:build>
+ <Error Text="Failed"
+ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
+ </dn:build>
+ </dn:msbuild>
+ </target>
+
+ <target name="hidden-failure">
+ <dn:msbuild failOnError="false">
+ <dn:build>
+ <Error Text="Failed"
+ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
+ </dn:build>
+ </dn:msbuild>
+ </target>
+
+ <target name="hidden-failure-property">
+ <dn:msbuild failOnError="false" errorProperty="msbuild.failed">
+ <dn:build>
+ <Error Text="Failed"
+ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
</dn:build>
</dn:msbuild>
</target>
Modified: ant/antlibs/dotnet/trunk/src/etc/testcases/nant.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/etc/testcases/nant.xml?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/src/etc/testcases/nant.xml (original)
+++ ant/antlibs/dotnet/trunk/src/etc/testcases/nant.xml Thu Sep 21 12:11:19 2006
@@ -51,9 +51,33 @@
<target name="nested-task">
<property name="foo" value="bar"/>
- <dn:nant>
+ <dn:nant errorProperty="nant.failed">
<dn:build>
<echo message="foo is ${foo}"/>
+ </dn:build>
+ </dn:nant>
+ </target>
+
+ <target name="fail">
+ <dn:nant>
+ <dn:build>
+ <fail message="Failed"/>
+ </dn:build>
+ </dn:nant>
+ </target>
+
+ <target name="hidden-failure">
+ <dn:nant failOnError="false">
+ <dn:build>
+ <fail message="Failed"/>
+ </dn:build>
+ </dn:nant>
+ </target>
+
+ <target name="hidden-failure-property">
+ <dn:nant failOnError="false" errorProperty="nant.failed">
+ <dn:build>
+ <fail message="Failed"/>
</dn:build>
</dn:nant>
</target>
Modified: ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/build/AbstractBuildTask.java
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/build/AbstractBuildTask.java?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/build/AbstractBuildTask.java (original)
+++ ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/build/AbstractBuildTask.java Thu Sep 21 12:11:19 2006
@@ -65,6 +65,20 @@
private String vm;
/**
+ * Whether a failure should stop the build.
+ *
+ * @since 1.0 Beta 2
+ */
+ private boolean failOnError = true;
+
+ /**
+ * Name of property to set if a build fails.
+ *
+ * @since 1.0 Beta 2
+ */
+ private String errorProperty;
+
+ /**
* Empty constructor.
*/
protected AbstractBuildTask() {
@@ -155,6 +169,24 @@
}
/**
+ * Whether a failure should stop the build.
+ *
+ * @since 1.0 Beta 2
+ */
+ public void setFailOnError(boolean b) {
+ failOnError = b;
+ }
+
+ /**
+ * Name of property to set if a build fails.
+ *
+ * @since 1.0 Beta 2
+ */
+ public void setErrorProperty(String name) {
+ errorProperty = name;
+ }
+
+ /**
* Must return the executable.
*
* @return must not return null
@@ -230,6 +262,8 @@
for (int i = 0; i < args.length; i++) {
exec.createArg().setValue(args[i]);
}
+ exec.setFailonerror(failOnError);
+ exec.internalSetErrorProperty(errorProperty);
try {
exec.execute();
Modified: ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/MSBuildTaskTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/MSBuildTaskTest.java?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/MSBuildTaskTest.java (original)
+++ ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/MSBuildTaskTest.java Thu Sep 21 12:11:19 2006
@@ -60,6 +60,25 @@
public void testNestedTask() throws Exception {
if (getProject().getProperty("msbuild.found") != null) {
expectLogContaining("nested-task", "foo is bar");
+ assertNull(getProject().getProperty("msbuild.failed"));
+ }
+ }
+
+ public void testFail() throws Exception {
+ if (getProject().getProperty("msbuild.found") != null) {
+ expectBuildException("fail", "Msbuild should fail");
+ }
+ }
+
+ public void testHiddenFail() {
+ if (getProject().getProperty("msbuild.found") != null) {
+ executeTarget("hidden-failure");
+ }
+ }
+
+ public void testHiddenFailWithProperty() {
+ if (getProject().getProperty("msbuild.found") != null) {
+ expectPropertySet("hidden-failure-property", "msbuild.failed");
}
}
}
Modified: ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/NAntTaskTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/NAntTaskTest.java?view=diff&rev=448637&r1=448636&r2=448637
==============================================================================
--- ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/NAntTaskTest.java (original)
+++ ant/antlibs/dotnet/trunk/src/tests/junit/org/apache/ant/dotnet/build/NAntTaskTest.java Thu Sep 21 12:11:19 2006
@@ -60,6 +60,25 @@
public void testNestedTask() throws Exception {
if (getProject().getProperty("nant.found") != null) {
expectLogContaining("nested-task", "foo is bar");
+ assertNull(getProject().getProperty("nant.failed"));
+ }
+ }
+
+ public void testFail() throws Exception {
+ if (getProject().getProperty("nant.found") != null) {
+ expectBuildException("fail", "NAnt should fail");
+ }
+ }
+
+ public void testHiddenFail() {
+ if (getProject().getProperty("nant.found") != null) {
+ executeTarget("hidden-failure");
+ }
+ }
+
+ public void testHiddenFailWithProperty() {
+ if (getProject().getProperty("nant.found") != null) {
+ expectPropertySet("hidden-failure-property", "nant.failed");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org