Browse Source

Little something to make IDE debugging easier; <diagnostics/> prints the diagnostics out as per -diagnostics.

1. Why does Netbeans4.1 keep javax.xml.parsers.SAXParserFactory a secret? SecurityException handling to Diagnostics to compensate.
2. could add output file support, maybe?
3. could add task="junit" for detailed task diags instead...


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278422 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 20 years ago
parent
commit
bcb846c805
3 changed files with 53 additions and 2 deletions
  1. +15
    -2
      src/main/org/apache/tools/ant/Diagnostics.java
  2. +37
    -0
      src/main/org/apache/tools/ant/taskdefs/DiagnosticsTask.java
  3. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/defaults.properties

+ 15
- 2
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -259,10 +259,23 @@ public final class Diagnostics {
* @param out the stream to print the properties to. * @param out the stream to print the properties to.
*/ */
private static void doReportSystemProperties(PrintStream out) { 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();) { keys.hasMoreElements();) {
String key = (String) keys.nextElement(); 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);
} }
} }




+ 37
- 0
src/main/org/apache/tools/ant/taskdefs/DiagnosticsTask.java View File

@@ -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);
}


}

+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -83,6 +83,7 @@ libraries=org.apache.tools.ant.taskdefs.repository.Libraries
length=org.apache.tools.ant.taskdefs.Length length=org.apache.tools.ant.taskdefs.Length
clone=org.apache.tools.ant.taskdefs.Clone clone=org.apache.tools.ant.taskdefs.Clone
copypath=org.apache.tools.ant.taskdefs.CopyPath copypath=org.apache.tools.ant.taskdefs.CopyPath
diagnostics=org.apache.tools.ant.taskdefs.DiagnosticsTask


# optional tasks # optional tasks
image=org.apache.tools.ant.taskdefs.optional.image.Image image=org.apache.tools.ant.taskdefs.optional.image.Image


Loading…
Cancel
Save