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 { | |||
| private static final String TEST_CLASS | |||
| = "org.apache.tools.ant.taskdefs.optional.Test"; | |||
| /** utility class */ | |||
| private Diagnostics(){ | |||
| } | |||
| @@ -88,7 +91,7 @@ public final class Diagnostics { | |||
| */ | |||
| public static boolean isOptionalAvailable() { | |||
| try { | |||
| Class.forName("org.apache.tools.ant.taskdefs.optional.Test"); | |||
| Class.forName(TEST_CLASS); | |||
| } catch (ClassNotFoundException e){ | |||
| return false; | |||
| } | |||
| @@ -102,13 +105,15 @@ public final class Diagnostics { | |||
| */ | |||
| public static void validateVersion() throws BuildException { | |||
| 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 optionalVersion = getImplementationVersion(optional); | |||
| if (coreVersion != null && !coreVersion.equals(optionalVersion) ){ | |||
| if (coreVersion != null && !coreVersion.equals(optionalVersion)) { | |||
| 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" + | |||
| " optional: " + optionalVersion); | |||
| } | |||
| @@ -169,7 +174,7 @@ public final class Diagnostics { | |||
| // pkg.getImplementationVersion(); | |||
| method = pkg.getClass().getMethod("getImplementationVersion", new Class[0]); | |||
| Object version = method.invoke(pkg, null); | |||
| return (String)version; | |||
| return (String) version; | |||
| } | |||
| } catch (Exception e){ | |||
| // 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 | |||
| */ | |||
| private static String getXmlParserName() { | |||
| SAXParser saxParser= getSAXParser(); | |||
| SAXParser saxParser = getSAXParser(); | |||
| if (saxParser == null) { | |||
| return "Could not create an XML Parser"; | |||
| } | |||
| @@ -202,7 +207,7 @@ public final class Diagnostics { | |||
| if (saxParserFactory == null) { | |||
| return null; | |||
| } | |||
| SAXParser saxParser=null; | |||
| SAXParser saxParser = null; | |||
| try { | |||
| saxParser = saxParserFactory.newSAXParser(); | |||
| } catch (Exception e) { | |||
| @@ -220,7 +225,7 @@ public final class Diagnostics { | |||
| if (saxParser == null) { | |||
| return null; | |||
| } | |||
| String location=getClassLocation(saxParser.getClass()); | |||
| String location = getClassLocation(saxParser.getClass()); | |||
| return location; | |||
| } | |||
| @@ -230,7 +235,7 @@ public final class Diagnostics { | |||
| * @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); | |||
| return f == null ? null : f.getAbsolutePath(); | |||
| } | |||
| @@ -253,7 +258,8 @@ public final class Diagnostics { | |||
| try { | |||
| optional = Class.forName( | |||
| "org.apache.tools.ant.taskdefs.optional.Test"); | |||
| out.println("optional tasks : " + getImplementationVersion(optional)); | |||
| out.println("optional tasks : " | |||
| + getImplementationVersion(optional)); | |||
| } catch (ClassNotFoundException e){ | |||
| out.println("optional tasks : not available"); | |||
| } | |||
| @@ -297,9 +303,9 @@ public final class Diagnostics { | |||
| * @param out the stream to print the properties to. | |||
| */ | |||
| 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)); | |||
| } | |||
| } | |||
| @@ -331,7 +337,8 @@ public final class Diagnostics { | |||
| Throwable error = null; | |||
| try { | |||
| 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[]{}}); | |||
| } catch (ClassNotFoundException e) { | |||
| out.println("Not available."); | |||
| @@ -366,7 +373,7 @@ public final class Diagnostics { | |||
| try { | |||
| props.load(is); | |||
| for (Enumeration keys = props.keys(); keys.hasMoreElements();){ | |||
| String key = (String)keys.nextElement(); | |||
| String key = (String) keys.nextElement(); | |||
| String classname = props.getProperty(key); | |||
| try { | |||
| Class.forName(classname); | |||
| @@ -375,7 +382,7 @@ public final class Diagnostics { | |||
| out.println(key + " : Not Available"); | |||
| } catch (NoClassDefFoundError e) { | |||
| String pkg = e.getMessage().replace('/', '.'); | |||
| out.println(key + " : Missing dependency " + pkg ); | |||
| out.println(key + " : Missing dependency " + pkg); | |||
| } catch (Error e) { | |||
| out.println(key + " : Initialization error"); | |||
| } | |||
| @@ -394,13 +401,13 @@ public final class Diagnostics { | |||
| * @param 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 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: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. | |||
| @@ -558,7 +559,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||
| if (isIncluded("")) { | |||
| if (!isExcluded("")) { | |||
| if (isSelected("",basedir)) { | |||
| if (isSelected("", basedir)) { | |||
| dirsIncluded.addElement(""); | |||
| } else { | |||
| dirsDeselected.addElement(""); | |||
| @@ -676,7 +677,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||
| if (file.isDirectory()) { | |||
| if (isIncluded(name)) { | |||
| if (!isExcluded(name)) { | |||
| if (isSelected(name,file)) { | |||
| if (isSelected(name, file)) { | |||
| dirsIncluded.addElement(name); | |||
| if (fast) { | |||
| scandir(file, name + File.separator, fast); | |||
| @@ -709,7 +710,7 @@ public class DirectoryScanner implements FileScanner, SelectorScanner, ResourceF | |||
| } else if (file.isFile()) { | |||
| if (isIncluded(name)) { | |||
| if (!isExcluded(name)) { | |||
| if (isSelected(name,file)) { | |||
| if (isSelected(name, file)) { | |||
| filesIncluded.addElement(name); | |||
| } else { | |||
| 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. | |||
| * | |||
| * @return the resource with the given name. | |||
| * @since Ant 1.5.2 | |||
| */ | |||
| public Resource getResource(String name) { | |||
| @@ -257,7 +257,8 @@ public class IntrospectionHelper implements BuildListener { | |||
| particular order. | |||
| */ | |||
| } | |||
| AttributeSetter as = createAttributeSetter(m, args[0], propName); | |||
| AttributeSetter as | |||
| = createAttributeSetter(m, args[0], propName); | |||
| if (as != null) { | |||
| attributeTypes.put(propName, args[0]); | |||
| 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, | |||
| * line number and column number). Note that the column number is | |||
| * currently ignored. | |||
| * | |||
| * @author Matt Foemmel | |||
| */ | |||
| public class Location implements Serializable { | |||
| @@ -119,8 +119,9 @@ public abstract class ProjectComponent { | |||
| // 'reasonable' default, if the component is used without | |||
| // a Project ( for example as a standalone Bean ). | |||
| // 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.InputStream; | |||
| import java.io.InputStreamReader; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.helper.ProjectHelper2; | |||
| import org.apache.tools.ant.util.LoaderUtils; | |||
| import org.xml.sax.AttributeList; | |||
| import org.xml.sax.Attributes; | |||
| /** | |||
| * 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 ! | |||
| // protected Hashtable processedFiles=new Hashtable(); | |||
| protected Vector importStack=new Vector(); | |||
| protected Vector importStack = new Vector(); | |||
| // Temporary - until we figure a better API | |||
| /** EXPERIMENTAL WILL_CHANGE | |||
| @@ -464,10 +462,9 @@ public class ProjectHelper { | |||
| * @deprecated Use PropertyHelper | |||
| */ | |||
| 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, | |||
| Vector propertyRefs) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| PropertyHelper.parsePropertyStringDefault(value, fragments, | |||
| propertyRefs); | |||
| } | |||
| @@ -54,14 +54,10 @@ | |||
| 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: | |||
| - 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. | |||
| * | |||
| * @see Project#createTask | |||
| * @author James Duncan Davidson | |||
| */ | |||
| public abstract class Task extends ProjectComponent { | |||
| /** | |||
| @@ -104,6 +104,12 @@ public class UnknownElement extends Task { | |||
| return elementName; | |||
| } | |||
| /** | |||
| * Get the RuntimeConfigurable instance for this UnknownElement, containing | |||
| * the configuration information. | |||
| * | |||
| * @return the configuration info. | |||
| */ | |||
| public RuntimeConfigurable getWrapper() { | |||
| return wrapper; | |||
| } | |||
| @@ -84,6 +84,7 @@ import org.w3c.dom.Text; | |||
| * if executed in parallel. | |||
| * | |||
| * @see Project#addBuildListener(BuildListener) | |||
| * @author Matt Foemmel | |||
| */ | |||
| public class XmlLogger implements BuildLogger { | |||
| @@ -288,7 +289,8 @@ public class XmlLogger implements BuildLogger { | |||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | |||
| if (poppedStack != targetElement) { | |||
| throw new RuntimeException("Mismatch - popped element = " | |||
| + poppedStack.element + " finished target element = " | |||
| + poppedStack.element | |||
| + " finished target element = " | |||
| + targetElement.element); | |||
| } | |||
| if (!threadStack.empty()) { | |||
| @@ -477,6 +479,9 @@ public class XmlLogger implements BuildLogger { | |||
| /** | |||
| * 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) { | |||
| } | |||
| @@ -485,6 +490,8 @@ public class XmlLogger implements BuildLogger { | |||
| * Ignore error print stream. All output will be written to | |||
| * either the XML log file or the PrintStream provided to | |||
| * setOutputPrintStream | |||
| * | |||
| * @param err the stream we are going to ignore. | |||
| */ | |||
| public void setErrorPrintStream(PrintStream err) { | |||
| } | |||