git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274857 13f79535-47bb-0310-9956-ffa450edef68master
@@ -65,8 +65,10 @@ import org.apache.tools.ant.util.FileUtils; | |||||
* | * | ||||
* @author Magesh Umasankar | * @author Magesh Umasankar | ||||
*/ | */ | ||||
public abstract class BaseFilterReader | |||||
extends FilterReader { | |||||
public abstract class BaseFilterReader extends FilterReader { | |||||
/** Buffer size used when reading */ | |||||
private static final int BUFFER_SIZE = 8192; | |||||
/** Have the parameters passed been interpreted? */ | /** Have the parameters passed been interpreted? */ | ||||
private boolean initialized = false; | private boolean initialized = false; | ||||
@@ -116,7 +118,7 @@ public abstract class BaseFilterReader | |||||
* | * | ||||
* @exception IOException If an I/O error occurs | * @exception IOException If an I/O error occurs | ||||
*/ | */ | ||||
public final int read(final char cbuf[], final int off, | |||||
public final int read(final char[] cbuf, final int off, | |||||
final int len) throws IOException { | final int len) throws IOException { | ||||
for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
final int ch = read(); | final int ch = read(); | ||||
@@ -232,6 +234,6 @@ public abstract class BaseFilterReader | |||||
* reading | * reading | ||||
*/ | */ | ||||
protected final String readFully() throws IOException { | protected final String readFully() throws IOException { | ||||
return FileUtils.readFully(in, 8192); | |||||
return FileUtils.readFully(in, BUFFER_SIZE); | |||||
} | } | ||||
} | } |
@@ -70,8 +70,7 @@ import org.apache.tools.ant.types.Parameter; | |||||
* | * | ||||
* @author Magesh Umasankar | * @author Magesh Umasankar | ||||
*/ | */ | ||||
public final class HeadFilter | |||||
extends BaseParamFilterReader | |||||
public final class HeadFilter extends BaseParamFilterReader | |||||
implements ChainableReader { | implements ChainableReader { | ||||
/** Parameter name for the number of lines to be returned. */ | /** Parameter name for the number of lines to be returned. */ | ||||
private static final String LINES_KEY = "lines"; | private static final String LINES_KEY = "lines"; | ||||
@@ -83,7 +82,7 @@ public final class HeadFilter | |||||
private long linesRead = 0; | private long linesRead = 0; | ||||
/** Default number of lines to show */ | /** Default number of lines to show */ | ||||
private static int DEFAULT_NUM_LINES = 10; | |||||
private static final int DEFAULT_NUM_LINES = 10; | |||||
/** Number of lines to be returned in the filtered stream. */ | /** Number of lines to be returned in the filtered stream. */ | ||||
private long lines = DEFAULT_NUM_LINES; | private long lines = DEFAULT_NUM_LINES; | ||||
@@ -62,6 +62,8 @@ import java.io.Reader; | |||||
* (if you have more complex Java parsing needs, use a real lexer). | * (if you have more complex Java parsing needs, use a real lexer). | ||||
* Since this class heavily relies on the single char read function, | * Since this class heavily relies on the single char read function, | ||||
* you are reccomended to make it work on top of a buffered reader. | * you are reccomended to make it work on top of a buffered reader. | ||||
* | |||||
* @author Not Specified. | |||||
*/ | */ | ||||
public final class StripJavaComments | public final class StripJavaComments | ||||
extends BaseFilterReader | extends BaseFilterReader | ||||
@@ -73,8 +73,7 @@ import org.apache.tools.ant.types.Parameter; | |||||
* | * | ||||
* @author Magesh Umasankar | * @author Magesh Umasankar | ||||
*/ | */ | ||||
public final class TailFilter | |||||
extends BaseParamFilterReader | |||||
public final class TailFilter extends BaseParamFilterReader | |||||
implements ChainableReader { | implements ChainableReader { | ||||
/** Parameter name for the number of lines to be returned. */ | /** Parameter name for the number of lines to be returned. */ | ||||
private static final String LINES_KEY = "lines"; | private static final String LINES_KEY = "lines"; | ||||
@@ -85,8 +84,11 @@ public final class TailFilter | |||||
/** Number of lines currently read in. */ | /** Number of lines currently read in. */ | ||||
private long linesRead = 0; | private long linesRead = 0; | ||||
/** Default number of lines to show */ | |||||
private static final int DEFAULT_NUM_LINES = 10; | |||||
/** Number of lines to be returned in the filtered stream. */ | /** Number of lines to be returned in the filtered stream. */ | ||||
private long lines = 10; | |||||
private long lines = DEFAULT_NUM_LINES; | |||||
/** Number of lines to be skipped. */ | /** Number of lines to be skipped. */ | ||||
private long skip = 0; | private long skip = 0; | ||||
@@ -150,15 +152,17 @@ public final class TailFilter | |||||
while (line == null || line.length() == 0) { | while (line == null || line.length() == 0) { | ||||
line = lineTokenizer.getToken(in); | line = lineTokenizer.getToken(in); | ||||
line = tailFilter(line); | line = tailFilter(line); | ||||
if (line == null) | |||||
if (line == null) { | |||||
return -1; | return -1; | ||||
} | |||||
linePos = 0; | linePos = 0; | ||||
} | } | ||||
int ch = line.charAt(linePos); | int ch = line.charAt(linePos); | ||||
linePos++; | linePos++; | ||||
if (linePos == line.length()) | |||||
if (linePos == line.length()) { | |||||
line = null; | line = null; | ||||
} | |||||
return ch; | return ch; | ||||
} | } | ||||
@@ -183,7 +187,7 @@ public final class TailFilter | |||||
/** | /** | ||||
* Sets the number of lines to be skipped in the filtered stream. | * Sets the number of lines to be skipped in the filtered stream. | ||||
* | * | ||||
* @param lines the number of lines to be skipped in the filtered stream | |||||
* @param skip the number of lines to be skipped in the filtered stream | |||||
*/ | */ | ||||
public final void setSkip(final long skip) { | public final void setSkip(final long skip) { | ||||
this.skip = skip; | this.skip = skip; | ||||
@@ -245,7 +249,7 @@ public final class TailFilter | |||||
* null at the end of outputting the lines | * null at the end of outputting the lines | ||||
*/ | */ | ||||
private String tailFilter(String line) { | private String tailFilter(String line) { | ||||
if (! completedReadAhead) { | |||||
if (!completedReadAhead) { | |||||
if (line != null) { | if (line != null) { | ||||
lineList.add(line); | lineList.add(line); | ||||
if (lines == -1) { | if (lines == -1) { | ||||
@@ -178,8 +178,8 @@ public final class ChainReaderHelper { | |||||
} | } | ||||
if (clazz != null) { | if (clazz != null) { | ||||
if (!FilterReader.class.isAssignableFrom(clazz)) { | if (!FilterReader.class.isAssignableFrom(clazz)) { | ||||
throw new BuildException(className + | |||||
" does not extend java.io.FilterReader"); | |||||
throw new BuildException(className | |||||
+ " does not extend java.io.FilterReader"); | |||||
} | } | ||||
final Constructor[] constructors = | final Constructor[] constructors = | ||||
clazz.getConstructors(); | clazz.getConstructors(); | ||||
@@ -188,16 +188,17 @@ public final class ChainReaderHelper { | |||||
for (; j < constructors.length; j++) { | for (; j < constructors.length; j++) { | ||||
Class[] types = constructors[j] | Class[] types = constructors[j] | ||||
.getParameterTypes(); | .getParameterTypes(); | ||||
if (types.length == 1 && | |||||
types[0].isAssignableFrom(Reader.class)) { | |||||
if (types.length == 1 | |||||
&& types[0].isAssignableFrom(Reader.class)) { | |||||
consPresent = true; | consPresent = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ( !consPresent) { | |||||
throw new BuildException( className + | |||||
" does not define a public constructor" + | |||||
" that takes in a Reader as its single argument."); | |||||
if (!consPresent) { | |||||
throw new BuildException(className | |||||
+ " does not define a public constructor" | |||||
+ " that takes in a Reader as its " | |||||
+ "single argument."); | |||||
} | } | ||||
final Reader[] rdr = {instream}; | final Reader[] rdr = {instream}; | ||||
instream = | instream = | ||||
@@ -235,13 +236,14 @@ public final class ChainReaderHelper { | |||||
* classes, even if they have public methods. | * classes, even if they have public methods. | ||||
*/ | */ | ||||
private void setProjectOnObject(Object obj) { | private void setProjectOnObject(Object obj) { | ||||
if (project == null) | |||||
if (project == null) { | |||||
return; | return; | ||||
} | |||||
if (obj instanceof BaseFilterReader) { | if (obj instanceof BaseFilterReader) { | ||||
((BaseFilterReader) obj).setProject(project); | ((BaseFilterReader) obj).setProject(project); | ||||
return; | return; | ||||
} | } | ||||
project.setProjectReference( obj ); | |||||
project.setProjectReference(obj); | |||||
} | } | ||||
/** | /** | ||||
@@ -146,7 +146,9 @@ public class Untar extends Expand { | |||||
if (tis != null) { | if (tis != null) { | ||||
try { | try { | ||||
tis.close(); | tis.close(); | ||||
} catch (IOException e) {} | |||||
} catch (IOException e) { | |||||
// ignore | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -187,7 +189,7 @@ public class Untar extends Expand { | |||||
* @return valid values | * @return valid values | ||||
*/ | */ | ||||
public String[] getValues() { | public String[] getValues() { | ||||
return new String[] { NONE, GZIP, BZIP2 }; | |||||
return new String[] {NONE, GZIP, BZIP2}; | |||||
} | } | ||||
/** | /** | ||||
@@ -88,10 +88,11 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
*/ | */ | ||||
public class WaitFor extends ConditionBase { | public class WaitFor extends ConditionBase { | ||||
private long maxWaitMillis = 1000l * 60l * 3l; // default max wait time | |||||
private long maxWaitMultiplier = 1l; | |||||
private long checkEveryMillis = 500l; | |||||
private long checkEveryMultiplier = 1l; | |||||
/** default max wait time */ | |||||
private long maxWaitMillis = 1000L * 60L * 3L; | |||||
private long maxWaitMultiplier = 1L; | |||||
private long checkEveryMillis = 500L; | |||||
private long checkEveryMultiplier = 1L; | |||||
private String timeoutProperty; | private String timeoutProperty; | ||||
/** | /** | ||||
@@ -159,6 +160,7 @@ public class WaitFor extends ConditionBase { | |||||
try { | try { | ||||
Thread.sleep(checkEveryMillis); | Thread.sleep(checkEveryMillis); | ||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
// ignore | |||||
} | } | ||||
} | } | ||||
@@ -192,12 +194,12 @@ public class WaitFor extends ConditionBase { | |||||
private Hashtable timeTable = new Hashtable(); | private Hashtable timeTable = new Hashtable(); | ||||
public Unit() { | public Unit() { | ||||
timeTable.put(MILLISECOND, new Long(1l)); | |||||
timeTable.put(SECOND, new Long(1000l)); | |||||
timeTable.put(MINUTE, new Long(1000l * 60l)); | |||||
timeTable.put(HOUR, new Long(1000l * 60l * 60l)); | |||||
timeTable.put(DAY, new Long(1000l * 60l * 60l * 24l)); | |||||
timeTable.put(WEEK, new Long(1000l * 60l * 60l * 24l * 7l)); | |||||
timeTable.put(MILLISECOND, new Long(1L)); | |||||
timeTable.put(SECOND, new Long(1000L)); | |||||
timeTable.put(MINUTE, new Long(1000L * 60L)); | |||||
timeTable.put(HOUR, new Long(1000L * 60L * 60L)); | |||||
timeTable.put(DAY, new Long(1000L * 60L * 60L * 24L)); | |||||
timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L)); | |||||
} | } | ||||
public long getMultiplier() { | public long getMultiplier() { | ||||
@@ -390,12 +390,12 @@ public class CSharp extends DotnetCompile { | |||||
*@return The Definitions Parameter to CSC | *@return The Definitions Parameter to CSC | ||||
*/ | */ | ||||
protected String getDefinitionsParameter() { | protected String getDefinitionsParameter() { | ||||
String predecessors=super.getDefinitionsParameter(); | |||||
String predecessors = super.getDefinitionsParameter(); | |||||
if (notEmpty(definitions)) { | if (notEmpty(definitions)) { | ||||
if (predecessors==null) { | |||||
predecessors= "/define:"; | |||||
if (predecessors == null) { | |||||
predecessors = "/define:"; | |||||
} | } | ||||
return predecessors+ definitions; | |||||
return predecessors + definitions; | |||||
} else { | } else { | ||||
return predecessors; | return predecessors; | ||||
} | } | ||||
@@ -132,8 +132,9 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
* @return number of files out of date | * @return number of files out of date | ||||
*/ | */ | ||||
protected int buildFileList(NetCommand command, Hashtable filesToBuild, long outputTimestamp) { | protected int buildFileList(NetCommand command, Hashtable filesToBuild, long outputTimestamp) { | ||||
int filesOutOfDate=0; | |||||
boolean scanImplicitFileset=getSrcDir()!=null || filesets.size()==0; | |||||
int filesOutOfDate = 0; | |||||
boolean scanImplicitFileset | |||||
= getSrcDir() != null || filesets.size() == 0; | |||||
if (scanImplicitFileset) { | if (scanImplicitFileset) { | ||||
//scan for an implicit fileset if there was a srcdir set | //scan for an implicit fileset if there was a srcdir set | ||||
//or there was no srcDir set but the @ | //or there was no srcDir set but the @ | ||||
@@ -151,7 +152,7 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
//get any included source directories | //get any included source directories | ||||
for (int i = 0; i < filesets.size(); i++) { | for (int i = 0; i < filesets.size(); i++) { | ||||
FileSet fs = (FileSet) filesets.elementAt(i); | FileSet fs = (FileSet) filesets.elementAt(i); | ||||
filesOutOfDate+= command.scanOneFileset( | |||||
filesOutOfDate += command.scanOneFileset( | |||||
fs.getDirectoryScanner(getProject()), | fs.getDirectoryScanner(getProject()), | ||||
filesToBuild, | filesToBuild, | ||||
outputTimestamp); | outputTimestamp); | ||||
@@ -166,9 +167,9 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
* @param command the command to append to | * @param command the command to append to | ||||
*/ | */ | ||||
protected void addFilesToCommand(Hashtable filesToBuild, NetCommand command) { | protected void addFilesToCommand(Hashtable filesToBuild, NetCommand command) { | ||||
int count=filesToBuild.size(); | |||||
log("compiling " + count + " file" + ((count== 1) ? "" : "s")); | |||||
Enumeration files=filesToBuild.elements(); | |||||
int count = filesToBuild.size(); | |||||
log("compiling " + count + " file" + ((count == 1) ? "" : "s")); | |||||
Enumeration files = filesToBuild.elements(); | |||||
while (files.hasMoreElements()) { | while (files.hasMoreElements()) { | ||||
File file = (File) files.nextElement(); | File file = (File) files.nextElement(); | ||||
command.addArgument(file.toString()); | command.addArgument(file.toString()); | ||||
@@ -195,8 +196,8 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
*/ | */ | ||||
protected void addFilesAndExecute(NetCommand command, boolean ignoreTimestamps) { | protected void addFilesAndExecute(NetCommand command, boolean ignoreTimestamps) { | ||||
long outputTimestamp = getOutputFileTimestamp(); | long outputTimestamp = getOutputFileTimestamp(); | ||||
Hashtable filesToBuild =new Hashtable(); | |||||
int filesOutOfDate = buildFileList(command,filesToBuild, outputTimestamp); | |||||
Hashtable filesToBuild = new Hashtable(); | |||||
int filesOutOfDate = buildFileList(command, filesToBuild, outputTimestamp); | |||||
//add the files to the command | //add the files to the command | ||||
addFilesToCommand(filesToBuild, command); | addFilesToCommand(filesToBuild, command); | ||||
@@ -206,7 +207,7 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
if (filesOutOfDate > 0) { | if (filesOutOfDate > 0) { | ||||
command.runCommand(); | command.runCommand(); | ||||
} else { | } else { | ||||
log("output file is up to date",Project.MSG_VERBOSE); | |||||
log("output file is up to date", Project.MSG_VERBOSE); | |||||
} | } | ||||
} | } | ||||
@@ -192,7 +192,7 @@ public abstract class DotnetCompile | |||||
"System.Windows.Forms.dll", | "System.Windows.Forms.dll", | ||||
"System.XML.dll"}; | "System.XML.dll"}; | ||||
protected static final String REFERENCE_OPTION= "/reference:"; | |||||
protected static final String REFERENCE_OPTION = "/reference:"; | |||||
/** | /** | ||||
* debug flag. Controls generation of debug information. | * debug flag. Controls generation of debug information. | ||||
@@ -235,7 +235,7 @@ public abstract class DotnetCompile | |||||
/** | /** | ||||
* filesets of references | * filesets of references | ||||
*/ | */ | ||||
protected Vector referenceFilesets =new Vector(); | |||||
protected Vector referenceFilesets = new Vector(); | |||||
/** | /** | ||||
@@ -558,7 +558,7 @@ public abstract class DotnetCompile | |||||
*@param dirName The new DestDir value | *@param dirName The new DestDir value | ||||
*/ | */ | ||||
public void setDestDir(File dirName) { | public void setDestDir(File dirName) { | ||||
log( "DestDir currently unused", Project.MSG_WARN ); | |||||
log("DestDir currently unused", Project.MSG_WARN); | |||||
} | } | ||||
@@ -567,7 +567,7 @@ public abstract class DotnetCompile | |||||
* @param targetType | * @param targetType | ||||
*/ | */ | ||||
public void setTargetType(TargetTypes targetType) { | public void setTargetType(TargetTypes targetType) { | ||||
this.targetType=targetType.getValue(); | |||||
this.targetType = targetType.getValue(); | |||||
} | } | ||||
/** | /** | ||||
* Set the type of target. | * Set the type of target. | ||||
@@ -579,12 +579,12 @@ public abstract class DotnetCompile | |||||
public void setTargetType(String ttype) | public void setTargetType(String ttype) | ||||
throws BuildException { | throws BuildException { | ||||
ttype = ttype.toLowerCase(); | ttype = ttype.toLowerCase(); | ||||
if (ttype.equals("exe") || ttype.equals("library") || | |||||
ttype.equals("module") || ttype.equals("winexe")) { | |||||
if (ttype.equals("exe") || ttype.equals("library") | |||||
|| ttype.equals("module") || ttype.equals("winexe")) { | |||||
targetType = ttype; | targetType = ttype; | ||||
} else { | } else { | ||||
throw new BuildException("targetType " + ttype | throw new BuildException("targetType " + ttype | ||||
+ " is not one of 'exe', 'module', 'winexe' or 'library'" ); | |||||
+ " is not one of 'exe', 'module', 'winexe' or 'library'"); | |||||
} | } | ||||
} | } | ||||
@@ -706,8 +706,8 @@ public abstract class DotnetCompile | |||||
* @return a string beginning /D: or null for no definitions | * @return a string beginning /D: or null for no definitions | ||||
*/ | */ | ||||
protected String getDefinitionsParameter() throws BuildException { | protected String getDefinitionsParameter() throws BuildException { | ||||
StringBuffer defines=new StringBuffer(); | |||||
Enumeration defEnum=definitionList.elements(); | |||||
StringBuffer defines = new StringBuffer(); | |||||
Enumeration defEnum = definitionList.elements(); | |||||
while (defEnum.hasMoreElements()) { | while (defEnum.hasMoreElements()) { | ||||
//loop through all definitions | //loop through all definitions | ||||
DotnetDefine define = (DotnetDefine) defEnum.nextElement(); | DotnetDefine define = (DotnetDefine) defEnum.nextElement(); | ||||
@@ -717,10 +717,10 @@ public abstract class DotnetCompile | |||||
defines.append(getDefinitionsDelimiter()); | defines.append(getDefinitionsDelimiter()); | ||||
} | } | ||||
} | } | ||||
if (defines.length()==0) { | |||||
if (defines.length() == 0) { | |||||
return null; | return null; | ||||
} else { | } else { | ||||
return "/D:"+defines; | |||||
return "/D:" + defines; | |||||
} | } | ||||
} | } | ||||
@@ -847,10 +847,10 @@ public abstract class DotnetCompile | |||||
fillInSharedParameters(command); | fillInSharedParameters(command); | ||||
addResources(command); | addResources(command); | ||||
addCompilerSpecificOptions(command); | addCompilerSpecificOptions(command); | ||||
int referencesOutOfDate=addReferenceFilesets(command, | |||||
getOutputFileTimestamp()); | |||||
int referencesOutOfDate | |||||
= addReferenceFilesets(command, getOutputFileTimestamp()); | |||||
//if the refs are out of date, force a build. | //if the refs are out of date, force a build. | ||||
boolean forceBuild= referencesOutOfDate > 0; | |||||
boolean forceBuild = referencesOutOfDate > 0; | |||||
addFilesAndExecute(command, forceBuild); | addFilesAndExecute(command, forceBuild); | ||||
} | } | ||||
@@ -903,7 +903,7 @@ public abstract class DotnetCompile | |||||
* resource setting | * resource setting | ||||
*/ | */ | ||||
protected void addResources(NetCommand command) { | protected void addResources(NetCommand command) { | ||||
Enumeration e=resources.elements(); | |||||
Enumeration e = resources.elements(); | |||||
while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
DotnetResource resource = (DotnetResource) e.nextElement(); | DotnetResource resource = (DotnetResource) e.nextElement(); | ||||
command.addArgument(createResourceParameter(resource)); | command.addArgument(createResourceParameter(resource)); | ||||
@@ -927,7 +927,7 @@ public abstract class DotnetCompile | |||||
protected int addReferenceFilesets(NetCommand command, long outputTimestamp) { | protected int addReferenceFilesets(NetCommand command, long outputTimestamp) { | ||||
int filesOutOfDate = 0; | int filesOutOfDate = 0; | ||||
Hashtable filesToBuild=new Hashtable(); | |||||
Hashtable filesToBuild = new Hashtable(); | |||||
for (int i = 0; i < referenceFilesets.size(); i++) { | for (int i = 0; i < referenceFilesets.size(); i++) { | ||||
FileSet fs = (FileSet) referenceFilesets.elementAt(i); | FileSet fs = (FileSet) referenceFilesets.elementAt(i); | ||||
filesOutOfDate += command.scanOneFileset( | filesOutOfDate += command.scanOneFileset( | ||||
@@ -936,10 +936,10 @@ public abstract class DotnetCompile | |||||
outputTimestamp); | outputTimestamp); | ||||
} | } | ||||
//bail out early if there were no files | //bail out early if there were no files | ||||
if (filesToBuild.size()==0) { | |||||
if (filesToBuild.size() == 0) { | |||||
return 0; | return 0; | ||||
} | } | ||||
StringBuffer referenceList= new StringBuffer(REFERENCE_OPTION); | |||||
StringBuffer referenceList = new StringBuffer(REFERENCE_OPTION); | |||||
//now scan the hashtable and add the files | //now scan the hashtable and add the files | ||||
Enumeration files = filesToBuild.elements(); | Enumeration files = filesToBuild.elements(); | ||||
while (files.hasMoreElements()) { | while (files.hasMoreElements()) { | ||||
@@ -948,7 +948,7 @@ public abstract class DotnetCompile | |||||
referenceList.append(file.toString()); | referenceList.append(file.toString()); | ||||
referenceList.append(getReferenceDelimiter()); | referenceList.append(getReferenceDelimiter()); | ||||
} else { | } else { | ||||
log("ignoring "+file+" as it is not a managed executable", | |||||
log("ignoring " + file + " as it is not a managed executable", | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
@@ -989,7 +989,7 @@ public abstract class DotnetCompile | |||||
* @todo look at the PE header of the exe and see if it is managed or not. | * @todo look at the PE header of the exe and see if it is managed or not. | ||||
*/ | */ | ||||
protected static boolean isFileManagedBinary(File file) { | protected static boolean isFileManagedBinary(File file) { | ||||
String filename= file.toString().toLowerCase(); | |||||
String filename = file.toString().toLowerCase(); | |||||
return filename.endsWith(".exe") || filename.endsWith(".dll") | return filename.endsWith(".exe") || filename.endsWith(".dll") | ||||
|| filename.endsWith(".netmodule"); | || filename.endsWith(".netmodule"); | ||||
} | } | ||||
@@ -106,7 +106,7 @@ public class DotnetDefine { | |||||
* @throws BuildException | * @throws BuildException | ||||
*/ | */ | ||||
public String getValue(Task owner) throws BuildException { | public String getValue(Task owner) throws BuildException { | ||||
if (name==null) { | |||||
if (name == null) { | |||||
throw new BuildException("No name provided for the define element", | throw new BuildException("No name provided for the define element", | ||||
owner.getLocation()); | owner.getLocation()); | ||||
} | } | ||||
@@ -123,7 +123,7 @@ public class DotnetDefine { | |||||
* @return true if the condition is valid | * @return true if the condition is valid | ||||
*/ | */ | ||||
public boolean isSet(Task owner) { | public boolean isSet(Task owner) { | ||||
Project p=owner.getProject(); | |||||
Project p = owner.getProject(); | |||||
if (ifCond != null && p.getProperty(ifCond) == null) { | if (ifCond != null && p.getProperty(ifCond) == null) { | ||||
return false; | return false; | ||||
} else if (unlessCond != null && p.getProperty(unlessCond) != null) { | } else if (unlessCond != null && p.getProperty(unlessCond) != null) { | ||||
@@ -160,10 +160,11 @@ public class Ilasm | |||||
* any extra command options? | * any extra command options? | ||||
*/ | */ | ||||
protected String extraOptions; | protected String extraOptions; | ||||
/** | /** | ||||
* filesets of references | * filesets of references | ||||
*/ | */ | ||||
protected Vector referenceFilesets =new Vector(); | |||||
protected Vector referenceFilesets = new Vector(); | |||||
/** | /** | ||||
@@ -245,7 +246,8 @@ public class Ilasm | |||||
* @ant.attribute ignore="true" | * @ant.attribute ignore="true" | ||||
*/ | */ | ||||
public void setOwner(String s) { | public void setOwner(String s) { | ||||
log("This option is not supported by ILASM as of Beta-2, and will be ignored", Project.MSG_WARN); | |||||
log("This option is not supported by ILASM as of Beta-2, " | |||||
+ "and will be ignored", Project.MSG_WARN); | |||||
} | } | ||||
@@ -523,7 +525,7 @@ public class Ilasm | |||||
* @todo look at the PE header of the exe and see if it is managed or not. | * @todo look at the PE header of the exe and see if it is managed or not. | ||||
*/ | */ | ||||
protected static boolean isFileManagedBinary(File file) { | protected static boolean isFileManagedBinary(File file) { | ||||
String filename= file.toString().toLowerCase(); | |||||
String filename = file.toString().toLowerCase(); | |||||
return filename.endsWith(".exe") || filename.endsWith(".dll") | return filename.endsWith(".exe") || filename.endsWith(".dll") | ||||
|| filename.endsWith(".netmodule"); | || filename.endsWith(".netmodule"); | ||||
} | } | ||||
@@ -89,17 +89,17 @@ public class ImportTypelib extends Task { | |||||
/** | /** | ||||
* /sysarray | * /sysarray | ||||
*/ | */ | ||||
private boolean useSysArray=false; | |||||
private boolean useSysArray = false; | |||||
/** | /** | ||||
* /unsafe | * /unsafe | ||||
*/ | */ | ||||
private boolean unsafe=false; | |||||
private boolean unsafe = false; | |||||
/** | /** | ||||
* extra commands? | * extra commands? | ||||
*/ | */ | ||||
private String extraOptions=null; | |||||
private String extraOptions = null; | |||||
/** | /** | ||||
* name the output file. required | * name the output file. required | ||||
@@ -170,7 +170,7 @@ public class ImportTypelib extends Task { | |||||
throw new BuildException( | throw new BuildException( | ||||
"source file is a directory"); | "source file is a directory"); | ||||
} | } | ||||
if (namespace==null) { | |||||
if (namespace == null) { | |||||
throw new BuildException("No namespace"); | throw new BuildException("No namespace"); | ||||
} | } | ||||
} | } | ||||
@@ -181,13 +181,13 @@ public class ImportTypelib extends Task { | |||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
validate(); | validate(); | ||||
log("Importing typelib "+srcFile | |||||
+" to assembly "+destFile | |||||
+" in namespace "+namespace, Project.MSG_VERBOSE); | |||||
log("Importing typelib " + srcFile | |||||
+ " to assembly " + destFile | |||||
+ " in namespace " + namespace, Project.MSG_VERBOSE); | |||||
//rebuild unless the dest file is newer than the source file | //rebuild unless the dest file is newer than the source file | ||||
if (srcFile.exists() && destFile.exists() && | |||||
srcFile.lastModified() <= destFile.lastModified()) { | |||||
log("The typelib is up to date",Project.MSG_VERBOSE); | |||||
if (srcFile.exists() && destFile.exists() | |||||
&& srcFile.lastModified() <= destFile.lastModified()) { | |||||
log("The typelib is up to date", Project.MSG_VERBOSE); | |||||
return; | return; | ||||
} | } | ||||
@@ -205,7 +205,5 @@ public class ImportTypelib extends Task { | |||||
command.addArgument("/unsafe"); | command.addArgument("/unsafe"); | ||||
} | } | ||||
command.addArgument(extraOptions); | command.addArgument(extraOptions); | ||||
} | } | ||||
} | } |
@@ -210,7 +210,7 @@ public class NetCommand { | |||||
if (argument2 != null && argument2.length() != 0) { | if (argument2 != null && argument2.length() != 0) { | ||||
commandLine.createArgument().setValue(argument1 + argument2); | commandLine.createArgument().setValue(argument1 + argument2); | ||||
} | } | ||||
} | |||||
} | |||||
/** | /** | ||||
* set up the command sequence.. | * set up the command sequence.. | ||||
@@ -218,10 +218,10 @@ public class NetCommand { | |||||
protected void prepareExecutor() { | protected void prepareExecutor() { | ||||
// default directory to the project's base directory | // default directory to the project's base directory | ||||
if (owner == null) { | if (owner == null) { | ||||
throw new RuntimeException("no owner"); | |||||
throw new RuntimeException("no owner"); | |||||
} | } | ||||
if (owner.getProject() == null) { | if (owner.getProject() == null) { | ||||
throw new RuntimeException("Owner has no project"); | |||||
throw new RuntimeException("Owner has no project"); | |||||
} | } | ||||
File dir = owner.getProject().getBaseDir(); | File dir = owner.getProject().getBaseDir(); | ||||
ExecuteStreamHandler handler = new LogStreamHandler(owner, | ExecuteStreamHandler handler = new LogStreamHandler(owner, | ||||
@@ -213,7 +213,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||||
/** | /** | ||||
* Specifies the root namespace for all type declarations. | * Specifies the root namespace for all type declarations. | ||||
* @param a root namespace. | |||||
* @param rootNamespace a root namespace. | |||||
*/ | */ | ||||
public void setRootNamespace(String rootNamespace) { | public void setRootNamespace(String rootNamespace) { | ||||
this.rootNamespace = rootNamespace; | this.rootNamespace = rootNamespace; | ||||
@@ -364,7 +364,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||||
protected void validate() | protected void validate() | ||||
throws BuildException { | throws BuildException { | ||||
super.validate(); | super.validate(); | ||||
if (getDestFile()==null) { | |||||
if (getDestFile() == null) { | |||||
throw new BuildException("DestFile was not specified"); | throw new BuildException("DestFile was not specified"); | ||||
} | } | ||||
} | } | ||||
@@ -239,17 +239,17 @@ public class WsdlToDotnet extends Task { | |||||
//set source and rebuild options | //set source and rebuild options | ||||
boolean rebuild = true; | boolean rebuild = true; | ||||
if (srcFile!=null) { | |||||
if (srcFile != null) { | |||||
command.addArgument(srcFile.toString()); | command.addArgument(srcFile.toString()); | ||||
//rebuild unless the dest file is newer than the source file | //rebuild unless the dest file is newer than the source file | ||||
if (srcFile.exists() && destFile.exists() && | |||||
srcFile.lastModified() <= destFile.lastModified()) { | |||||
if (srcFile.exists() && destFile.exists() | |||||
&& srcFile.lastModified() <= destFile.lastModified()) { | |||||
rebuild = false; | rebuild = false; | ||||
} | } | ||||
} else { | } else { | ||||
//no source file? must be a url, which has no dependency | //no source file? must be a url, which has no dependency | ||||
//handling | //handling | ||||
rebuild=true; | |||||
rebuild = true; | |||||
command.addArgument(url); | command.addArgument(url); | ||||
} | } | ||||
if (rebuild) { | if (rebuild) { | ||||
@@ -71,7 +71,7 @@ import org.apache.tools.ant.Project; | |||||
* <p>Moved out of MatchingTask to make it a standalone object that | * <p>Moved out of MatchingTask to make it a standalone object that | ||||
* could be referenced (by scripts for example). | * could be referenced (by scripts for example). | ||||
* | * | ||||
* @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||||
* @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||||
* @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | ||||
* @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> | * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> | ||||
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | ||||
@@ -85,7 +85,7 @@ public class PatternSet extends DataType { | |||||
/** | /** | ||||
* inner class to hold a name on list. "If" and "Unless" attributes | * inner class to hold a name on list. "If" and "Unless" attributes | ||||
* may be used to invalidate the entry based on the existence of a | |||||
* may be used to invalidate the entry based on the existence of a | |||||
* property (typically set thru the use of the Available task). | * property (typically set thru the use of the Available task). | ||||
*/ | */ | ||||
public class NameEntry { | public class NameEntry { | ||||
@@ -93,8 +93,8 @@ public class PatternSet extends DataType { | |||||
private String ifCond; | private String ifCond; | ||||
private String unlessCond; | private String unlessCond; | ||||
public void setName(String name) { | |||||
this.name = name; | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | } | ||||
public void setIf(String cond) { | public void setIf(String cond) { | ||||
@@ -109,8 +109,8 @@ public class PatternSet extends DataType { | |||||
return name; | return name; | ||||
} | } | ||||
public String evalName(Project p) { | |||||
return valid(p) ? name : null; | |||||
public String evalName(Project p) { | |||||
return valid(p) ? name : null; | |||||
} | } | ||||
private boolean valid(Project p) { | private boolean valid(Project p) { | ||||
@@ -127,7 +127,7 @@ public class PatternSet extends DataType { | |||||
if ((ifCond != null) || (unlessCond != null)) { | if ((ifCond != null) || (unlessCond != null)) { | ||||
buf.append(":"); | buf.append(":"); | ||||
String connector = ""; | String connector = ""; | ||||
if (ifCond != null) { | if (ifCond != null) { | ||||
buf.append("if->"); | buf.append("if->"); | ||||
buf.append(ifCond); | buf.append(ifCond); | ||||
@@ -153,7 +153,7 @@ public class PatternSet extends DataType { | |||||
* instance. | * instance. | ||||
* | * | ||||
* <p>You must not set another attribute or nest elements inside | * <p>You must not set another attribute or nest elements inside | ||||
* this element if you make it a reference.</p> | |||||
* this element if you make it a reference.</p> | |||||
*/ | */ | ||||
public void setRefid(Reference r) throws BuildException { | public void setRefid(Reference r) throws BuildException { | ||||
if (!includeList.isEmpty() || !excludeList.isEmpty()) { | if (!includeList.isEmpty() || !excludeList.isEmpty()) { | ||||
@@ -202,7 +202,7 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
return addPatternToList(includesFileList); | return addPatternToList(includesFileList); | ||||
} | } | ||||
/** | /** | ||||
* add a name entry on the exclude list | * add a name entry on the exclude list | ||||
*/ | */ | ||||
@@ -212,7 +212,7 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
return addPatternToList(excludeList); | return addPatternToList(excludeList); | ||||
} | } | ||||
/** | /** | ||||
* add a name entry on the exclude files list | * add a name entry on the exclude files list | ||||
*/ | */ | ||||
@@ -224,7 +224,7 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
/** | /** | ||||
* Appends <code>includes</code> to the current list of include patterns. | |||||
* Appends <code>includes</code> to the current list of include patterns. | |||||
* Patterns may be separated by a comma or a space. | * Patterns may be separated by a comma or a space. | ||||
* | * | ||||
* @param includes the string containing the include patterns | * @param includes the string containing the include patterns | ||||
@@ -242,7 +242,7 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
/** | /** | ||||
* Appends <code>excludes</code> to the current list of exclude patterns. | |||||
* Appends <code>excludes</code> to the current list of exclude patterns. | |||||
* Patterns may be separated by a comma or a space. | * Patterns may be separated by a comma or a space. | ||||
* | * | ||||
* @param excludes the string containing the exclude patterns | * @param excludes the string containing the exclude patterns | ||||
@@ -271,7 +271,7 @@ public class PatternSet extends DataType { | |||||
/** | /** | ||||
* Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
* | * | ||||
* @param includesFile The file to fetch the include patterns from. | |||||
* @param includesFile The file to fetch the include patterns from. | |||||
*/ | */ | ||||
public void setIncludesfile(File includesFile) throws BuildException { | public void setIncludesfile(File includesFile) throws BuildException { | ||||
if (isReference()) { | if (isReference()) { | ||||
@@ -283,7 +283,7 @@ public class PatternSet extends DataType { | |||||
/** | /** | ||||
* Sets the name of the file containing the excludes patterns. | * Sets the name of the file containing the excludes patterns. | ||||
* | * | ||||
* @param excludesFile The file to fetch the exclude patterns from. | |||||
* @param excludesFile The file to fetch the exclude patterns from. | |||||
*/ | */ | ||||
public void setExcludesfile(File excludesFile) throws BuildException { | public void setExcludesfile(File excludesFile) throws BuildException { | ||||
if (isReference()) { | if (isReference()) { | ||||
@@ -291,21 +291,21 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
createExcludesFile().setName(excludesFile.getAbsolutePath()); | createExcludesFile().setName(excludesFile.getAbsolutePath()); | ||||
} | } | ||||
/** | /** | ||||
* Reads path matching patterns from a file and adds them to the | * Reads path matching patterns from a file and adds them to the | ||||
* includes or excludes list (as appropriate). | |||||
* includes or excludes list (as appropriate). | |||||
*/ | */ | ||||
private void readPatterns(File patternfile, Vector patternlist, Project p) | private void readPatterns(File patternfile, Vector patternlist, Project p) | ||||
throws BuildException { | throws BuildException { | ||||
BufferedReader patternReader = null; | BufferedReader patternReader = null; | ||||
try { | try { | ||||
// Get a FileReader | // Get a FileReader | ||||
patternReader = | |||||
new BufferedReader(new FileReader(patternfile)); | |||||
// Create one NameEntry in the appropriate pattern list for each | |||||
patternReader = | |||||
new BufferedReader(new FileReader(patternfile)); | |||||
// Create one NameEntry in the appropriate pattern list for each | |||||
// line in the file. | // line in the file. | ||||
String line = patternReader.readLine(); | String line = patternReader.readLine(); | ||||
while (line != null) { | while (line != null) { | ||||
@@ -316,14 +316,14 @@ public class PatternSet extends DataType { | |||||
line = patternReader.readLine(); | line = patternReader.readLine(); | ||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
String msg = "An error occured while reading from pattern file: " | |||||
String msg = "An error occured while reading from pattern file: " | |||||
+ patternfile; | + patternfile; | ||||
throw new BuildException(msg, ioe); | throw new BuildException(msg, ioe); | ||||
} finally { | } finally { | ||||
if (null != patternReader) { | if (null != patternReader) { | ||||
try { | try { | ||||
patternReader.close(); | patternReader.close(); | ||||
} catch (IOException ioe) { | |||||
} catch (IOException ioe) { | |||||
//Ignore exception | //Ignore exception | ||||
} | } | ||||
} | } | ||||
@@ -344,7 +344,7 @@ public class PatternSet extends DataType { | |||||
createInclude().setName(incl[i]); | createInclude().setName(incl[i]); | ||||
} | } | ||||
} | } | ||||
String[] excl = other.getExcludePatterns(p); | String[] excl = other.getExcludePatterns(p); | ||||
if (excl != null) { | if (excl != null) { | ||||
for (int i = 0; i < excl.length; i++) { | for (int i = 0; i < excl.length; i++) { | ||||
@@ -384,14 +384,14 @@ public class PatternSet extends DataType { | |||||
if (isReference()) { | if (isReference()) { | ||||
return getRef(p).hasPatterns(p); | return getRef(p).hasPatterns(p); | ||||
} else { | } else { | ||||
return includesFileList.size() > 0 || excludesFileList.size() > 0 | |||||
return includesFileList.size() > 0 || excludesFileList.size() > 0 | |||||
|| includeList.size() > 0 || excludeList.size() > 0; | || includeList.size() > 0 || excludeList.size() > 0; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Performs the check for circular references and returns the | * Performs the check for circular references and returns the | ||||
* referenced PatternSet. | |||||
* referenced PatternSet. | |||||
*/ | */ | ||||
private PatternSet getRef(Project p) { | private PatternSet getRef(Project p) { | ||||
if (!isChecked()) { | if (!isChecked()) { | ||||
@@ -399,7 +399,7 @@ public class PatternSet extends DataType { | |||||
stk.push(this); | stk.push(this); | ||||
dieOnCircularReference(stk, p); | dieOnCircularReference(stk, p); | ||||
} | } | ||||
Object o = getRefid().getReferencedObject(p); | Object o = getRefid().getReferencedObject(p); | ||||
if (!(o instanceof PatternSet)) { | if (!(o instanceof PatternSet)) { | ||||
String msg = getRefid().getRefId() + " doesn\'t denote a patternset"; | String msg = getRefid().getRefId() + " doesn\'t denote a patternset"; | ||||
@@ -418,7 +418,7 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
Vector tmpNames = new Vector(); | Vector tmpNames = new Vector(); | ||||
for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | |||||
for (Enumeration e = list.elements(); e.hasMoreElements();) { | |||||
NameEntry ne = (NameEntry) e.nextElement(); | NameEntry ne = (NameEntry) e.nextElement(); | ||||
String pattern = ne.evalName(p); | String pattern = ne.evalName(p); | ||||
if (pattern != null && pattern.length() > 0) { | if (pattern != null && pattern.length() > 0) { | ||||
@@ -430,7 +430,7 @@ public class PatternSet extends DataType { | |||||
tmpNames.copyInto(result); | tmpNames.copyInto(result); | ||||
return result; | return result; | ||||
} | } | ||||
/** | /** | ||||
* Read includesfile ot excludesfile if not already done so. | * Read includesfile ot excludesfile if not already done so. | ||||
*/ | */ | ||||
@@ -473,8 +473,8 @@ public class PatternSet extends DataType { | |||||
} | } | ||||
public String toString() { | public String toString() { | ||||
return "patternSet{ includes: " + includeList + | |||||
" excludes: " + excludeList + " }"; | |||||
return "patternSet{ includes: " + includeList | |||||
+ " excludes: " + excludeList + " }"; | |||||
} | } | ||||
} | } |