- externalized strings (Main)
- name-hiding (Main)
- use StringUtils.LINE_SEP instead of locally getting line.seperator property (Main + other classes), I didn't get chance to replace all of these
Included a base main_messages.properties file, but my 2nd language skills are very poor, so I decided against including a translated version. I may get someone here (in work) to contribute a Vietnamese/Japanese bundle at a later date.
Kev
Index: org/apache/tools/ant/Main.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/Main.java,v retrieving revision 1.116 diff -u -r1.116 Main.java --- org/apache/tools/ant/Main.java 21 Jan 2005 11:24:26 -0000 1.116 +++ org/apache/tools/ant/Main.java 21 Feb 2005 14:58:16 -0000 @@ -26,9 +26,11 @@ import java.util.Enumeration; import java.util.Properties; import java.util.Vector; + import org.apache.tools.ant.input.DefaultInputHandler; import org.apache.tools.ant.input.InputHandler; import org.apache.tools.ant.launch.AntMain; +import org.apache.tools.ant.util.StringUtils; /** @@ -43,7 +45,7 @@ * */ public class Main implements AntMain { - + /** The default build file name. */ public static final String DEFAULT_BUILD_FILENAME = "build.xml"; @@ -297,44 +299,35 @@ } else if (arg.equals("-debug") || arg.equals("-d")) { printVersion(); msgOutputLevel = Project.MSG_DEBUG; - } else if (arg.equals("-noinput")) { + } else if (arg.equals("-noinput")) { allowInput = false; - } else if (arg.equals("-logfile") || arg.equals("-l")) { + } else if (arg.equals("-logfile") || arg.equals("-l")) { try { File logFile = new File(args[i + 1]); i++; logTo = new PrintStream(new FileOutputStream(logFile)); isLogFileUsed = true; } catch (IOException ioe) { - String msg = "Cannot write on the specified log file. " - + "Make sure the path exists and you have write " - + "permissions."; - throw new BuildException(msg); + throw new BuildException(MainMessages.CANT_WRITE_LOG); } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a log file when " - + "using the -log argument"; - throw new BuildException(msg); + throw new BuildException(MainMessages.NO_LOG_SPECIFIED); } } else if (arg.equals("-buildfile") || arg.equals("-file") - || arg.equals("-f")) { + || arg.equals("-f")) { try { buildFile = new File(args[i + 1].replace('/', File.separatorChar)); i++; } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a buildfile when " - + "using the -buildfile argument"; - throw new BuildException(msg); + throw new BuildException(MainMessages.NO_BUILD_FILE_SPECIFIED); } - } else if (arg.equals("-listener")) { + } else if (arg.equals("-listener")) { try { listeners.addElement(args[i + 1]); i++; } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a classname when " - + "using the -listener argument"; - throw new BuildException(msg); + throw new BuildException(MainMessages.NO_LISTENER_CLASS_SPECIFIED); } - } else if (arg.startsWith("-D")) { + } else if (arg.startsWith("-D")) { /* Interestingly enough, we get to here when a user * uses -Dname=value. However, in some cases, the OS @@ -349,85 +342,73 @@ String name = arg.substring(2, arg.length()); String value = null; - int posEq = name.indexOf("="); + int posEq = name.indexOf("="); if (posEq > 0) { value = name.substring(posEq + 1); name = name.substring(0, posEq); } else if (i < args.length - 1) { value = args[++i]; } else { - throw new BuildException("Missing value for property " + throw new BuildException(MainMessages.MISSING_VALUE_FOR_PROPERTY + name); } definedProps.put(name, value); - } else if (arg.equals("-logger")) { + } else if (arg.equals("-logger")) { if (loggerClassname != null) { - throw new BuildException("Only one logger class may " - + " be specified."); + throw new BuildException(MainMessages.MORE_THAN_ONE_LOGGER_SPECIFIED); } try { loggerClassname = args[++i]; } catch (ArrayIndexOutOfBoundsException aioobe) { - throw new BuildException("You must specify a classname when" - + " using the -logger argument"); + throw new BuildException(MainMessages.NO_LOGGER_CLASS_SPECIFIED); } - } else if (arg.equals("-inputhandler")) { + } else if (arg.equals("-inputhandler")) { if (inputHandlerClassname != null) { - throw new BuildException("Only one input handler class may " - + "be specified."); + throw new BuildException(MainMessages.MORE_THAN_ONE_INPUT_HANDLER_SPECIFIED); } try { inputHandlerClassname = args[++i]; } catch (ArrayIndexOutOfBoundsException aioobe) { - throw new BuildException("You must specify a classname when" - + " using the -inputhandler" - + " argument"); + throw new BuildException(MainMessages.NO_INPUT_HANDLER_CLASS_SPECIFIED); } - } else if (arg.equals("-emacs") || arg.equals("-e")) { + } else if (arg.equals("-emacs") || arg.equals("-e")) { emacsMode = true; - } else if (arg.equals("-projecthelp") || arg.equals("-p")) { + } else if (arg.equals("-projecthelp") || arg.equals("-p")) { // set the flag to display the targets and quit projectHelp = true; - } else if (arg.equals("-find") || arg.equals("-s")) { + } else if (arg.equals("-find") || arg.equals("-s")) { // eat up next arg if present, default to build.xml if (i < args.length - 1) { searchForThis = args[++i]; } else { searchForThis = DEFAULT_BUILD_FILENAME; } - } else if (arg.startsWith("-propertyfile")) { + } else if (arg.startsWith("-propertyfile")) { try { propertyFiles.addElement(args[i + 1]); i++; } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a property filename when " - + "using the -propertyfile argument"; - throw new BuildException(msg); + throw new BuildException(MainMessages.NO_PROPERTY_FILE_SPECIFIED); } - } else if (arg.equals("-k") || arg.equals("-keep-going")) { + } else if (arg.equals("-k") || arg.equals("-keep-going")) { keepGoingMode = true; - } else if (arg.equals("-nice")) { + } else if (arg.equals("-nice")) { try { threadPriority = Integer.decode(args[i + 1]); } catch (ArrayIndexOutOfBoundsException aioobe) { - throw new BuildException( - "You must supply a niceness value (1-10)" - + " after the -nice option"); + throw new BuildException(MainMessages.NO_NICENESS_VALUE); } catch (NumberFormatException e) { - throw new BuildException("Unrecognized niceness value: " - + args[i + 1]); + throw new BuildException(MainMessages.UNRECOGNIZED_NICENESS_VALUE + args[i + 1]); } i++; if (threadPriority.intValue() < Thread.MIN_PRIORITY || threadPriority.intValue() > Thread.MAX_PRIORITY) { - throw new BuildException( - "Niceness value is out of the range 1-10"); + throw new BuildException(MainMessages.NICENESS_VALUE_OUT_OF_RANGE); } - } else if (arg.startsWith("-")) { + } else if (arg.startsWith("-")) { // we don't have any more args to recognize! - String msg = "Unknown argument: " + arg; - System.out.println(msg); + System.out.println(MainMessages.UNKNOWN_ARGUMENT + arg); printUsage(); throw new BuildException(""); } else { @@ -440,7 +421,7 @@ if (buildFile == null) { // but -find then search for it if (searchForThis != null) { - buildFile = findBuildFile(System.getProperty("user.dir"), + buildFile = findBuildFile(System.getProperty("user.dir"), searchForThis); } else { buildFile = new File(DEFAULT_BUILD_FILENAME); @@ -449,16 +430,16 @@ // make sure buildfile exists if (!buildFile.exists()) { - System.out.println("Buildfile: " + buildFile + " does not exist!"); - throw new BuildException("Build failed"); + System.out.println("Buildfile: " + buildFile + " does not exist!"); + throw new BuildException("Build failed"); } // make sure it's not a directory (this falls into the ultra // paranoid lets check everything category if (buildFile.isDirectory()) { - System.out.println("What? Buildfile: " + buildFile + " is a dir!"); - throw new BuildException("Build failed"); + System.out.println("What? Buildfile: " + buildFile + " is a dir!"); + throw new BuildException("Build failed"); } // Load the property files specified by -propertyfile @@ -473,8 +454,8 @@ fis = new FileInputStream(filename); props.load(fis); } catch (IOException e) { - System.out.println("Could not load property file " - + filename + ": " + e.getMessage()); + System.out.println("Could not load property file " + + filename + ": " + e.getMessage()); } finally { if (fis != null) { try { @@ -496,7 +477,7 @@ } if (msgOutputLevel >= Project.MSG_INFO) { - System.out.println("Buildfile: " + buildFile); + System.out.println("Buildfile: " + buildFile); } if (logTo != null) { @@ -521,7 +502,7 @@ File parent = file.getParentFile(); if (parent != null && msgOutputLevel >= Project.MSG_VERBOSE) { - System.out.println("Searching in " + parent.getAbsolutePath()); + System.out.println("Searching in " + parent.getAbsolutePath()); } return parent; @@ -547,7 +528,7 @@ private File findBuildFile(String start, String suffix) throws BuildException { if (msgOutputLevel >= Project.MSG_INFO) { - System.out.println("Searching for " + suffix + " ..."); + System.out.println("Searching for " + suffix + " ..."); } File parent = new File(new File(start).getAbsolutePath()); @@ -561,7 +542,7 @@ // if parent is null, then we are at the root of the fs, // complain that we can't find the build file. if (parent == null) { - throw new BuildException("Could not locate a build file!"); + throw new BuildException("Could not locate a build file!"); } // refresh our file handle @@ -597,13 +578,12 @@ addBuildListeners(project); addInputHandler(project); - PrintStream err = System.err; - PrintStream out = System.out; - InputStream in = System.in; + PrintStream storedErr = System.err; + PrintStream storedOut = System.out; + InputStream storedIn = System.in; // use a system manager that prevents from System.exit() - SecurityManager oldsm = null; - oldsm = System.getSecurityManager(); + SecurityManager oldsm = System.getSecurityManager(); //SecurityManager can not be installed here for backwards //compatibility reasons (PD). Needs to be loaded prior to @@ -630,7 +610,7 @@ Thread.currentThread().setPriority(threadPriority.intValue()); } catch (SecurityException swallowed) { //we cannot set the priority here. - project.log("A security manager refused to set the -nice value"); + project.log("A security manager refused to set the -nice value"); } } @@ -645,7 +625,7 @@ project.setUserProperty(arg, value); } - project.setUserProperty("ant.file", + project.setUserProperty("ant.file", buildFile.getAbsolutePath()); project.setKeepGoingMode(keepGoingMode); @@ -673,16 +653,16 @@ System.setSecurityManager(oldsm); } - System.setOut(out); - System.setErr(err); - System.setIn(in); + System.setOut(storedOut); + System.setErr(storedErr); + System.setIn(storedIn); } } catch (RuntimeException exc) { error = exc; throw exc; - } catch (Error err) { - error = err; - throw err; + } catch (Error er) { + error = er; + throw er; } finally { if (!projectHelp) { project.fireBuildFinished(error); @@ -704,7 +684,7 @@ // Add the default listener project.addBuildListener(createLogger()); - for (int i = 0; i < listeners.size(); i++) { + for (int i = 0, size = listeners.size(); i < size; i++) { String className = (String) listeners.elementAt(i); try { BuildListener listener = @@ -771,13 +751,13 @@ Class loggerClass = Class.forName(loggerClassname); logger = (BuildLogger) (loggerClass.newInstance()); } catch (ClassCastException e) { - System.err.println("The specified logger class " + System.err.println("The specified logger class " + loggerClassname - + " does not implement the BuildLogger interface"); + + " does not implement the BuildLogger interface"); throw new RuntimeException(); } catch (Exception e) { - System.err.println("Unable to instantiate specified logger " - + "class " + loggerClassname + " : " + System.err.println("Unable to instantiate specified logger " + + "class " + loggerClassname + " : " + e.getClass().getName()); throw new RuntimeException(); } @@ -797,44 +777,43 @@ * Prints the usage information for this class to <code>System.out</code>. */ private static void printUsage() { - String lSep = System.getProperty("line.separator"); StringBuffer msg = new StringBuffer(); - msg.append("ant [options] [target [target2 [target3] ...]]" + lSep); - msg.append("Options: " + lSep); - msg.append(" -help, -h print this message" + lSep); - msg.append(" -projecthelp, -p print project help information" + lSep); - msg.append(" -version print the version information and exit" + lSep); - msg.append(" -diagnostics print information that might be helpful to" + lSep); - msg.append(" diagnose or report problems." + lSep); - msg.append(" -quiet, -q be extra quiet" + lSep); - msg.append(" -verbose, -v be extra verbose" + lSep); - msg.append(" -debug, -d print debugging information" + lSep); - msg.append(" -emacs, -e produce logging information without adornments" - + lSep); - msg.append(" -lib <path> specifies a path to search for jars and classes" - + lSep); - msg.append(" -logfile <file> use given file for log" + lSep); - msg.append(" -l <file> ''" + lSep); - msg.append(" -logger <classname> the class which is to perform logging" + lSep); - msg.append(" -listener <classname> add an instance of class as a project listener" - + lSep); - msg.append(" -noinput do not allow interactive input" + lSep); - msg.append(" -buildfile <file> use given buildfile" + lSep); - msg.append(" -file <file> ''" + lSep); - msg.append(" -f <file> ''" + lSep); - msg.append(" -D<property>=<value> use value for given property" + lSep); - msg.append(" -keep-going, -k execute all targets that do not depend" + lSep); - msg.append(" on failed target(s)" + lSep); - msg.append(" -propertyfile <name> load all properties from file with -D" + lSep); - msg.append(" properties taking precedence" + lSep); - msg.append(" -inputhandler <class> the class which will handle input requests" + lSep); - msg.append(" -find <file> (s)earch for buildfile towards the root of" + lSep); - msg.append(" -s <file> the filesystem and use it" + lSep); - msg.append(" -nice number A niceness value for the main thread:" + lSep - + " 1 (lowest) to 10 (highest); 5 is the default" - + lSep); - msg.append(" -nouserlib Run ant without using the jar files from" + lSep - + " ${user.home}/.ant/lib" + lSep); + msg.append("ant [options] [target [target2 [target3] ...]]" + StringUtils.LINE_SEP); + msg.append("Options: " + StringUtils.LINE_SEP); + msg.append(" -help, -h print this message" + StringUtils.LINE_SEP); + msg.append(" -projecthelp, -p print project help information" + StringUtils.LINE_SEP); + msg.append(" -version print the version information and exit" + StringUtils.LINE_SEP); + msg.append(" -diagnostics print information that might be helpful to" + StringUtils.LINE_SEP); + msg.append(" diagnose or report problems." + StringUtils.LINE_SEP); + msg.append(" -quiet, -q be extra quiet" + StringUtils.LINE_SEP); + msg.append(" -verbose, -v be extra verbose" + StringUtils.LINE_SEP); + msg.append(" -debug, -d print debugging information" + StringUtils.LINE_SEP); + msg.append(" -emacs, -e produce logging information without adornments" + + StringUtils.LINE_SEP); + msg.append(" -lib <path> specifies a path to search for jars and classes" + + StringUtils.LINE_SEP); + msg.append(" -logfile <file> use given file for log" + StringUtils.LINE_SEP); + msg.append(" -l <file> ''" + StringUtils.LINE_SEP); + msg.append(" -logger <classname> the class which is to perform logging" + StringUtils.LINE_SEP); + msg.append(" -listener <classname> add an instance of class as a project listener" + + StringUtils.LINE_SEP); + msg.append(" -noinput do not allow interactive input" + StringUtils.LINE_SEP); + msg.append(" -buildfile <file> use given buildfile" + StringUtils.LINE_SEP); + msg.append(" -file <file> ''" + StringUtils.LINE_SEP); + msg.append(" -f <file> ''" + StringUtils.LINE_SEP); + msg.append(" -D<property>=<value> use value for given property" + StringUtils.LINE_SEP); + msg.append(" -keep-going, -k execute all targets that do not depend" + StringUtils.LINE_SEP); + msg.append(" on failed target(s)" + StringUtils.LINE_SEP); + msg.append(" -propertyfile <name> load all properties from file with -D" + StringUtils.LINE_SEP); + msg.append(" properties taking precedence" + StringUtils.LINE_SEP); + msg.append(" -inputhandler <class> the class which will handle input requests" + StringUtils.LINE_SEP); + msg.append(" -find <file> (s)earch for buildfile towards the root of" + StringUtils.LINE_SEP); + msg.append(" -s <file> the filesystem and use it" + StringUtils.LINE_SEP); + msg.append(" -nice number A niceness value for the main thread:" + StringUtils.LINE_SEP + + " 1 (lowest) to 10 (highest); 5 is the default" + + StringUtils.LINE_SEP); + msg.append(" -nouserlib Run ant without using the jar files from" + StringUtils.LINE_SEP + + " ${user.home}/.ant/lib" + StringUtils.LINE_SEP); msg.append(" -noclasspath Run ant without using CLASSPATH"); System.out.println(msg.toString()); } @@ -1006,15 +985,14 @@ Vector descriptions, String heading, int maxlen) { // now, start printing the targets and their descriptions - String lSep = System.getProperty("line.separator"); // got a bit annoyed that I couldn't find a pad function String spaces = " "; while (spaces.length() <= maxlen) { spaces += spaces; } StringBuffer msg = new StringBuffer(); - msg.append(heading + lSep + lSep); - for (int i = 0; i < names.size(); i++) { + msg.append(heading + StringUtils.LINE_SEP + StringUtils.LINE_SEP); + for (int i = 0, size = names.size(); i < size; i++) { msg.append(" "); msg.append(names.elementAt(i)); if (descriptions != null) { @@ -1022,8 +1000,8 @@ spaces.substring(0, maxlen - ((String) names.elementAt(i)).length() + 2)); msg.append(descriptions.elementAt(i)); } - msg.append(lSep); + msg.append(StringUtils.LINE_SEP); } project.log(msg.toString()); } -} +} \ No newline at end of file Index: org/apache/tools/ant/ProjectHelper.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/ProjectHelper.java,v retrieving revision 1.114 diff -u -r1.114 ProjectHelper.java --- org/apache/tools/ant/ProjectHelper.java 13 Dec 2004 16:43:51 -0000 1.114 +++ org/apache/tools/ant/ProjectHelper.java 21 Feb 2005 14:58:35 -0000 @@ -24,8 +24,11 @@ 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.apache.tools.ant.util.StringUtils; + import org.xml.sax.AttributeList; /** @@ -529,7 +532,7 @@ } String errorMessage = "The following error occurred while executing this line:" - + System.getProperty("line.separator") + + StringUtils.LINE_SEP + ex.getLocation().toString() + ex.getMessage(); if (newLocation == null) { Index: org/apache/tools/ant/UnknownElement.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/UnknownElement.java,v retrieving revision 1.84 diff -u -r1.84 UnknownElement.java --- org/apache/tools/ant/UnknownElement.java 7 Jan 2005 21:56:59 -0000 1.84 +++ org/apache/tools/ant/UnknownElement.java 21 Feb 2005 14:58:54 -0000 @@ -21,7 +21,9 @@ import java.util.Iterator; import java.util.List; import java.io.IOException; + import org.apache.tools.ant.taskdefs.PreSetDef; +import org.apache.tools.ant.util.StringUtils; /** * Wrapper class that holds all the information necessary to create a task @@ -458,45 +460,43 @@ */ protected BuildException getNotFoundException(String what, String elementName) { - String lSep = System.getProperty("line.separator"); String msg = "Could not create " + what + " of type: " + elementName - + "." + lSep + lSep + + "." + StringUtils.LINE_SEP + StringUtils.LINE_SEP + "Ant could not find the task or a class this " - + "task relies upon." + lSep + lSep - + "This is common and has a number of causes; the usual " + lSep - + "solutions are to read the manual pages then download and" + lSep - + "install needed JAR files, or fix the build file: " + lSep - + " - You have misspelt '" + elementName + "'." + lSep - + " Fix: check your spelling." + lSep - + " - The task needs an external JAR file to execute" + lSep - + " and this is not found at the right place in the classpath." + lSep - + " Fix: check the documentation for dependencies." + lSep - + " Fix: declare the task." + lSep - + " - The task is an Ant optional task and the JAR file and/or libraries" + lSep - + " implementing the functionality were not found at the time you" + lSep - + " yourself built your installation of Ant from the Ant sources." + lSep - + " Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the" + lSep - + " task and make sure it contains more than merely a META-INF/MANIFEST.MF." + lSep - + " If all it contains is the manifest, then rebuild Ant with the needed" + lSep - + " libraries present in ${ant.home}/lib/optional/ , or alternatively," + lSep - + " download a pre-built release version from apache.org" + lSep - + " - The build file was written for a later version of Ant" + lSep - + " Fix: upgrade to at least the latest release version of Ant" + lSep - + " - The task is not an Ant core or optional task " + lSep - + " and needs to be declared using <taskdef>." + lSep - + " - You are attempting to use a task defined using " + lSep - + " <presetdef> or <macrodef> but have spelt wrong or not " + lSep - + " defined it at the point of use" + lSep - + lSep - + "Remember that for JAR files to be visible to Ant tasks implemented" + lSep - + "in ANT_HOME/lib, the files must be in the same directory or on the" + lSep - + "classpath" + lSep - + lSep - + "Please neither file bug reports on this problem, nor email the" + lSep - + "Ant mailing lists, until all of these causes have been explored," + lSep + + "task relies upon." + StringUtils.LINE_SEP + StringUtils.LINE_SEP + + "This is common and has a number of causes; the usual " + StringUtils.LINE_SEP + + "solutions are to read the manual pages then download and" + StringUtils.LINE_SEP + + "install needed JAR files, or fix the build file: " + StringUtils.LINE_SEP + + " - You have misspelt '" + elementName + "'." + StringUtils.LINE_SEP + + " Fix: check your spelling." + StringUtils.LINE_SEP + + " - The task needs an external JAR file to execute" + StringUtils.LINE_SEP + + " and this is not found at the right place in the classpath." + StringUtils.LINE_SEP + + " Fix: check the documentation for dependencies." + StringUtils.LINE_SEP + + " Fix: declare the task." + StringUtils.LINE_SEP + + " - The task is an Ant optional task and the JAR file and/or libraries" + StringUtils.LINE_SEP + + " implementing the functionality were not found at the time you" + StringUtils.LINE_SEP + + " yourself built your installation of Ant from the Ant sources." + StringUtils.LINE_SEP + + " Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the" + StringUtils.LINE_SEP + + " task and make sure it contains more than merely a META-INF/MANIFEST.MF." + StringUtils.LINE_SEP + + " If all it contains is the manifest, then rebuild Ant with the needed" + StringUtils.LINE_SEP + + " libraries present in ${ant.home}/lib/optional/ , or alternatively," + StringUtils.LINE_SEP + + " download a pre-built release version from apache.org" + StringUtils.LINE_SEP + + " - The build file was written for a later version of Ant" + StringUtils.LINE_SEP + + " Fix: upgrade to at least the latest release version of Ant" + StringUtils.LINE_SEP + + " - The task is not an Ant core or optional task " + StringUtils.LINE_SEP + + " and needs to be declared using <taskdef>." + StringUtils.LINE_SEP + + " - You are attempting to use a task defined using " + StringUtils.LINE_SEP + + " <presetdef> or <macrodef> but have spelt wrong or not " + StringUtils.LINE_SEP + + " defined it at the point of use" + StringUtils.LINE_SEP + + StringUtils.LINE_SEP + + "Remember that for JAR files to be visible to Ant tasks implemented" + StringUtils.LINE_SEP + + "in ANT_HOME/lib, the files must be in the same directory or on the" + StringUtils.LINE_SEP + + "classpath" + StringUtils.LINE_SEP + + StringUtils.LINE_SEP + + "Please neither file bug reports on this problem, nor email the" + StringUtils.LINE_SEP + + "Ant mailing lists, until all of these causes have been explored," + StringUtils.LINE_SEP + "as this is not an Ant bug."; - return new BuildException(msg, getLocation()); } Index: org/apache/tools/ant/filters/util/JavaClassHelper.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java,v retrieving revision 1.10 diff -u -r1.10 JavaClassHelper.java --- org/apache/tools/ant/filters/util/JavaClassHelper.java 9 Mar 2004 16:48:02 -0000 1.10 +++ org/apache/tools/ant/filters/util/JavaClassHelper.java 21 Feb 2005 14:58:57 -0000 @@ -18,10 +18,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; + import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.ConstantValue; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; +import org.apache.tools.ant.util.StringUtils; /** * Helper class that filters constants from a Java Class @@ -29,9 +31,6 @@ */ public final class JavaClassHelper { - /** System specific line separator. */ - private static final String LS = System.getProperty("line.separator"); - /** * Get the constants declared in a file as name=value * @@ -59,7 +58,7 @@ sb.append(field.getName()); sb.append('='); sb.append(cvs); - sb.append(LS); + sb.append(StringUtils.LINE_SEP); } } } Index: org/apache/tools/ant/taskdefs/AbstractCvsTask.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v retrieving revision 1.35 diff -u -r1.35 AbstractCvsTask.java --- org/apache/tools/ant/taskdefs/AbstractCvsTask.java 17 Jul 2004 15:10:11 -0000 1.35 +++ org/apache/tools/ant/taskdefs/AbstractCvsTask.java 21 Feb 2005 14:59:17 -0000 @@ -375,8 +375,9 @@ public void execute() throws BuildException { String savedCommand = getCommand(); - - if (this.getCommand() == null && vecCommandlines.size() == 0) { + int commandLinesSize = vecCommandlines.size(); + + if (this.getCommand() == null && commandLinesSize == 0) { // re-implement legacy behaviour: this.setCommand(AbstractCvsTask.DEFAULT_COMMAND); } @@ -387,10 +388,11 @@ cloned = (Commandline) cmd.clone(); cloned.createArgument(true).setLine(c); this.addConfiguredCommandline(cloned, true); + commandLinesSize++; //added another command to vector } try { - for (int i = 0; i < vecCommandlines.size(); i++) { + for (int i = 0; i < commandLinesSize; i++) { this.runCommand((Commandline) vecCommandlines.elementAt(i)); } } finally { Index: org/apache/tools/ant/taskdefs/Execute.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v retrieving revision 1.89 diff -u -r1.89 Execute.java --- org/apache/tools/ant/taskdefs/Execute.java 2 Feb 2005 07:59:36 -0000 1.89 +++ org/apache/tools/ant/taskdefs/Execute.java 21 Feb 2005 15:00:52 -0000 @@ -34,6 +34,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.util.FileUtils; +import org.apache.tools.ant.util.StringUtils; import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.types.Commandline; @@ -166,15 +167,15 @@ return procEnvironment; } String var = null; - String line, lineSep = System.getProperty("line.separator"); + String line; while ((line = in.readLine()) != null) { if (line.indexOf('=') == -1) { // Chunk part of previous env var (UNIX env vars can // contain embedded new lines). if (var == null) { - var = lineSep + line; + var = StringUtils.LINE_SEP + line; } else { - var += lineSep + line; + var += StringUtils.LINE_SEP + line; } } else { // New env var...append the previous one if we have it. Index: org/apache/tools/ant/taskdefs/Javac.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v retrieving revision 1.124 diff -u -r1.124 Javac.java --- org/apache/tools/ant/taskdefs/Javac.java 12 Nov 2004 15:14:59 -0000 1.124 +++ org/apache/tools/ant/taskdefs/Javac.java 21 Feb 2005 15:01:20 -0000 @@ -18,6 +18,7 @@ package org.apache.tools.ant.taskdefs; import java.io.File; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; Index: org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java,v retrieving revision 1.27 diff -u -r1.27 CompilerAdapterFactory.java --- org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java 30 Sep 2004 12:41:52 -0000 1.27 +++ org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java 21 Feb 2005 15:01:26 -0000 @@ -127,6 +127,9 @@ || compilerType.equalsIgnoreCase("symantec")) { return new Sj(); } + if (compilerType.equalsIgnoreCase("ajc")) { + return new Ajc(); + } return resolveClassName(compilerType); } @@ -146,6 +149,7 @@ return true; } } catch (ClassNotFoundException cnfe2) { + /* do nothing */ } } return false; Index: org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v retrieving revision 1.58 diff -u -r1.58 DefaultCompilerAdapter.java --- org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 26 Jan 2005 15:11:26 -0000 1.58 +++ org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 21 Feb 2005 15:01:47 -0000 @@ -68,7 +68,7 @@ protected String memoryMaximumSize; protected File[] compileList; - protected static final String lSep = System.getProperty("line.separator"); + protected static final String LINE_SEPARATOR = System.getProperty("line.separator"); protected Javac attributes; @@ -398,12 +398,12 @@ } niceSourceList.append(" to be compiled:"); - niceSourceList.append(lSep); + niceSourceList.append(LINE_SEPARATOR); for (int i = 0; i < compileList.length; i++) { String arg = compileList[i].getAbsolutePath(); cmd.createArgument().setValue(arg); - niceSourceList.append(" " + arg + lSep); + niceSourceList.append(" " + arg + LINE_SEPARATOR); } attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); Index: org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java,v retrieving revision 1.28 diff -u -r1.28 ChangeLogParser.java --- org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java 6 Dec 2004 17:35:42 -0000 1.28 +++ org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java 21 Feb 2005 15:01:51 -0000 @@ -23,6 +23,8 @@ import java.util.Hashtable; import java.util.TimeZone; +import org.apache.tools.ant.util.StringUtils; + /** * A class used to parse the output of the CVS log command. * @@ -114,23 +116,22 @@ * @param line the line */ private void processComment(final String line) { - final String lineSeparator = System.getProperty("line.separator"); if (line.equals( "=============================================================================")) { //We have ended changelog for that particular file //so we can save it final int end - = comment.length() - lineSeparator.length(); //was -1 + = comment.length() - StringUtils.LINE_SEP.length(); //was -1 comment = comment.substring(0, end); saveEntry(); status = GET_FILE; } else if (line.equals("----------------------------")) { final int end - = comment.length() - lineSeparator.length(); //was -1 + = comment.length() - StringUtils.LINE_SEP.length(); //was -1 comment = comment.substring(0, end); status = GET_PREVIOUS_REV; } else { - comment += line + lineSeparator; + comment += line + StringUtils.LINE_SEP; } } @@ -218,12 +219,12 @@ /** * Parse date out from expected format. * - * @param date the string holding date + * @param dateToParse the string holding date * @return the date object or null if unknown date format */ - private Date parseDate(final String date) { + private Date parseDate(final String dateToParse) { try { - return INPUT_DATE.parse(date); + return INPUT_DATE.parse(dateToParse); } catch (ParseException e) { //final String message = REZ.getString( "changelog.bat-date.error", date ); //getContext().error( message ); Index: org/apache/tools/ant/taskdefs/email/EmailTask.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java,v retrieving revision 1.30 diff -u -r1.30 EmailTask.java --- org/apache/tools/ant/taskdefs/email/EmailTask.java 2 Feb 2005 20:08:57 -0000 1.30 +++ org/apache/tools/ant/taskdefs/email/EmailTask.java 21 Feb 2005 15:02:10 -0000 @@ -202,15 +202,15 @@ /** * Add a message element. * - * @param message The message object. + * @param messageToAdd The message object. * @throws BuildException if a message has already been added. */ - public void addMessage(Message message) throws BuildException { + public void addMessage(Message messageToAdd) throws BuildException { if (this.message != null) { throw new BuildException( "Only one message can be sent in an email"); } - this.message = message; + this.message = messageToAdd; } /** Index: org/apache/tools/ant/taskdefs/optional/Javah.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java,v retrieving revision 1.34 diff -u -r1.34 Javah.java --- org/apache/tools/ant/taskdefs/optional/Javah.java 4 Feb 2005 08:08:07 -0000 1.34 +++ org/apache/tools/ant/taskdefs/optional/Javah.java 21 Feb 2005 15:02:16 -0000 @@ -22,6 +22,7 @@ import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; @@ -30,7 +31,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.JavaEnvUtils; +import org.apache.tools.ant.util.StringUtils; import org.apache.tools.ant.util.facade.FacadeTaskHelper; import org.apache.tools.ant.util.facade.ImplementationSpecificArgument; @@ -78,7 +79,6 @@ private boolean stubs = false; private Path bootclasspath; //private Path extdirs; - private static String lSep = System.getProperty("line.separator"); private FacadeTaskHelper facade = null; public Javah() { @@ -414,7 +414,7 @@ String[] c = getClasses(); for (int i = 0; i < c.length; i++) { cmd.createArgument().setValue(c[i]); - niceClassList.append(" " + c[i] + lSep); + niceClassList.append(" " + c[i] + StringUtils.LINE_SEP); } StringBuffer prefix = new StringBuffer("Class"); @@ -422,7 +422,7 @@ prefix.append("es"); } prefix.append(" to be compiled:"); - prefix.append(lSep); + prefix.append(StringUtils.LINE_SEP); log(prefix.toString() + niceClassList.toString(), Project.MSG_VERBOSE); } Index: org/apache/tools/ant/util/DOMElementWriter.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/util/DOMElementWriter.java,v retrieving revision 1.26 diff -u -r1.26 DOMElementWriter.java --- org/apache/tools/ant/util/DOMElementWriter.java 24 Jan 2005 18:13:20 -0000 1.26 +++ org/apache/tools/ant/util/DOMElementWriter.java 21 Feb 2005 15:02:46 -0000 @@ -21,6 +21,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; + import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -28,6 +29,8 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; +import org.apache.tools.ant.util.StringUtils; + /** * Writes a DOM tree to a given Writer. * @@ -39,8 +42,6 @@ */ public class DOMElementWriter { - private static String lSep = System.getProperty("line.separator"); - /** * Don't try to be too smart but at least recognize the predefined * entities. @@ -107,7 +108,7 @@ case Node.ELEMENT_NODE: if (!hasChildren) { - out.write(lSep); + out.write(StringUtils.LINE_SEP); hasChildren = true; } write((Element) child, out, indent + 1, indentWith); @@ -163,7 +164,7 @@ out.write("</"); out.write(element.getTagName()); out.write(">"); - out.write(lSep); + out.write(StringUtils.LINE_SEP); out.flush(); } Index: org/apache/tools/ant/MainMessages.java =================================================================== RCS file: org/apache/tools/ant/MainMessages.java diff -N org/apache/tools/ant/MainMessages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org/apache/tools/ant/MainMessages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,56 @@ +/* + * Copyright 2000-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. + * + */ + +package org.apache.tools.ant; + +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class MainMessages { + private static final String BUNDLE_NAME = "org/apache/tools/ant/main_messages"; + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME, Locale.getDefault()); + + static final String CANT_WRITE_LOG = RESOURCE_BUNDLE.getString("Main.CantWriteLog"); + static final String NO_LOG_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoLogSpecified"); + static final String NO_BUILD_FILE_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoBuildFileSpecified"); + static final String NO_LISTENER_CLASS_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoListenerClassSpecified"); + static final String MISSING_VALUE_FOR_PROPERTY = RESOURCE_BUNDLE.getString("Main.MissingValueForProperty"); + static final String MORE_THAN_ONE_LOGGER_SPECIFIED = RESOURCE_BUNDLE.getString("Main.MoreThanOneLoggerSpecified"); + static final String NO_LOGGER_CLASS_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoLoggerClassSpecified"); + static final String MORE_THAN_ONE_INPUT_HANDLER_SPECIFIED = RESOURCE_BUNDLE.getString("Main.MoreThanOneInputHandlerSpecified"); + static final String NO_INPUT_HANDLER_CLASS_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoInputHandlerClassSpecified"); + static final String NO_PROPERTY_FILE_SPECIFIED = RESOURCE_BUNDLE.getString("Main.NoPropertyFileSpecified"); + static final String NO_NICENESS_VALUE = RESOURCE_BUNDLE.getString("Main.NoNicenessValue"); + static final String UNRECOGNIZED_NICENESS_VALUE = RESOURCE_BUNDLE.getString("Main.UnrecognizedNicenessValue"); + static final String NICENESS_VALUE_OUT_OF_RANGE = RESOURCE_BUNDLE.getString("Main.NicenessValueOutOfRange"); + static final String UNKNOWN_ARGUMENT = RESOURCE_BUNDLE.getString("Main.UnknownArgument"); + + private MainMessages() { + //private constructor + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} Index: org/apache/tools/ant/main_messages.properties =================================================================== RCS file: org/apache/tools/ant/main_messages.properties diff -N org/apache/tools/ant/main_messages.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org/apache/tools/ant/main_messages.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +Main.CantWriteLog=Cannot write on the specified log file. Make sure the path exists and you have write permissions. +Main.NoLogSpecified=You must specify a log file when using the -log argument. +Main.NoBuildFileSpecified=You must specify a buildfile when using the -buildfile argument. +Main.NoListenerClassSpecified=You must specify a classname when using the -listener argument. +Main.MissingPropertyValue=Missing value for property +Main.MoreThanOneLoggerSpecified=Only one logger class may be specified. +Main.NoLoggerClassSpecified=You must specify a classname when using the -logger argument. +Main.MoreThanOneInputHandlerSpecified=Only one input handler class may be specified. +Main.NoInputHandlerClassSpecified=You must specify a classname when using the -inputhandler argument. +Main.NoPropertyFileSpecified=You must specify a property filename when using the -propertyfile argument. +Main.NoNicenessValue=You must supply a niceness value (1-10) after the -nice option. +Main.UnrecognizedNicenessValue=Unrecognized niceness value: +Main.NicenessValueOutOfRange=Niceness value is out of the range 1-10. +Main.UnknownArgument=Unknown argument: Index: org/apache/tools/ant/main_messages_en_US.properties =================================================================== RCS file: org/apache/tools/ant/main_messages_en_US.properties diff -N org/apache/tools/ant/main_messages_en_US.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org/apache/tools/ant/main_messages_en_US.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +Main.CantWriteLog=Cannot write on the specified log file. Make sure the path exists and you have write permissions. +Main.NoLogSpecified=You must specify a log file when using the -log argument. +Main.NoBuildFileSpecified=You must specify a buildfile when using the -buildfile argument. +Main.NoListenerClassSpecified=You must specify a classname when using the -listener argument. +Main.MissingValueForProperty=Missing value for property +Main.MoreThanOneLoggerSpecified=Only one logger class may be specified. +Main.NoLoggerClassSpecified=You must specify a classname when using the -logger argument. +Main.MoreThanOneInputHandlerSpecified=Only one input handler class may be specified. +Main.NoInputHandlerClassSpecified=You must specify a classname when using the -inputhandler argument. +Main.NoPropertyFileSpecified=You must specify a property filename when using the -propertyfile argument. +Main.NoNicenessValue=You must supply a niceness value (1-10) after the -nice option. +Main.UnrecognizedNicenessValue=Unrecognized niceness value: +Main.NicenessValueOutOfRange=Niceness value is out of the range 1-10. +Main.UnknownArgument=Unknown argument:
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]