|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.Task | +--org.apache.tools.ant.taskdefs.MatchingTask | +--org.apache.tools.ant.taskdefs.optional.dotnet.CSharp
This task compiles CSharp source into executables or modules. The task will only work on win2K until other platforms support csc.exe or an equivalent. CSC.exe must be on the execute path too.
All parameters are optional: <csc/> should suffice to produce a debug build of all *.cs files. References to external files do require explicit enumeration, so are one of the first attributes to consider adding.
The task is a directory based task, so attributes like includes="*.cs" and excludes="broken.cs" can be used to control the files pulled in. By default, all *.cs files from the project folder down are included in the command. When this happens the output file -if not specified- is taken as the first file in the list, which may be somewhat hard to control. Specifying the output file with 'outfile' seems prudent.
TODO
History
0.3 | Beta 1 edition | To avoid having to remember which assemblies to include, the task automatically refers to the main dotnet libraries in Beta1. |
0.2 | Slightly different | Split command execution to a separate class; |
0.1 | "I can't believe it's so rudimentary" | First pass; minimal builds only support; |
Field Summary | |
protected boolean |
_debug
debug flag. |
protected java.io.File |
_docFile
output XML documentation flag |
protected java.lang.String |
_extraOptions
any extra command options? |
protected boolean |
_failOnError
flag to control action on execution trouble |
protected boolean |
_includeDefaultReferences
flag to enable automatic reference inclusion |
protected boolean |
_incremental
incremental build flag |
protected java.lang.String |
_mainClass
main class (or null for automatic choice) |
protected boolean |
_optimize
optimise flag |
protected java.lang.String |
_outputFile
output file. |
protected Path |
_referenceFiles
using the path approach didnt work as it could not handle the implicit execution path. |
protected java.lang.String |
_references
list of reference classes. |
protected java.lang.String |
_targetType
type of target. |
protected boolean |
_unsafe
enable unsafe code flag. |
protected java.io.File |
_win32icon
icon for incorporation into apps |
protected static java.lang.String |
csc_exe_name
name of the executable. |
protected static java.lang.String |
csc_file_ext
what is the file extension we search on? |
protected static java.lang.String |
csc_file_pattern
derive the search pattern from the extension |
protected static java.lang.String |
DEFAULT_REFERENCE_LIST
C# is really dumb in how it handles inclusion. |
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
fileset, useDefaultExcludes |
Fields inherited from class org.apache.tools.ant.Task |
description, location, project, target, taskName, taskType, wrapper |
Constructor Summary | |
CSharp()
constructor inits everything and set up the search pattern |
Method Summary | |
void |
Clear()
reset all contents. |
void |
execute()
do the work by building the command line and then calling it |
protected java.lang.String |
getAdditionalModulesParameter()
get the argument or null for no argument needed |
boolean |
getDebug()
query the debug flag |
protected java.lang.String |
getDebugParameter()
get the debug switch argument |
protected java.lang.String |
getDefaultReferenceParameter()
get default reference list |
protected java.lang.String |
getDefinitionsParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getDocFileParameter()
get the argument or null for no argument needed |
java.lang.String |
getExtraOptions()
Gets the ExtraOptions attribute |
protected java.lang.String |
getExtraOptionsParameter()
get any extra options or null for no argument needed |
boolean |
getFailFailOnError()
query fail on error flag |
boolean |
getIncludeDefaultReferences()
query the optimise flag |
protected java.lang.String |
getIncludeDefaultReferencesParameter()
get the include default references flag or null for no argument needed |
boolean |
getIncremental()
query the incrementalflag |
protected java.lang.String |
getIncrementalParameter()
get the incremental build argument |
java.lang.String |
getMainClass()
Gets the MainClass attribute |
protected java.lang.String |
getMainClassParameter()
get the /main argument or null for no argument needed |
boolean |
getOptimize()
query the optimise flag |
protected java.lang.String |
getOptimizeParameter()
get the optimise flag or null for no argument needed |
protected java.lang.String |
getOutputFileParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getReferenceFilesParameter()
turn the path list into a list of files and a /references argument |
protected java.lang.String |
getReferencesParameter()
get the reference string or null for no argument needed |
java.lang.String |
getTargetType()
Gets the TargetType attribute |
protected java.lang.String |
getTargetTypeParameter()
get the argument or null for no argument needed |
boolean |
getUnsafe()
query the Unsafe attribute |
protected java.lang.String |
getUnsafeParameter()
get the argument or null for no argument needed |
int |
getWarnLevel()
query warn level |
protected java.lang.String |
getWarnLevelParameter()
get the warn level switch |
protected java.lang.String |
getWin32IconParameter()
get the argument or null for no argument needed |
protected boolean |
notEmpty(java.lang.String s)
test for a string containing something useful |
void |
setAdditionalModules(java.lang.String params)
Set the definitions |
void |
setDebug(boolean f)
set the debug flag on or off |
void |
setDefinitions(java.lang.String params)
Set the definitions |
void |
setDestDir(java.lang.String dirName)
Set the destination dir to find the files to be compiled |
void |
setDocFile(java.lang.String f)
file for generated XML documentation |
void |
setExtraOptions(java.lang.String extraOptions)
Sets the ExtraOptions attribute |
void |
setFailOnError(boolean b)
set fail on error flag |
void |
setIncludeDefaultReferences(boolean f)
set the automatic reference inclusion flag on or off this flag controls the string of references and the /nostdlib option in CSC |
void |
setIncremental(boolean f)
set the incremental compilation flag on or off |
void |
setMainClass(java.lang.String mainClass)
Sets the MainClass attribute |
void |
setOptimize(boolean f)
set the optimise flag on or off |
void |
setOutputFile(java.lang.String params)
Set the definitions |
void |
setReferenceFiles(Path path)
add another path to the reference file path list |
void |
setReferences(java.lang.String s)
Set the reference list to be used for this compilation. |
void |
setSrcDir(java.lang.String srcDirName)
Set the source dir to find the files to be compiled |
void |
setTargetType(java.lang.String targetType)
define the target |
void |
setUnsafe(boolean unsafe)
Sets the Unsafe attribute |
void |
setWarnLevel(int warnLevel)
set warn level (no range checking) |
void |
setWin32Icon(java.lang.String fileName)
Set the win32 icon |
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
createExclude, createInclude, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String csc_exe_name
protected static final java.lang.String csc_file_ext
protected static final java.lang.String csc_file_pattern
protected java.lang.String _references
protected Path _referenceFiles
protected static final java.lang.String DEFAULT_REFERENCE_LIST
protected boolean _includeDefaultReferences
protected boolean _optimize
protected boolean _incremental
protected boolean _debug
protected java.io.File _docFile
protected boolean _unsafe
protected java.lang.String _mainClass
protected java.lang.String _extraOptions
protected java.lang.String _targetType
protected java.io.File _win32icon
protected java.lang.String _outputFile
protected boolean _failOnError
Constructor Detail |
public CSharp()
Method Detail |
public void setReferences(java.lang.String s)
s
- The new References valueprotected java.lang.String getReferencesParameter()
public void setReferenceFiles(Path path)
path
- another path to appendprotected java.lang.String getReferenceFilesParameter()
protected java.lang.String getDefaultReferenceParameter()
public void setIncludeDefaultReferences(boolean f)
f
- on/off flagpublic boolean getIncludeDefaultReferences()
protected java.lang.String getIncludeDefaultReferencesParameter()
public void setOptimize(boolean f)
f
- on/off flagpublic boolean getOptimize()
protected java.lang.String getOptimizeParameter()
public void setIncremental(boolean f)
f
- on/off flagpublic boolean getIncremental()
protected java.lang.String getIncrementalParameter()
public void setDebug(boolean f)
f
- on/off flagpublic boolean getDebug()
protected java.lang.String getDebugParameter()
public void setDocFile(java.lang.String f)
f
- output fileprotected java.lang.String getDocFileParameter()
public void setWarnLevel(int warnLevel)
warnLevel
- warn level -see .net docs for valid range (probably 0-4)public int getWarnLevel()
protected java.lang.String getWarnLevelParameter()
public void setUnsafe(boolean unsafe)
unsafe
- The new Unsafe valuepublic boolean getUnsafe()
protected java.lang.String getUnsafeParameter()
public void setMainClass(java.lang.String mainClass)
mainClass
- The new MainClass valuepublic java.lang.String getMainClass()
protected java.lang.String getMainClassParameter()
public void setExtraOptions(java.lang.String extraOptions)
extraOptions
- The new ExtraOptions valuepublic java.lang.String getExtraOptions()
protected java.lang.String getExtraOptionsParameter()
public void setSrcDir(java.lang.String srcDirName)
srcDirName
- The new SrcDir valuepublic void setDestDir(java.lang.String dirName)
dirName
- The new DestDir valuepublic void setTargetType(java.lang.String targetType) throws BuildException
targetType
- The new TargetType valueBuildException
- if target is not one of exe|library|module|winexepublic java.lang.String getTargetType()
protected java.lang.String getTargetTypeParameter()
public void setWin32Icon(java.lang.String fileName)
fileName
- path to the file. Can be relative, absolute, whatever.protected java.lang.String getWin32IconParameter()
public void setDefinitions(java.lang.String params)
list
- of definitions split by ; or , or even :protected java.lang.String getDefinitionsParameter()
public void setAdditionalModules(java.lang.String params)
list
- of definitions split by ; or , or even :protected java.lang.String getAdditionalModulesParameter()
public void setOutputFile(java.lang.String params)
list
- of definitions split by ; or , or even :protected java.lang.String getOutputFileParameter()
public void setFailOnError(boolean b)
b
- The new FailOnError valuepublic boolean getFailFailOnError()
public void Clear()
protected boolean notEmpty(java.lang.String s)
s
- string inpublic void execute() throws BuildException
execute
in class Task
org.apache.tools.ant.Task
BuildException
- if someting goes wrong with the build
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |