Bug 90597 - Ant script exits when not expected
diff --git a/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InternalAntRunner.java b/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InternalAntRunner.java index c537c6f..80cd4fc 100644 --- a/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InternalAntRunner.java +++ b/ant/org.eclipse.ant.ui/Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InternalAntRunner.java
@@ -29,7 +29,6 @@ import java.util.Map; import java.util.Properties; import java.util.Vector; - import org.apache.tools.ant.AntTypeDefinition; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildException; @@ -317,6 +316,7 @@ PrintStream originalOut = System.out; InputStream originalIn= System.in; + SecurityManager originalSM= System.getSecurityManager(); scriptExecuted= true; try { if (argList != null && (argList.remove("-projecthelp") || argList.remove("-p"))) { //$NON-NLS-1$ //$NON-NLS-2$ @@ -404,6 +404,8 @@ printArguments(getCurrentProject()); } + System.setSecurityManager(new AntSecurityManager(originalSM, Thread.currentThread())); + if (targets == null) { targets= new Vector(1); } @@ -412,12 +414,17 @@ } getCurrentProject().addReference("eclipse.ant.targetVector", targets); //$NON-NLS-1$ getCurrentProject().executeTargets(targets); - } catch (Throwable e) { + } catch (AntSecurityException e) { + //expected + } catch (Throwable e) { error = e; } finally { System.setErr(originalErr); System.setOut(originalOut); System.setIn(originalIn); + if (System.getSecurityManager() instanceof AntSecurityManager) { + System.setSecurityManager(originalSM); + } if (!projectHelp) { fireBuildFinished(getCurrentProject(), error);