git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274444 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -77,6 +77,9 @@ import java.lang.reflect.InvocationTargetException; | |||||
| */ | */ | ||||
| public final class Diagnostics { | public final class Diagnostics { | ||||
| private static final String TEST_CLASS | |||||
| = "org.apache.tools.ant.taskdefs.optional.Test"; | |||||
| /** utility class */ | /** utility class */ | ||||
| private Diagnostics(){ | private Diagnostics(){ | ||||
| } | } | ||||
| @@ -88,7 +91,7 @@ public final class Diagnostics { | |||||
| */ | */ | ||||
| public static boolean isOptionalAvailable() { | public static boolean isOptionalAvailable() { | ||||
| try { | try { | ||||
| Class.forName("org.apache.tools.ant.taskdefs.optional.Test"); | |||||
| Class.forName(TEST_CLASS); | |||||
| } catch (ClassNotFoundException e){ | } catch (ClassNotFoundException e){ | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -102,13 +105,15 @@ public final class Diagnostics { | |||||
| */ | */ | ||||
| public static void validateVersion() throws BuildException { | public static void validateVersion() throws BuildException { | ||||
| try { | try { | ||||
| Class optional = Class.forName("org.apache.tools.ant.taskdefs.optional.Test"); | |||||
| Class optional | |||||
| = Class.forName("org.apache.tools.ant.taskdefs.optional.Test"); | |||||
| String coreVersion = getImplementationVersion(Main.class); | String coreVersion = getImplementationVersion(Main.class); | ||||
| String optionalVersion = getImplementationVersion(optional); | String optionalVersion = getImplementationVersion(optional); | ||||
| if (coreVersion != null && !coreVersion.equals(optionalVersion) ){ | |||||
| if (coreVersion != null && !coreVersion.equals(optionalVersion)) { | |||||
| throw new BuildException( | throw new BuildException( | ||||
| "Invalid implementation version between Ant core and Ant optional tasks.\n" + | |||||
| "Invalid implementation version between Ant core and " | |||||
| + "Ant optional tasks.\n" + | |||||
| " core : " + coreVersion + "\n" + | " core : " + coreVersion + "\n" + | ||||
| " optional: " + optionalVersion); | " optional: " + optionalVersion); | ||||
| } | } | ||||
| @@ -169,7 +174,7 @@ public final class Diagnostics { | |||||
| // pkg.getImplementationVersion(); | // pkg.getImplementationVersion(); | ||||
| method = pkg.getClass().getMethod("getImplementationVersion", new Class[0]); | method = pkg.getClass().getMethod("getImplementationVersion", new Class[0]); | ||||
| Object version = method.invoke(pkg, null); | Object version = method.invoke(pkg, null); | ||||
| return (String)version; | |||||
| return (String) version; | |||||
| } | } | ||||
| } catch (Exception e){ | } catch (Exception e){ | ||||
| // JDK < 1.2 should land here because the methods above don't exist. | // JDK < 1.2 should land here because the methods above don't exist. | ||||
| @@ -183,7 +188,7 @@ public final class Diagnostics { | |||||
| * @return the classname of the parser | * @return the classname of the parser | ||||
| */ | */ | ||||
| private static String getXmlParserName() { | private static String getXmlParserName() { | ||||
| SAXParser saxParser= getSAXParser(); | |||||
| SAXParser saxParser = getSAXParser(); | |||||
| if (saxParser == null) { | if (saxParser == null) { | ||||
| return "Could not create an XML Parser"; | return "Could not create an XML Parser"; | ||||
| } | } | ||||
| @@ -202,7 +207,7 @@ public final class Diagnostics { | |||||
| if (saxParserFactory == null) { | if (saxParserFactory == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| SAXParser saxParser=null; | |||||
| SAXParser saxParser = null; | |||||
| try { | try { | ||||
| saxParser = saxParserFactory.newSAXParser(); | saxParser = saxParserFactory.newSAXParser(); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -220,7 +225,7 @@ public final class Diagnostics { | |||||
| if (saxParser == null) { | if (saxParser == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| String location=getClassLocation(saxParser.getClass()); | |||||
| String location = getClassLocation(saxParser.getClass()); | |||||
| return location; | return location; | ||||
| } | } | ||||
| @@ -230,7 +235,7 @@ public final class Diagnostics { | |||||
| * @return the jar file or path where a class was found, or null | * @return the jar file or path where a class was found, or null | ||||
| */ | */ | ||||
| private static String getClassLocation( Class clazz) { | |||||
| private static String getClassLocation(Class clazz) { | |||||
| File f = LoaderUtils.getClassSource(clazz); | File f = LoaderUtils.getClassSource(clazz); | ||||
| return f == null ? null : f.getAbsolutePath(); | return f == null ? null : f.getAbsolutePath(); | ||||
| } | } | ||||
| @@ -253,7 +258,8 @@ public final class Diagnostics { | |||||
| try { | try { | ||||
| optional = Class.forName( | optional = Class.forName( | ||||
| "org.apache.tools.ant.taskdefs.optional.Test"); | "org.apache.tools.ant.taskdefs.optional.Test"); | ||||
| out.println("optional tasks : " + getImplementationVersion(optional)); | |||||
| out.println("optional tasks : " | |||||
| + getImplementationVersion(optional)); | |||||
| } catch (ClassNotFoundException e){ | } catch (ClassNotFoundException e){ | ||||
| out.println("optional tasks : not available"); | out.println("optional tasks : not available"); | ||||
| } | } | ||||
| @@ -297,9 +303,9 @@ 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().keys(); | |||||
| keys.hasMoreElements(); ){ | |||||
| String key = (String)keys.nextElement(); | |||||
| for (Enumeration keys = System.getProperties().keys(); | |||||
| keys.hasMoreElements();) { | |||||
| String key = (String) keys.nextElement(); | |||||
| out.println(key + " : " + System.getProperty(key)); | out.println(key + " : " + System.getProperty(key)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -331,7 +337,8 @@ public final class Diagnostics { | |||||
| Throwable error = null; | Throwable error = null; | ||||
| try { | try { | ||||
| Class which = Class.forName("org.apache.env.Which"); | Class which = Class.forName("org.apache.env.Which"); | ||||
| Method method = which.getMethod("main", new Class[]{ String[].class }); | |||||
| Method method | |||||
| = which.getMethod("main", new Class[]{ String[].class }); | |||||
| method.invoke(null, new Object[]{new String[]{}}); | method.invoke(null, new Object[]{new String[]{}}); | ||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| out.println("Not available."); | out.println("Not available."); | ||||
| @@ -366,7 +373,7 @@ public final class Diagnostics { | |||||
| try { | try { | ||||
| props.load(is); | props.load(is); | ||||
| for (Enumeration keys = props.keys(); keys.hasMoreElements();){ | for (Enumeration keys = props.keys(); keys.hasMoreElements();){ | ||||
| String key = (String)keys.nextElement(); | |||||
| String key = (String) keys.nextElement(); | |||||
| String classname = props.getProperty(key); | String classname = props.getProperty(key); | ||||
| try { | try { | ||||
| Class.forName(classname); | Class.forName(classname); | ||||
| @@ -375,7 +382,7 @@ public final class Diagnostics { | |||||
| out.println(key + " : Not Available"); | out.println(key + " : Not Available"); | ||||
| } catch (NoClassDefFoundError e) { | } catch (NoClassDefFoundError e) { | ||||
| String pkg = e.getMessage().replace('/', '.'); | String pkg = e.getMessage().replace('/', '.'); | ||||
| out.println(key + " : Missing dependency " + pkg ); | |||||
| out.println(key + " : Missing dependency " + pkg); | |||||
| } catch (Error e) { | } catch (Error e) { | ||||
| out.println(key + " : Initialization error"); | out.println(key + " : Initialization error"); | ||||
| } | } | ||||
| @@ -394,13 +401,13 @@ public final class Diagnostics { | |||||
| * @param out | * @param out | ||||
| */ | */ | ||||
| private static void doReportParserInfo(PrintStream out) { | private static void doReportParserInfo(PrintStream out) { | ||||
| String parserName=getXmlParserName(); | |||||
| String parserLocation=getXMLParserLocation(); | |||||
| if(parserName==null) { | |||||
| parserName="unknown"; | |||||
| String parserName = getXmlParserName(); | |||||
| String parserLocation = getXMLParserLocation(); | |||||
| if (parserName == null) { | |||||
| parserName = "unknown"; | |||||
| } | } | ||||
| if(parserLocation==null) { | |||||
| parserLocation="unknown"; | |||||
| if (parserLocation == null) { | |||||
| parserLocation = "unknown"; | |||||
| } | } | ||||
| out.println("XML Parser : " + parserName); | out.println("XML Parser : " + parserName); | ||||
| out.println("XML Parser Location: " + parserLocation); | out.println("XML Parser Location: " + parserLocation); | ||||
| @@ -152,7 +152,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a> | * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a> | ||||
| * @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a> | * @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a> | ||||
| */ | */ | ||||
| public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceFactory { | |||||
| public class DirectoryScanner | |||||
| implements FileScanner, SelectorScanner, ResourceFactory { | |||||
| /** | /** | ||||
| * Patterns which should be excluded by default. | * Patterns which should be excluded by default. | ||||
| @@ -558,7 +559,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||||
| if (isIncluded("")) { | if (isIncluded("")) { | ||||
| if (!isExcluded("")) { | if (!isExcluded("")) { | ||||
| if (isSelected("",basedir)) { | |||||
| if (isSelected("", basedir)) { | |||||
| dirsIncluded.addElement(""); | dirsIncluded.addElement(""); | ||||
| } else { | } else { | ||||
| dirsDeselected.addElement(""); | dirsDeselected.addElement(""); | ||||
| @@ -676,7 +677,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||||
| if (file.isDirectory()) { | if (file.isDirectory()) { | ||||
| if (isIncluded(name)) { | if (isIncluded(name)) { | ||||
| if (!isExcluded(name)) { | if (!isExcluded(name)) { | ||||
| if (isSelected(name,file)) { | |||||
| if (isSelected(name, file)) { | |||||
| dirsIncluded.addElement(name); | dirsIncluded.addElement(name); | ||||
| if (fast) { | if (fast) { | ||||
| scandir(file, name + File.separator, fast); | scandir(file, name + File.separator, fast); | ||||
| @@ -709,7 +710,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||||
| } else if (file.isFile()) { | } else if (file.isFile()) { | ||||
| if (isIncluded(name)) { | if (isIncluded(name)) { | ||||
| if (!isExcluded(name)) { | if (!isExcluded(name)) { | ||||
| if (isSelected(name,file)) { | |||||
| if (isSelected(name, file)) { | |||||
| filesIncluded.addElement(name); | filesIncluded.addElement(name); | ||||
| } else { | } else { | ||||
| everythingIncluded = false; | everythingIncluded = false; | ||||
| @@ -949,8 +950,10 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||||
| } | } | ||||
| /** | /** | ||||
| * Get the named resource | |||||
| * @param name path name of the file relative to the dir attribute. | * @param name path name of the file relative to the dir attribute. | ||||
| * | * | ||||
| * @return the resource with the given name. | |||||
| * @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
| */ | */ | ||||
| public Resource getResource(String name) { | public Resource getResource(String name) { | ||||
| @@ -257,7 +257,8 @@ public class IntrospectionHelper implements BuildListener { | |||||
| particular order. | particular order. | ||||
| */ | */ | ||||
| } | } | ||||
| AttributeSetter as = createAttributeSetter(m, args[0], propName); | |||||
| AttributeSetter as | |||||
| = createAttributeSetter(m, args[0], propName); | |||||
| if (as != null) { | if (as != null) { | ||||
| attributeTypes.put(propName, args[0]); | attributeTypes.put(propName, args[0]); | ||||
| attributeSetters.put(propName, as); | attributeSetters.put(propName, as); | ||||
| @@ -62,6 +62,8 @@ import org.xml.sax.Locator; | |||||
| * Stores the location of a piece of text within a file (file name, | * Stores the location of a piece of text within a file (file name, | ||||
| * line number and column number). Note that the column number is | * line number and column number). Note that the column number is | ||||
| * currently ignored. | * currently ignored. | ||||
| * | |||||
| * @author Matt Foemmel | |||||
| */ | */ | ||||
| public class Location implements Serializable { | public class Location implements Serializable { | ||||
| @@ -119,8 +119,9 @@ public abstract class ProjectComponent { | |||||
| // 'reasonable' default, if the component is used without | // 'reasonable' default, if the component is used without | ||||
| // a Project ( for example as a standalone Bean ). | // a Project ( for example as a standalone Bean ). | ||||
| // Most ant components can be used this way. | // Most ant components can be used this way. | ||||
| if( msgLevel >= Project.MSG_INFO ) | |||||
| System.err.println( msg ); | |||||
| if (msgLevel >= Project.MSG_INFO) { | |||||
| System.err.println(msg); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -58,14 +58,12 @@ import java.io.BufferedReader; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.util.Enumeration; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.helper.ProjectHelper2; | import org.apache.tools.ant.helper.ProjectHelper2; | ||||
| import org.apache.tools.ant.util.LoaderUtils; | import org.apache.tools.ant.util.LoaderUtils; | ||||
| import org.xml.sax.AttributeList; | import org.xml.sax.AttributeList; | ||||
| import org.xml.sax.Attributes; | |||||
| /** | /** | ||||
| * Configures a Project (complete with Targets and Tasks) based on | * Configures a Project (complete with Targets and Tasks) based on | ||||
| @@ -134,7 +132,7 @@ public class ProjectHelper { | |||||
| // Since the tree is composed of UE and RC - it can be reused ! | // Since the tree is composed of UE and RC - it can be reused ! | ||||
| // protected Hashtable processedFiles=new Hashtable(); | // protected Hashtable processedFiles=new Hashtable(); | ||||
| protected Vector importStack=new Vector(); | |||||
| protected Vector importStack = new Vector(); | |||||
| // Temporary - until we figure a better API | // Temporary - until we figure a better API | ||||
| /** EXPERIMENTAL WILL_CHANGE | /** EXPERIMENTAL WILL_CHANGE | ||||
| @@ -464,10 +462,9 @@ public class ProjectHelper { | |||||
| * @deprecated Use PropertyHelper | * @deprecated Use PropertyHelper | ||||
| */ | */ | ||||
| public static String replaceProperties(Project project, String value, | public static String replaceProperties(Project project, String value, | ||||
| Hashtable keys) throws BuildException | |||||
| { | |||||
| PropertyHelper ph=PropertyHelper.getPropertyHelper(project); | |||||
| return ph.replaceProperties( null, value, keys); | |||||
| Hashtable keys) throws BuildException { | |||||
| PropertyHelper ph = PropertyHelper.getPropertyHelper(project); | |||||
| return ph.replaceProperties(null, value, keys); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -490,8 +487,7 @@ public class ProjectHelper { | |||||
| */ | */ | ||||
| public static void parsePropertyString(String value, Vector fragments, | public static void parsePropertyString(String value, Vector fragments, | ||||
| Vector propertyRefs) | Vector propertyRefs) | ||||
| throws BuildException | |||||
| { | |||||
| throws BuildException { | |||||
| PropertyHelper.parsePropertyStringDefault(value, fragments, | PropertyHelper.parsePropertyStringDefault(value, fragments, | ||||
| propertyRefs); | propertyRefs); | ||||
| } | } | ||||
| @@ -54,14 +54,10 @@ | |||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import org.apache.tools.ant.helper.*; | |||||
| import java.util.Hashtable; | |||||
| import java.util.Vector; | |||||
| import java.util.Enumeration; | |||||
| import java.util.*; | |||||
| import org.xml.sax.AttributeList; | |||||
| import org.xml.sax.Attributes; | |||||
| import org.xml.sax.helpers.AttributeListImpl; | |||||
| import org.xml.sax.helpers.AttributesImpl; | |||||
| /* ISSUES: | /* ISSUES: | ||||
| - ns param. It could be used to provide "namespaces" for properties, which | - ns param. It could be used to provide "namespaces" for properties, which | ||||
| @@ -64,6 +64,7 @@ import java.io.IOException; | |||||
| * using this class directly for construction. | * using this class directly for construction. | ||||
| * | * | ||||
| * @see Project#createTask | * @see Project#createTask | ||||
| * @author James Duncan Davidson | |||||
| */ | */ | ||||
| public abstract class Task extends ProjectComponent { | public abstract class Task extends ProjectComponent { | ||||
| /** | /** | ||||
| @@ -104,6 +104,12 @@ public class UnknownElement extends Task { | |||||
| return elementName; | return elementName; | ||||
| } | } | ||||
| /** | |||||
| * Get the RuntimeConfigurable instance for this UnknownElement, containing | |||||
| * the configuration information. | |||||
| * | |||||
| * @return the configuration info. | |||||
| */ | |||||
| public RuntimeConfigurable getWrapper() { | public RuntimeConfigurable getWrapper() { | ||||
| return wrapper; | return wrapper; | ||||
| } | } | ||||
| @@ -84,6 +84,7 @@ import org.w3c.dom.Text; | |||||
| * if executed in parallel. | * if executed in parallel. | ||||
| * | * | ||||
| * @see Project#addBuildListener(BuildListener) | * @see Project#addBuildListener(BuildListener) | ||||
| * @author Matt Foemmel | |||||
| */ | */ | ||||
| public class XmlLogger implements BuildLogger { | public class XmlLogger implements BuildLogger { | ||||
| @@ -288,7 +289,8 @@ public class XmlLogger implements BuildLogger { | |||||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | TimedElement poppedStack = (TimedElement) threadStack.pop(); | ||||
| if (poppedStack != targetElement) { | if (poppedStack != targetElement) { | ||||
| throw new RuntimeException("Mismatch - popped element = " | throw new RuntimeException("Mismatch - popped element = " | ||||
| + poppedStack.element + " finished target element = " | |||||
| + poppedStack.element | |||||
| + " finished target element = " | |||||
| + targetElement.element); | + targetElement.element); | ||||
| } | } | ||||
| if (!threadStack.empty()) { | if (!threadStack.empty()) { | ||||
| @@ -477,6 +479,9 @@ public class XmlLogger implements BuildLogger { | |||||
| /** | /** | ||||
| * Ignore emacs mode, as it has no meaning in XML format | * Ignore emacs mode, as it has no meaning in XML format | ||||
| * | |||||
| * @param emacsMode true if no loggher should produce emacs compatible | |||||
| * output | |||||
| */ | */ | ||||
| public void setEmacsMode(boolean emacsMode) { | public void setEmacsMode(boolean emacsMode) { | ||||
| } | } | ||||
| @@ -485,6 +490,8 @@ public class XmlLogger implements BuildLogger { | |||||
| * Ignore error print stream. All output will be written to | * Ignore error print stream. All output will be written to | ||||
| * either the XML log file or the PrintStream provided to | * either the XML log file or the PrintStream provided to | ||||
| * setOutputPrintStream | * setOutputPrintStream | ||||
| * | |||||
| * @param err the stream we are going to ignore. | |||||
| */ | */ | ||||
| public void setErrorPrintStream(PrintStream err) { | public void setErrorPrintStream(PrintStream err) { | ||||
| } | } | ||||