Methods Summary |
---|
protected abstract void | addCompilerSpecificOptions(NetCommand command)add any compiler specifics
|
public void | addDefine(DotnetDefine define)add a define to the list of definitions
definitionList.addElement(define);
|
public void | addReference(org.apache.tools.ant.types.FileSet reference)add a new reference fileset to the compilation
referenceFilesets.add(reference);
|
protected int | addReferenceFilesets(NetCommand command, long outputTimestamp)run through the list of reference files and add them to the command
int filesOutOfDate = 0;
Hashtable filesToBuild = new Hashtable();
for (int i = 0; i < referenceFilesets.size(); i++) {
FileSet fs = (FileSet) referenceFilesets.elementAt(i);
filesOutOfDate += command.scanOneFileset(
fs.getDirectoryScanner(getProject()),
filesToBuild,
outputTimestamp);
}
//bail out early if there were no files
if (filesToBuild.size() == 0) {
return 0;
}
//now scan the hashtable and add the files
Enumeration files = filesToBuild.elements();
while (files.hasMoreElements()) {
File file = (File) files.nextElement();
if (isFileManagedBinary(file)) {
if (isWindows) {
command.addArgument(
'"" + REFERENCE_OPTION + file.toString() + '"");
} else {
command.addArgument(REFERENCE_OPTION + file.toString());
}
} else {
log("ignoring " + file + " as it is not a managed executable",
Project.MSG_VERBOSE);
}
}
return filesOutOfDate;
|
public void | addResource(DotnetResource resource)link or embed a resource
resources.add(resource);
|
protected void | addResources(NetCommand command)for every resource declared, we get the (language specific)
resource setting
Enumeration e = resources.elements();
while (e.hasMoreElements()) {
DotnetResource resource = (DotnetResource) e.nextElement();
createResourceParameter(command, resource);
}
|
public void | clear()reset all contents.
targetType = null;
win32icon = null;
srcDir = null;
mainClass = null;
warnLevel = 3;
optimize = false;
debug = true;
references = null;
failOnError = true;
additionalModules = null;
includeDefaultReferences = true;
extraOptions = null;
|
protected NetCommand | createNetCommand()create our helper command
NetCommand command = new NetCommand(this, getTaskName(), getExecutable());
return command;
|
protected abstract void | createResourceParameter(NetCommand command, DotnetResource resource)Build a C# style parameter.
|
public void | execute()do the work by building the command line and then calling it
log("This task is deprecated and will be removed in a future version\n"
+ "of Ant. It is now part of the .NET Antlib:\n"
+ "http://ant.apache.org/antlibs/dotnet/index.html",
Project.MSG_WARN);
validate();
NetCommand command = createNetCommand();
//set up response file options
command.setAutomaticResponseFileThreshold(AUTOMATIC_RESPONSE_FILE_THRESHOLD);
command.setUseResponseFile(useResponseFile);
//fill in args
fillInSharedParameters(command);
addResources(command);
addCompilerSpecificOptions(command);
int referencesOutOfDate
= addReferenceFilesets(command, getOutputFileTimestamp());
//if the refs are out of date, force a build.
boolean forceBuild = referencesOutOfDate > 0;
addFilesAndExecute(command, forceBuild);
|
protected void | fillInSharedParameters(NetCommand command)fill in the common information
command.setFailOnError(getFailOnError());
//fill in args
command.addArgument("/nologo");
command.addArgument(getAdditionalModulesParameter());
command.addArgument(getDebugParameter());
command.addArgument(getDefinitionsParameter());
command.addArguments(getExtraOptionsParameters());
command.addArgument(getMainClassParameter());
command.addArgument(getOptimizeParameter());
command.addArgument(getDestFileParameter());
command.addArgument(getReferencesParameter());
command.addArgument(getTargetTypeParameter());
command.addArgument(getUtf8OutputParameter());
command.addArgument(getWin32IconParameter());
command.addArgument(getWin32ResParameter());
|
protected java.lang.String | getAdditionalModulesParameter()get the argument or null for no argument needed
if (notEmpty(additionalModules)) {
return "/addmodule:" + additionalModules;
} else {
return null;
}
|
public boolean | getDebug()query the debug flag
return debug;
|
protected java.lang.String | getDebugParameter()get the debug switch argument
return "/debug" + (debug ? "+" : "-");
|
public java.lang.String | getDefinitionsDelimiter()override point for delimiting definitions.
return ";";
|
protected java.lang.String | getDefinitionsParameter()get a list of definitions or null
StringBuffer defines = new StringBuffer();
Enumeration defEnum = definitionList.elements();
boolean firstDefinition = true;
while (defEnum.hasMoreElements()) {
//loop through all definitions
DotnetDefine define = (DotnetDefine) defEnum.nextElement();
if (define.isSet(this)) {
//add those that are set, and a delimiter
if (!firstDefinition) {
defines.append(getDefinitionsDelimiter());
}
defines.append(define.getValue(this));
firstDefinition = false;
}
}
if (defines.length() == 0) {
return null;
} else {
return "/d:" + defines;
}
|
protected java.lang.String | getDestFileParameter()get the argument or null for no argument needed
if (outputFile != null) {
return "/out:" + outputFile.toString();
} else {
return null;
}
|
protected java.lang.String | getExecutable()This method gets the name of the executable.
return executable;
|
public java.lang.String | getExtraOptions()Gets the ExtraOptions attribute
return this.extraOptions;
|
protected java.lang.String | getExtraOptionsParameter()get any extra options or null for no argument needed
if (extraOptions != null && extraOptions.length() != 0) {
return extraOptions;
} else {
return null;
}
|
protected java.lang.String[] | getExtraOptionsParameters()get any extra options or null for no argument needed, split
them if they represent multiple options.
String extra = getExtraOptionsParameter();
return extra == null ? null : Commandline.translateCommandline(extra);
|
public boolean | getFailOnError()query fail on error flag
return failOnError;
|
public abstract java.lang.String | getFileExtension()Get the extension of filenames to compile.
|
public java.lang.String | getFilePattern()Get the pattern for files to compile.
return "**/*." + getFileExtension();
|
public boolean | getIncludeDefaultReferences()query automatic reference inclusion flag
return includeDefaultReferences;
|
protected java.lang.String | getIncludeDefaultReferencesParameter()get the include default references flag or null for no argument needed
return "/nostdlib" + (includeDefaultReferences ? "-" : "+");
|
public java.lang.String | getMainClass()Gets the MainClass attribute
return this.mainClass;
|
protected java.lang.String | getMainClassParameter()get the /main argument or null for no argument needed
if (mainClass != null && mainClass.length() != 0) {
return "/main:" + mainClass;
} else {
return null;
}
|
public boolean | getOptimize()query the optimise flag
return optimize;
|
protected java.lang.String | getOptimizeParameter()get the optimise flag or null for no argument needed
return "/optimize" + (optimize ? "+" : "-");
|
public abstract java.lang.String | getReferenceDelimiter()Get the delimiter that the compiler uses between references.
For example, c# will return ";"; VB.NET will return ","
|
protected java.lang.String | getReferenceFilesParameter()turn the path list into a list of files and a /references argument
//bail on no references
if (references == null) {
return null;
}
//iterate through the ref list & generate an entry for each
//or just rely on the fact that the toString operator does this, but
//noting that the separator is ';' on windows, ':' on unix
//bail on no references listed
if (references.length() == 0) {
return null;
}
StringBuffer s = new StringBuffer(REFERENCE_OPTION);
if (isWindows) {
s.append('\"");
}
s.append(references);
if (isWindows) {
s.append('\"");
}
return s.toString();
|
protected java.lang.String | getReferencesParameter()get the reference string or null for no argument needed
//bail on no references
if (notEmpty(references)) {
if (isWindows) {
return '\"" + REFERENCE_OPTION + references + '\"";
} else {
return REFERENCE_OPTION + references;
}
} else {
return null;
}
|
public java.lang.String | getTargetType()Gets the TargetType attribute
return targetType;
|
protected java.lang.String | getTargetTypeParameter()get the argument or null for no argument needed
if (notEmpty(targetType)) {
return "/target:" + targetType;
} else {
return null;
}
|
protected java.lang.String | getUtf8OutputParameter()Gets the utf8OutpuParameter attribute of the CSharp object
return utf8output ? "/utf8output" : null;
|
public int | getWarnLevel()query warn level
return warnLevel;
|
protected java.lang.String | getWarnLevelParameter()get the warn level switch
return "/warn:" + warnLevel;
|
protected java.lang.String | getWin32IconParameter()get the argument or null for no argument needed
if (win32icon != null) {
return "/win32icon:" + win32icon.toString();
} else {
return null;
}
|
public java.io.File | getWin32Res()Gets the file of the win32 .res file to include.
return win32res;
|
protected java.lang.String | getWin32ResParameter()get the argument or null for no argument needed
if (win32res != null) {
return "/win32res:" + win32res.toString();
} else {
return null;
}
|
protected static boolean | isFileManagedBinary(java.io.File file)test for a file being managed or not
String filename = file.toString().toLowerCase();
return filename.endsWith(".exe") || filename.endsWith(".dll")
|| filename.endsWith(".netmodule");
|
public boolean | isUseResponseFile()getter for flag
return useResponseFile;
|
protected boolean | notEmpty(java.lang.String s)test for a string containing something useful
return s != null && s.length() != 0;
|
public void | setAdditionalModules(java.lang.String params)Semicolon separated list of modules to refer to.
additionalModules = params;
|
public void | setDebug(boolean f)set the debug flag on or off.
debug = f;
|
public void | setDestDir(java.io.File dirName)Set the destination directory of files to be compiled.
log("DestDir currently unused", Project.MSG_WARN);
|
public void | setExecutable(java.lang.String executable)set the name of the program, overriding the defaults.
Can be used to set the full path to a program, or to switch
to an alternate implementation of the command, such as the Mono or Rotor
versions -provided they use the same command line arguments as the
.NET framework edition
this.executable = executable;
|
public void | setExtraOptions(java.lang.String extraOptions)Any extra options which are not explicitly supported
by this task.
this.extraOptions = extraOptions;
|
public void | setFailOnError(boolean b)If true, fail on compilation errors.
failOnError = b;
|
public void | setIncludeDefaultReferences(boolean f)If true, automatically includes the common assemblies
in dotnet, and tells the compiler to link in mscore.dll.
set the automatic reference inclusion flag on or off this flag controls
the /nostdlib option in CSC
includeDefaultReferences = f;
|
public void | setMainClass(java.lang.String mainClass)Sets the name of main class for executables.
this.mainClass = mainClass;
|
public void | setOptimize(boolean f)If true, enables optimization flag.
optimize = f;
|
public void | setReferenceFiles(org.apache.tools.ant.types.Path path)Path of references to include.
Wildcards should work.
//demand create pathlist
if (referenceFiles == null) {
referenceFiles = new Path(this.getProject());
}
referenceFiles.append(path);
|
public void | setReferences(java.lang.String s)Semicolon separated list of DLLs to refer to.
references = s;
|
public void | setTargetType(org.apache.tools.ant.taskdefs.optional.dotnet.DotnetCompile$TargetTypes targetType)set the target type to one of exe|library|module|winexe
this.targetType = targetType.getValue();
|
public void | setTargetType(java.lang.String ttype)Set the type of target.
ttype = ttype.toLowerCase();
if (ttype.equals("exe") || ttype.equals("library")
|| ttype.equals("module") || ttype.equals("winexe")) {
targetType = ttype;
} else {
throw new BuildException("targetType " + ttype
+ " is not one of 'exe', 'module', 'winexe' or 'library'");
}
|
public void | setUseResponseFile(boolean useResponseFile)Flag to turn on response file use; default=false.
When set the command params are saved to a file and
this is passed in with @file. The task automatically switches
to this mode with big commands; this option is here for
testing and emergencies
this.useResponseFile = useResponseFile;
|
public void | setUtf8Output(boolean enabled)If true, require all compiler output to be in UTF8 format.
utf8output = enabled;
|
public void | setWarnLevel(int warnLevel)Level of warning currently between 1 and 4
with 4 being the strictest.
this.warnLevel = warnLevel;
|
public void | setWin32Icon(java.io.File fileName)Set the filename of icon to include.
win32icon = fileName;
|
public void | setWin32Res(java.io.File fileName)Sets the filename of a win32 resource (.RES) file to include.
This is not a .NET resource, but what Windows is used to.
win32res = fileName;
|
protected void | validate()validation code
if (outputFile != null && outputFile.isDirectory()) {
throw new BuildException("destFile cannot be a directory");
}
if (getExecutable() == null) {
throw new BuildException("There is no executable defined for this task");
}
|