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 | // make sure we aren't going to get the path separator next | ||||
if (!nextToken.equals(File.pathSeparator)) { | if (!nextToken.equals(File.pathSeparator)) { | ||||
if (nextToken.equals(":")) { | if (nextToken.equals(":")) { | ||||
if (!token.startsWith("/") && !token.startsWith("\\")){ | |||||
if (!token.startsWith("/") && !token.startsWith("\\")) { | |||||
// it indeed is a drive spec, get the next bit | // it indeed is a drive spec, get the next bit | ||||
String oneMore = tokenizer.nextToken().trim(); | String oneMore = tokenizer.nextToken().trim(); | ||||
if (!oneMore.equals(File.pathSeparator)) { | if (!oneMore.equals(File.pathSeparator)) { | ||||
@@ -55,7 +55,6 @@ package org.apache.tools.ant.filters; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.Reader; | import java.io.Reader; | ||||
import org.apache.tools.ant.types.Parameter; | |||||
/** | /** | ||||
* Converts non latin characters to unicode escapes | * Converts non latin characters to unicode escapes | ||||
@@ -66,7 +66,8 @@ import org.apache.tools.ant.types.Parameter; | |||||
* | * | ||||
* Or: | * 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 Steve Loughran | ||||
* @author Magesh Umasankar | * @author Magesh Umasankar | ||||
@@ -104,7 +104,8 @@ public class Mkdir extends Task { | |||||
/** | /** | ||||
* the directory to create; required. | * the directory to create; required. | ||||
* @param dir | |||||
* | |||||
* @param dir the directory to be made. | |||||
*/ | */ | ||||
public void setDir(File dir) { | public void setDir(File dir) { | ||||
this.dir = dir; | this.dir = dir; | ||||
@@ -94,6 +94,8 @@ public class Sequential extends Task | |||||
/** | /** | ||||
* Execute all nestedTasks. | * Execute all nestedTasks. | ||||
* | |||||
* @throws BuildException if one of the nested tasks fails. | |||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();) { | 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> | * getResource doesn't contain the name of the archive.</p> | ||||
*/ | */ | ||||
protected void addClasspathEntry(String resource) { | protected void addClasspathEntry(String resource) { | ||||
/* | |||||
/* | |||||
* pre Ant 1.6 this method used to call getClass().getResource | * pre Ant 1.6 this method used to call getClass().getResource | ||||
* while Ant 1.6 will call ClassLoader.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 = "org/apache/tools/ant/taskdefs/optional/" | ||||
+ resource; | + resource; | ||||
} | } | ||||
File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | ||||
resource); | resource); | ||||
if (f != null) { | if (f != null) { | ||||
@@ -302,13 +302,13 @@ public class ANTLR extends Task { | |||||
validateAttributes(); | validateAttributes(); | ||||
//TODO: use ANTLR to parse the grammar file to do this. | //TODO: use ANTLR to parse the grammar file to do this. | ||||
File generatedFile = getGeneratedFile(); | File generatedFile = getGeneratedFile(); | ||||
boolean targetIsOutOfDate = | |||||
boolean targetIsOutOfDate = | |||||
target.lastModified() > generatedFile.lastModified(); | target.lastModified() > generatedFile.lastModified(); | ||||
boolean superGrammarIsOutOfDate = superGrammar != null && | boolean superGrammarIsOutOfDate = superGrammar != null && | ||||
(superGrammar.lastModified() > generatedFile.lastModified()); | (superGrammar.lastModified() > generatedFile.lastModified()); | ||||
if (targetIsOutOfDate || superGrammarIsOutOfDate) { | if (targetIsOutOfDate || superGrammarIsOutOfDate) { | ||||
if (targetIsOutOfDate) { | if (targetIsOutOfDate) { | ||||
log("Compiling " + target + " as it is newer than " | |||||
log("Compiling " + target + " as it is newer than " | |||||
+ generatedFile, Project.MSG_VERBOSE); | + generatedFile, Project.MSG_VERBOSE); | ||||
} else if (superGrammarIsOutOfDate) { | } else if (superGrammarIsOutOfDate) { | ||||
log("Compiling " + target + " as " + superGrammar | log("Compiling " + target + " as " + superGrammar | ||||
@@ -329,7 +329,7 @@ public class ANTLR extends Task { | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
log("Skipped grammar file. Generated file " + generatedFile | |||||
log("Skipped grammar file. Generated file " + generatedFile | |||||
+ "is newer.", Project.MSG_VERBOSE); | + "is newer.", Project.MSG_VERBOSE); | ||||
} | } | ||||
} | } | ||||
@@ -410,10 +410,10 @@ public class ANTLR extends Task { | |||||
/** execute in a forked VM */ | /** execute in a forked VM */ | ||||
private int run(String[] command) throws BuildException { | private int run(String[] command) throws BuildException { | ||||
PumpStreamHandler psh = | |||||
PumpStreamHandler psh = | |||||
new PumpStreamHandler(new LogOutputStream(this, Project.MSG_INFO), | new PumpStreamHandler(new LogOutputStream(this, Project.MSG_INFO), | ||||
new TeeOutputStream( | new TeeOutputStream( | ||||
new LogOutputStream(this, | |||||
new LogOutputStream(this, | |||||
Project.MSG_WARN), | Project.MSG_WARN), | ||||
bos) | bos) | ||||
); | ); | ||||
@@ -83,71 +83,88 @@ public class Translate extends MatchingTask { | |||||
* Family name of resource bundle | * Family name of resource bundle | ||||
*/ | */ | ||||
private String bundle; | private String bundle; | ||||
/** | /** | ||||
* Locale specific language of the resource bundle | * Locale specific language of the resource bundle | ||||
*/ | */ | ||||
private String bundleLanguage; | private String bundleLanguage; | ||||
/** | /** | ||||
* Locale specific country of the resource bundle | * Locale specific country of the resource bundle | ||||
*/ | */ | ||||
private String bundleCountry; | private String bundleCountry; | ||||
/** | /** | ||||
* Locale specific variant of the resource bundle | * Locale specific variant of the resource bundle | ||||
*/ | */ | ||||
private String bundleVariant; | private String bundleVariant; | ||||
/** | /** | ||||
* Destination directory | * Destination directory | ||||
*/ | */ | ||||
private File toDir; | private File toDir; | ||||
/** | /** | ||||
* Source file encoding scheme | * Source file encoding scheme | ||||
*/ | */ | ||||
private String srcEncoding; | private String srcEncoding; | ||||
/** | /** | ||||
* Destination file encoding scheme | * Destination file encoding scheme | ||||
*/ | */ | ||||
private String destEncoding; | private String destEncoding; | ||||
/** | /** | ||||
* Resource Bundle file encoding scheme, defaults to srcEncoding | * Resource Bundle file encoding scheme, defaults to srcEncoding | ||||
*/ | */ | ||||
private String bundleEncoding; | private String bundleEncoding; | ||||
/** | /** | ||||
* Starting token to identify keys | * Starting token to identify keys | ||||
*/ | */ | ||||
private String startToken; | private String startToken; | ||||
/** | /** | ||||
* Ending token to identify keys | * Ending token to identify keys | ||||
*/ | */ | ||||
private String endToken; | private String endToken; | ||||
/** | /** | ||||
* Whether or not to create a new destination file. | * Whether or not to create a new destination file. | ||||
* Defaults to <code>false</code>. | * Defaults to <code>false</code>. | ||||
*/ | */ | ||||
private boolean forceOverwrite; | private boolean forceOverwrite; | ||||
/** | /** | ||||
* Vector to hold source file sets. | * Vector to hold source file sets. | ||||
*/ | */ | ||||
private Vector filesets = new Vector(); | private Vector filesets = new Vector(); | ||||
/** | /** | ||||
* Holds key value pairs loaded from resource bundle file | * Holds key value pairs loaded from resource bundle file | ||||
*/ | */ | ||||
private Hashtable resourceMap = new Hashtable(); | private Hashtable resourceMap = new Hashtable(); | ||||
/** | /** | ||||
* Used to resolve file names. | * Used to resolve file names. | ||||
*/ | */ | ||||
private FileUtils fileUtils = FileUtils.newFileUtils(); | private FileUtils fileUtils = FileUtils.newFileUtils(); | ||||
/** | /** | ||||
* Last Modified Timestamp of resource bundle file being used. | * Last Modified Timestamp of resource bundle file being used. | ||||
*/ | */ | ||||
private long[] bundleLastModified = new long[7]; | private long[] bundleLastModified = new long[7]; | ||||
/** | /** | ||||
* Last Modified Timestamp of source file being used. | * Last Modified Timestamp of source file being used. | ||||
*/ | */ | ||||
private long srcLastModified; | private long srcLastModified; | ||||
/** | /** | ||||
* Last Modified Timestamp of destination file being used. | * Last Modified Timestamp of destination file being used. | ||||
*/ | */ | ||||
private long destLastModified; | private long destLastModified; | ||||
/** | /** | ||||
* Has at least one file from the bundle been loaded? | * Has at least one file from the bundle been loaded? | ||||
*/ | */ | ||||
@@ -283,10 +300,8 @@ public class Translate extends MatchingTask { | |||||
if (!toDir.exists()) { | if (!toDir.exists()) { | ||||
toDir.mkdirs(); | 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) { | if (srcEncoding == null) { | ||||
@@ -509,63 +524,62 @@ public class Translate extends MatchingTask { | |||||
= new BufferedReader(new InputStreamReader(fis, srcEncoding)); | = new BufferedReader(new InputStreamReader(fis, srcEncoding)); | ||||
String line; | String line; | ||||
while ((line = in.readLine()) != null) { | 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); | out.write(line); | ||||
@@ -761,10 +761,10 @@ public class JUnitTask extends Task { | |||||
/** | /** | ||||
* @see Task#handleInput(byte[], int, int) | * @see Task#handleInput(byte[], int, int) | ||||
* | |||||
* | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
protected int handleInput(byte[] buffer, int offset, int length) | |||||
protected int handleInput(byte[] buffer, int offset, int length) | |||||
throws IOException { | throws IOException { | ||||
if (runner != null) { | if (runner != null) { | ||||
return runner.handleInput(buffer, offset, length); | return runner.handleInput(buffer, offset, length); | ||||
@@ -772,8 +772,8 @@ public class JUnitTask extends Task { | |||||
return super.handleInput(buffer, offset, length); | return super.handleInput(buffer, offset, length); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Pass output sent to System.out to the TestRunner so it can | * Pass output sent to System.out to the TestRunner so it can | ||||
* collect ot for the formatters. | * collect ot for the formatters. | ||||
@@ -847,7 +847,7 @@ public class JUnitTask extends Task { | |||||
} | } | ||||
if (commandline.getBootclasspath() != null) { | 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); | Project.MSG_WARN); | ||||
} | } | ||||
@@ -988,7 +988,7 @@ public class JUnitTask extends Task { | |||||
* @since Ant 1.4 | * @since Ant 1.4 | ||||
*/ | */ | ||||
protected void addClasspathEntry(String resource) { | protected void addClasspathEntry(String resource) { | ||||
/* | |||||
/* | |||||
* pre Ant 1.6 this method used to call getClass().getResource | * pre Ant 1.6 this method used to call getClass().getResource | ||||
* while Ant 1.6 will call ClassLoader.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 = "org/apache/tools/ant/taskdefs/optional/junit/" | ||||
+ resource; | + resource; | ||||
} | } | ||||
File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | File f = LoaderUtils.getResourceSource(getClass().getClassLoader(), | ||||
resource); | resource); | ||||
if (f != null) { | if (f != null) { | ||||
@@ -64,11 +64,16 @@ import java.io.IOException; | |||||
* href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5273">Bug | * href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5273">Bug | ||||
* report 5273</a>.</p> | * report 5273</a>.</p> | ||||
* | * | ||||
* @author Stefan Bodewig | |||||
* @author Stefan Bodewig | |||||
* @version $Revision$ | * @version $Revision$ | ||||
*/ | */ | ||||
public class ErrorInQuitException extends IOException { | public class ErrorInQuitException extends IOException { | ||||
/** | |||||
* Initialise from an IOException | |||||
* | |||||
* @param e the IO Exception. | |||||
*/ | |||||
public ErrorInQuitException(IOException e) { | public ErrorInQuitException(IOException e) { | ||||
super(e.getMessage()); | super(e.getMessage()); | ||||
} | } | ||||
@@ -23,7 +23,7 @@ if ""%1""=="""" goto doneStart | |||||
set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 | set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 | ||||
shift | shift | ||||
goto setupArgs | 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. | rem and for NT handling to skip to. | ||||
:doneStart | :doneStart | ||||
@@ -55,13 +55,11 @@ goto end | |||||
:checkJava | :checkJava | ||||
set _JAVACMD=%JAVACMD% | set _JAVACMD=%JAVACMD% | ||||
set LOCALCLASSPATH=%CLASSPATH% | set LOCALCLASSPATH=%CLASSPATH% | ||||
for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i | |||||
if "%JAVA_HOME%" == "" goto noJavaHome | if "%JAVA_HOME%" == "" goto noJavaHome | ||||
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome | if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome | ||||
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe | 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\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 | goto checkJikes | ||||
:noJavaHome | :noJavaHome | ||||
@@ -77,11 +75,11 @@ echo. | |||||
if not "%JIKESPATH%"=="" goto runAntWithJikes | if not "%JIKESPATH%"=="" goto runAntWithJikes | ||||
:runAnt | :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 | goto end | ||||
:runAntWithJikes | :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 | goto end | ||||
:end | :end | ||||