org.apache.tools.ant.taskdefs.optional.dotnet

Class NetCommand

public class NetCommand extends Object

This is a helper class to spawn net commands out. In its initial form it contains no .net specifics, just contains all the command line/exe construction stuff. However, it may be handy in future to have a means of setting the path to point to the dotnet bin directory; in which case the shared code should go in here.

Version: 0.5

Field Summary
protected CommandlinecommandLine
what is the command line
protected Executeexecutable
executable
protected booleanfailOnError
flag to control action on execution trouble
protected Taskowner
owner project
protected Stringprogram
actual program to invoke
protected Stringtitle
title of the command
protected booleantraceCommandLine
trace flag
Constructor Summary
NetCommand(Task owner, String title, String program)
constructor
Method Summary
voidaddArgument(String argument)
add an argument to a command line; do nothing if the arg is null or empty string
voidaddArgument(String argument1, String argument2)
concatenate two strings together and add them as a single argument, but only if argument2 is non-null and non-zero length
voidaddArguments(String[] arguments)
add an argument to a command line; do nothing if the arg is null or empty string
intgetAutomaticResponseFileThreshold()
getter for threshold
booleangetFailFailOnError()
query fail on error flag
booleanisUseResponseFile()
getter
protected voidlogError(String msg)
error text log
protected voidlogVerbose(String msg)
verbose text log
protected voidprepareExecutor()
set up the command sequence..
voidrunCommand()
Run the command using the given Execute instance.
intscanOneFileset(DirectoryScanner scanner, Hashtable filesToBuild, long outputTimestamp)
scan through one fileset for files to include
voidsetAutomaticResponseFileThreshold(int automaticResponseFileThreshold)
set threshold for automatically using response files -use 0 for off
voidsetDirectory(File directory)
set the directory to run from, if the default is inadequate
voidsetFailOnError(boolean b)
set fail on error flag
voidsetTraceCommandLine(boolean b)
turn tracing on or off
voidsetUseResponseFile(boolean useResponseFile)
set this to true to always use the response file

Field Detail

commandLine

protected Commandline commandLine
what is the command line

executable

protected Execute executable
executable

failOnError

protected boolean failOnError
flag to control action on execution trouble

owner

protected Task owner
owner project

program

protected String program
actual program to invoke

title

protected String title
title of the command

traceCommandLine

protected boolean traceCommandLine
trace flag

Constructor Detail

NetCommand

public NetCommand(Task owner, String title, String program)
constructor

Parameters: title (for logging/errors) owner owner task program app we are to run

Method Detail

addArgument

public void addArgument(String argument)
add an argument to a command line; do nothing if the arg is null or empty string

Parameters: argument The feature to be added to the Argument attribute

addArgument

public void addArgument(String argument1, String argument2)
concatenate two strings together and add them as a single argument, but only if argument2 is non-null and non-zero length

Parameters: argument1 The first argument argument2 The second argument

addArguments

public void addArguments(String[] arguments)
add an argument to a command line; do nothing if the arg is null or empty string

Parameters: arguments The features to be added to the Argument attribute

getAutomaticResponseFileThreshold

public int getAutomaticResponseFileThreshold()
getter for threshold

Returns: 0 for disabled, or a threshold for enabling response files

getFailFailOnError

public boolean getFailFailOnError()
query fail on error flag

Returns: The failFailOnError value

isUseResponseFile

public boolean isUseResponseFile()
getter

Returns: response file state

logError

protected void logError(String msg)
error text log

Parameters: msg message to display as an error

logVerbose

protected void logVerbose(String msg)
verbose text log

Parameters: msg string to add to log if verbose is defined for the build

prepareExecutor

protected void prepareExecutor()
set up the command sequence..

runCommand

public void runCommand()
Run the command using the given Execute instance.

Throws: BuildException if something goes wrong and the failOnError flag is true

scanOneFileset

public int scanOneFileset(DirectoryScanner scanner, Hashtable filesToBuild, long outputTimestamp)
scan through one fileset for files to include

Parameters: scanner the directory scanner to use. filesToBuild the map to place the files. outputTimestamp timestamp to compare against

Returns: #of files out of date

UNKNOWN: should FAT granularity be included here?

setAutomaticResponseFileThreshold

public void setAutomaticResponseFileThreshold(int automaticResponseFileThreshold)
set threshold for automatically using response files -use 0 for off

Parameters: automaticResponseFileThreshold the threshold value to use.

setDirectory

public void setDirectory(File directory)
set the directory to run from, if the default is inadequate

Parameters: directory the directory to use.

setFailOnError

public void setFailOnError(boolean b)
set fail on error flag

Parameters: b fail flag -set to true to cause an exception to be raised if the return value != 0

setTraceCommandLine

public void setTraceCommandLine(boolean b)
turn tracing on or off

Parameters: b trace flag

setUseResponseFile

public void setUseResponseFile(boolean useResponseFile)
set this to true to always use the response file

Parameters: useResponseFile a boolean value.