Steve, can you check that you are happy with this ?
Cheers,
Antoine
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 28, 2003 3:46 PM
Subject: cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs
JavaTest.java
> antoine 2003/08/28 06:46:33
>
> Modified: docs/manual/CoreTasks java.html
> src/etc/testcases/taskdefs java.xml
> src/main/org/apache/tools/ant/taskdefs Java.java
> src/testcases/org/apache/tools/ant/taskdefs JavaTest.java
> Log:
> Set default permissions appropriate to fail the builds when failonerror
is
> true (and fork false) and no other permissions were set.
> Suggestion of Steve Loughran.
>
> Revision Changes Path
> 1.22 +6 -1 ant/docs/manual/CoreTasks/java.html
>
> Index: java.html
> ===================================================================
> RCS file: /home/cvs/ant/docs/manual/CoreTasks/java.html,v
> retrieving revision 1.21
> retrieving revision 1.22
> diff -u -r1.21 -r1.22
> --- java.html 27 Aug 2003 14:23:16 -0000 1.21
> +++ java.html 28 Aug 2003 13:46:33 -0000 1.22
> @@ -88,7 +88,7 @@
> <tr>
> <td valign="top">failonerror</td>
> <td valign="top">Stop the buildprocess if the command exits with a
> - returncode other than 0. Default is "false"</td>
> + returncode other than 0. Default is "false"(see <a
href="#failonerror">note</a>)</td>
> <td align="center" valign="top">No</td>
> </tr>
> <tr>
> @@ -220,6 +220,11 @@
> <p>When the permission RuntimePermission exitVM has not been granted
(or has
> been revoked) the System.exit() call will be intercepted
> and treated like indicated in <i>failonerror</i>.</p>
> +<p><a name="failonerror"/>
> +If you specify <code>failonerror="true"</code> and you do not
specify permissions,
> +a set of default permissions will be added to your java invocation maki
ng sure that
> +a non zero return code will lead to a <code>BuildException</code>.
> +</p>
>
> <p>Settings will be ignored if fork is enabled.</p>
>
>
>
>
> 1.11 +16 -0 ant/src/etc/testcases/taskdefs/java.xml
>
> Index: java.xml
> ===================================================================
> RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/java.xml,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -r1.10 -r1.11
> --- java.xml 27 Aug 2003 19:12:42 -0000 1.10
> +++ java.xml 28 Aug 2003 13:46:33 -0000 1.11
> @@ -139,7 +139,23 @@
> <echo message="exitcode = ${exitcode}"/>
> </target>
>
> + <target name="testRunFailWithFailOnError">
> + <java classname="${app}"
> + classpath="${tests-classpath.value}"
> + failonerror="true"
> + >
> + <arg value="2"/>
> + </java>
> + </target>
>
> + <target name="testRunSuccessWithFailOnError">
> + <java classname="${app}"
> + classpath="${tests-classpath.value}"
> + failonerror="true"
> + >
> + <arg value="0"/>
> + </java>
> + </target>
>
> <target name="testSpawn">
> <java classname="${spawnapp}" fork="true" spawn="true"
classpath="${tests-classpath.value}">
>
>
>
> 1.71 +8 -1
ant/src/main/org/apache/tools/ant/taskdefs/Java.java
>
> Index: Java.java
> ===================================================================
> RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
> retrieving revision 1.70
> retrieving revision 1.71
> diff -u -r1.70 -r1.71
> --- Java.java 27 Aug 2003 14:23:16 -0000 1.70
> +++ Java.java 28 Aug 2003 13:46:33 -0000 1.71
> @@ -97,7 +97,7 @@
> private Long timeout = null;
> private Redirector redirector = new Redirector(this);
> private String resultProperty;
> - private Permissions perm;
> + private Permissions perm = null;
>
> private boolean spawn = false;
> private boolean incompatibleWithSpawn = false;
> @@ -108,6 +108,7 @@
> */
> public void execute() throws BuildException {
> File savedDir = dir;
> + Permissions savedPermissions = perm;
>
> int err = -1;
> try {
> @@ -122,6 +123,7 @@
> maybeSetResultPropertyValue(err);
> } finally {
> dir = savedDir;
> + perm = savedPermissions;
> }
> }
>
> @@ -179,6 +181,11 @@
> Project.MSG_WARN);
> }
>
> + if (perm == null && failOnError == true) {
> + perm = new Permissions();
> + log("running " + this.cmdl.getClassname()
> + + " with default permissions (exit forbidden)",
Project.MSG_VERBOSE);
> + }
> log("Running in same VM " + cmdl.describeJavaCommand(),
> Project.MSG_VERBOSE);
> }
>
>
>
> 1.15 +9 -0
ant/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java
>
> Index: JavaTest.java
> ===================================================================
> RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java,v
> retrieving revision 1.14
> retrieving revision 1.15
> diff -u -r1.14 -r1.15
> --- JavaTest.java 27 Aug 2003 14:23:17 -0000 1.14
> +++ JavaTest.java 28 Aug 2003 13:46:33 -0000 1.15
> @@ -196,6 +196,15 @@
> assertEquals("-1",project.getProperty("exitcode"));
> }
>
> + public void testRunFailWithFailOnError() {
> + expectBuildExceptionContaining("testRunFailWithFailOnError",
> + "non zero return code",
> + "Java returned:");
> + }
> +
> + public void testRunSuccessWithFailOnError() {
> + executeTarget("testRunSuccessWithFailOnError");
> + }
> public void testSpawn() {
> FileUtils fileutils = FileUtils.newFileUtils();
> File logFile = fileutils.createTempFile("spawn","log",
project.getBaseDir());
>
>
>
>
> ---------------------------------------------------------------------
> 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]