git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274794 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -176,7 +176,7 @@ public class PathTokenizer { | |||
| // make sure we aren't going to get the path separator next | |||
| if (!nextToken.equals(File.pathSeparator)) { | |||
| if (nextToken.equals(":")) { | |||
| if (!token.startsWith("/") && !token.startsWith("\\")){ | |||
| if (!token.startsWith("/") && !token.startsWith("\\")) { | |||
| // it indeed is a drive spec, get the next bit | |||
| String oneMore = tokenizer.nextToken().trim(); | |||
| if (!oneMore.equals(File.pathSeparator)) { | |||
| @@ -55,7 +55,6 @@ package org.apache.tools.ant.filters; | |||
| import java.io.IOException; | |||
| import java.io.Reader; | |||
| import org.apache.tools.ant.types.Parameter; | |||
| /** | |||
| * Converts non latin characters to unicode escapes | |||
| @@ -66,7 +66,8 @@ import org.apache.tools.ant.types.Parameter; | |||
| * | |||
| * Or: | |||
| * | |||
| * <pre><filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/></pre> | |||
| * <pre><filterreader | |||
| * classname="org.apache.tools.ant.filters.StripLineBreaks"/></pre> | |||
| * | |||
| * @author Steve Loughran | |||
| * @author Magesh Umasankar | |||
| @@ -104,7 +104,8 @@ public class Mkdir extends Task { | |||
| /** | |||
| * the directory to create; required. | |||
| * @param dir | |||
| * | |||
| * @param dir the directory to be made. | |||
| */ | |||
| public void setDir(File dir) { | |||
| this.dir = dir; | |||
| @@ -94,6 +94,8 @@ public class Sequential extends Task | |||
| /** | |||
| * Execute all nestedTasks. | |||
| * | |||
| * @throws BuildException if one of the nested tasks fails. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();) { | |||
| @@ -272,7 +272,7 @@ public class ANTLR extends Task { | |||
| * getResource doesn't contain the name of the archive.</p> | |||
| */ | |||
| protected void addClasspathEntry(String resource) { | |||
| /* | |||
| /* | |||
| * pre Ant 1.6 this method used to call getClass().getResource | |||
| * while Ant 1.6 will call ClassLoader.getResource(). | |||
| * | |||
| @@ -287,7 +287,7 @@ public class ANTLR extends Task { | |||
| resource = "org/apache/tools/ant/taskdefs/optional/" | |||
| + resource; | |||
| } | |||
| File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | |||
| resource); | |||
| if (f != null) { | |||
| @@ -302,13 +302,13 @@ public class ANTLR extends Task { | |||
| validateAttributes(); | |||
| //TODO: use ANTLR to parse the grammar file to do this. | |||
| File generatedFile = getGeneratedFile(); | |||
| boolean targetIsOutOfDate = | |||
| boolean targetIsOutOfDate = | |||
| target.lastModified() > generatedFile.lastModified(); | |||
| boolean superGrammarIsOutOfDate = superGrammar != null && | |||
| (superGrammar.lastModified() > generatedFile.lastModified()); | |||
| if (targetIsOutOfDate || superGrammarIsOutOfDate) { | |||
| if (targetIsOutOfDate) { | |||
| log("Compiling " + target + " as it is newer than " | |||
| log("Compiling " + target + " as it is newer than " | |||
| + generatedFile, Project.MSG_VERBOSE); | |||
| } else if (superGrammarIsOutOfDate) { | |||
| log("Compiling " + target + " as " + superGrammar | |||
| @@ -329,7 +329,7 @@ public class ANTLR extends Task { | |||
| } | |||
| } | |||
| } else { | |||
| log("Skipped grammar file. Generated file " + generatedFile | |||
| log("Skipped grammar file. Generated file " + generatedFile | |||
| + "is newer.", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -410,10 +410,10 @@ public class ANTLR extends Task { | |||
| /** execute in a forked VM */ | |||
| private int run(String[] command) throws BuildException { | |||
| PumpStreamHandler psh = | |||
| PumpStreamHandler psh = | |||
| new PumpStreamHandler(new LogOutputStream(this, Project.MSG_INFO), | |||
| new TeeOutputStream( | |||
| new LogOutputStream(this, | |||
| new LogOutputStream(this, | |||
| Project.MSG_WARN), | |||
| bos) | |||
| ); | |||
| @@ -83,71 +83,88 @@ public class Translate extends MatchingTask { | |||
| * Family name of resource bundle | |||
| */ | |||
| private String bundle; | |||
| /** | |||
| * Locale specific language of the resource bundle | |||
| */ | |||
| private String bundleLanguage; | |||
| /** | |||
| * Locale specific country of the resource bundle | |||
| */ | |||
| private String bundleCountry; | |||
| /** | |||
| * Locale specific variant of the resource bundle | |||
| */ | |||
| private String bundleVariant; | |||
| /** | |||
| * Destination directory | |||
| */ | |||
| private File toDir; | |||
| /** | |||
| * Source file encoding scheme | |||
| */ | |||
| private String srcEncoding; | |||
| /** | |||
| * Destination file encoding scheme | |||
| */ | |||
| private String destEncoding; | |||
| /** | |||
| * Resource Bundle file encoding scheme, defaults to srcEncoding | |||
| */ | |||
| private String bundleEncoding; | |||
| /** | |||
| * Starting token to identify keys | |||
| */ | |||
| private String startToken; | |||
| /** | |||
| * Ending token to identify keys | |||
| */ | |||
| private String endToken; | |||
| /** | |||
| * Whether or not to create a new destination file. | |||
| * Defaults to <code>false</code>. | |||
| */ | |||
| private boolean forceOverwrite; | |||
| /** | |||
| * Vector to hold source file sets. | |||
| */ | |||
| private Vector filesets = new Vector(); | |||
| /** | |||
| * Holds key value pairs loaded from resource bundle file | |||
| */ | |||
| private Hashtable resourceMap = new Hashtable(); | |||
| /** | |||
| * Used to resolve file names. | |||
| */ | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| /** | |||
| * Last Modified Timestamp of resource bundle file being used. | |||
| */ | |||
| private long[] bundleLastModified = new long[7]; | |||
| /** | |||
| * Last Modified Timestamp of source file being used. | |||
| */ | |||
| private long srcLastModified; | |||
| /** | |||
| * Last Modified Timestamp of destination file being used. | |||
| */ | |||
| private long destLastModified; | |||
| /** | |||
| * Has at least one file from the bundle been loaded? | |||
| */ | |||
| @@ -283,10 +300,8 @@ public class Translate extends MatchingTask { | |||
| if (!toDir.exists()) { | |||
| toDir.mkdirs(); | |||
| } else { | |||
| if (toDir.isFile()) { | |||
| throw new BuildException(toDir + " is not a directory"); | |||
| } | |||
| } else if (toDir.isFile()) { | |||
| throw new BuildException(toDir + " is not a directory"); | |||
| } | |||
| if (srcEncoding == null) { | |||
| @@ -509,63 +524,62 @@ public class Translate extends MatchingTask { | |||
| = new BufferedReader(new InputStreamReader(fis, srcEncoding)); | |||
| String line; | |||
| while ((line = in.readLine()) != null) { | |||
| // 2003-02-21 new replace algorithm by tbee (tbee@tbee.org) | |||
| // because it wasn't able to replace something like "@aaa;@bbb;" | |||
| // is there a startToken | |||
| // and there is still stuff following the startToken | |||
| int startIndex = line.indexOf(startToken); | |||
| while ( startIndex >= 0 && (startIndex+startToken.length()) <= line.length() ) | |||
| { | |||
| // the new value, this needs to be here | |||
| // because it is required to calculate the next position to search from | |||
| // at the end of the loop | |||
| String replace = null; | |||
| // we found a starttoken, is there an endtoken following? | |||
| // start at token+tokenlength because start and end token may be indentical | |||
| int endIndex = line.indexOf(endToken, startIndex + startToken.length()); | |||
| if (endIndex < 0) startIndex += 1; | |||
| else | |||
| { | |||
| // grab the token | |||
| String token = line.substring(startIndex + startToken.length(), endIndex); | |||
| // If there is a white space or = or :, then | |||
| // it isn't to be treated as a valid key. | |||
| boolean validToken = true; | |||
| for (int k = 0; k < token.length() && validToken; k++) | |||
| { | |||
| char c = token.charAt(k); | |||
| if ( c == ':' | |||
| || c == '=' | |||
| || Character.isSpaceChar(c) | |||
| ) | |||
| { | |||
| validToken = false; | |||
| } | |||
| } | |||
| if (!validToken) startIndex += 1; | |||
| else | |||
| { | |||
| // find the replace string | |||
| if (resourceMap.containsKey(token)) replace = (String)resourceMap.get(token); | |||
| else replace = token; | |||
| // generate the new line | |||
| line = line.substring(0, startIndex) | |||
| + replace | |||
| + line.substring(endIndex + endToken.length()); | |||
| // set start position for next search | |||
| startIndex += replace.length(); | |||
| } | |||
| } | |||
| // find next starttoken | |||
| startIndex = line.indexOf(startToken, startIndex); | |||
| } | |||
| // 2003-02-21 new replace algorithm by tbee (tbee@tbee.org) | |||
| // because it wasn't able to replace something like "@aaa;@bbb;" | |||
| // is there a startToken | |||
| // and there is still stuff following the startToken | |||
| int startIndex = line.indexOf(startToken); | |||
| while (startIndex >= 0 && (startIndex + startToken.length()) <= line.length()) { | |||
| // the new value, this needs to be here | |||
| // because it is required to calculate the next position to search from | |||
| // at the end of the loop | |||
| String replace = null; | |||
| // we found a starttoken, is there an endtoken following? | |||
| // start at token+tokenlength because start and end token may be indentical | |||
| int endIndex = line.indexOf(endToken, startIndex + startToken.length()); | |||
| if (endIndex < 0) { | |||
| startIndex += 1; | |||
| } else { | |||
| // grab the token | |||
| String token = line.substring(startIndex + startToken.length(), endIndex); | |||
| // If there is a white space or = or :, then | |||
| // it isn't to be treated as a valid key. | |||
| boolean validToken = true; | |||
| for (int k = 0; k < token.length() && validToken; k++) | |||
| { | |||
| char c = token.charAt(k); | |||
| if (c == ':' || c == '=' | |||
| || Character.isSpaceChar(c)) { | |||
| validToken = false; | |||
| } | |||
| } | |||
| if (!validToken) { | |||
| startIndex += 1; | |||
| } else { | |||
| // find the replace string | |||
| if (resourceMap.containsKey(token)) { | |||
| replace = (String) resourceMap.get(token); | |||
| } else { | |||
| replace = token; | |||
| } | |||
| // generate the new line | |||
| line = line.substring(0, startIndex) | |||
| + replace | |||
| + line.substring(endIndex + endToken.length()); | |||
| // set start position for next search | |||
| startIndex += replace.length(); | |||
| } | |||
| } | |||
| // find next starttoken | |||
| startIndex = line.indexOf(startToken, startIndex); | |||
| } | |||
| out.write(line); | |||
| @@ -761,10 +761,10 @@ public class JUnitTask extends Task { | |||
| /** | |||
| * @see Task#handleInput(byte[], int, int) | |||
| * | |||
| * | |||
| * @since Ant 1.6 | |||
| */ | |||
| protected int handleInput(byte[] buffer, int offset, int length) | |||
| protected int handleInput(byte[] buffer, int offset, int length) | |||
| throws IOException { | |||
| if (runner != null) { | |||
| return runner.handleInput(buffer, offset, length); | |||
| @@ -772,8 +772,8 @@ public class JUnitTask extends Task { | |||
| return super.handleInput(buffer, offset, length); | |||
| } | |||
| } | |||
| /** | |||
| * Pass output sent to System.out to the TestRunner so it can | |||
| * collect ot for the formatters. | |||
| @@ -847,7 +847,7 @@ public class JUnitTask extends Task { | |||
| } | |||
| if (commandline.getBootclasspath() != null) { | |||
| log("bootclasspath is ignored if running in the same VM.", | |||
| log("bootclasspath is ignored if running in the same VM.", | |||
| Project.MSG_WARN); | |||
| } | |||
| @@ -988,7 +988,7 @@ public class JUnitTask extends Task { | |||
| * @since Ant 1.4 | |||
| */ | |||
| protected void addClasspathEntry(String resource) { | |||
| /* | |||
| /* | |||
| * pre Ant 1.6 this method used to call getClass().getResource | |||
| * while Ant 1.6 will call ClassLoader.getResource(). | |||
| * | |||
| @@ -1003,7 +1003,7 @@ public class JUnitTask extends Task { | |||
| resource = "org/apache/tools/ant/taskdefs/optional/junit/" | |||
| + resource; | |||
| } | |||
| File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | |||
| resource); | |||
| if (f != null) { | |||
| @@ -64,11 +64,16 @@ import java.io.IOException; | |||
| * href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5273">Bug | |||
| * report 5273</a>.</p> | |||
| * | |||
| * @author Stefan Bodewig | |||
| * @author Stefan Bodewig | |||
| * @version $Revision$ | |||
| */ | |||
| public class ErrorInQuitException extends IOException { | |||
| /** | |||
| * Initialise from an IOException | |||
| * | |||
| * @param e the IO Exception. | |||
| */ | |||
| public ErrorInQuitException(IOException e) { | |||
| super(e.getMessage()); | |||
| } | |||
| @@ -23,7 +23,7 @@ if ""%1""=="""" goto doneStart | |||
| set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 | |||
| shift | |||
| goto setupArgs | |||
| rem This label provides a place for the argument list loop to break out | |||
| rem This label provides a place for the argument list loop to break out | |||
| rem and for NT handling to skip to. | |||
| :doneStart | |||
| @@ -55,13 +55,11 @@ goto end | |||
| :checkJava | |||
| set _JAVACMD=%JAVACMD% | |||
| set LOCALCLASSPATH=%CLASSPATH% | |||
| for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i | |||
| if "%JAVA_HOME%" == "" goto noJavaHome | |||
| if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome | |||
| if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe | |||
| if exist "%JAVA_HOME%\lib\tools.jar" set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%LOCALCLASSPATH% | |||
| if exist "%JAVA_HOME%\lib\classes.zip" set LOCALCLASSPATH=%JAVA_HOME%\lib\classes.zip;%LOCALCLASSPATH% | |||
| goto checkJikes | |||
| :noJavaHome | |||
| @@ -77,11 +75,11 @@ echo. | |||
| if not "%JIKESPATH%"=="" goto runAntWithJikes | |||
| :runAnt | |||
| "%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS% | |||
| "%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% | |||
| goto end | |||
| :runAntWithJikes | |||
| "%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS% | |||
| "%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% | |||
| goto end | |||
| :end | |||