diff --git a/src/main/org/apache/tools/ant/Diagnostics.java b/src/main/org/apache/tools/ant/Diagnostics.java index 64a3bbb9c..9b950f38e 100644 --- a/src/main/org/apache/tools/ant/Diagnostics.java +++ b/src/main/org/apache/tools/ant/Diagnostics.java @@ -259,10 +259,23 @@ public final class Diagnostics { * @param out the stream to print the properties to. */ private static void doReportSystemProperties(PrintStream out) { - for (Enumeration keys = System.getProperties().propertyNames(); + Properties sysprops = null; + try { + sysprops = System.getProperties(); + } catch (SecurityException e) { + out.println("Access to System.getProperties() blocked " + + "by a security manager"); + } + for (Enumeration keys = sysprops.propertyNames(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); - out.println(key + " : " + System.getProperty(key)); + String value; + try { + value = System.getProperty(key); + } catch (SecurityException e) { + value = "Access to this property blocked by a security manager"; + } + out.println(key + " : " + value); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/DiagnosticsTask.java b/src/main/org/apache/tools/ant/taskdefs/DiagnosticsTask.java new file mode 100644 index 000000000..ac14690c2 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/DiagnosticsTask.java @@ -0,0 +1,37 @@ +package org.apache.tools.ant.taskdefs; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Diagnostics; + +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * This is a task that hands off work to the Diagnostics module. + * It lets you run diagnostics in an IDE. + */ +public class DiagnosticsTask extends Task { + + private static final String[] args=new String[0]; + + public void execute() throws BuildException { + Diagnostics.main(args); + } + + +} diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 91ba03c95..c0f9ee345 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -83,6 +83,7 @@ libraries=org.apache.tools.ant.taskdefs.repository.Libraries length=org.apache.tools.ant.taskdefs.Length clone=org.apache.tools.ant.taskdefs.Clone copypath=org.apache.tools.ant.taskdefs.CopyPath +diagnostics=org.apache.tools.ant.taskdefs.DiagnosticsTask # optional tasks image=org.apache.tools.ant.taskdefs.optional.image.Image