Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public abstract Class AbstractCvsTask

extends Task
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.Cvs, org.apache.tools.ant.taskdefs.cvslib.ChangeLogTask, org.apache.tools.ant.taskdefs.cvslib.CvsTagDiff, org.apache.tools.ant.taskdefs.cvslib.CvsVersion
Imports
java.io.BufferedOutputStream, .File, .IOException, .OutputStream, .PrintStream, java.nio.file.Paths, java.util.ArrayList, .Arrays, .List, .Vector, java.util.stream.Collectors, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.types.Commandline, .Environment, org.apache.tools.ant.util.FileUtils

original Cvs.java 1.20

Note

This implementation has been moved here from Cvs.java with the addition of some accessors for extensibility. Another task can extend this with some customized output processing.

Since
Ant 1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private boolean
append

whether or not to append stdout/stderr to existing files

private Commandline
private String
command

the CVS command to execute.

private List<Commandline>
commandlines

list of Commandline children

private int
compression

compression level to use.

private String
cvsPackage

the package/module to check out.

private String
cvsRoot

the CVSROOT variable.

private String
cvsRsh

the CVS_RSH variable.

private static final String
DEFAULT_COMMAND

the default command.

public static final int
DEFAULT_COMPRESSION_LEVEL

Default compression level to use, if compression is enabled via setCompression(true).

private File
dest

the directory where the checked out files should be placed.

private File
error

the file to direct standard error from the command.

private OutputStream
private ExecuteStreamHandler
executeStreamHandler

Create accessors for the following, to allow different handling of the output.

private boolean
failOnError

If true it will stop the build if cvs exits with error.

private static final int
private List<AbstractCvsTask.Module>
private boolean
noexec

report only, don't change any files.

private File
output

the file to direct standard output from the command.

private OutputStream
private File
passFile

CVS password file

private int
port

CVS port

private boolean
quiet

suppress information messages.

private boolean
reallyquiet

suppress all messages.

private String
tag

the tag

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addCommandArgument(String
command argument
arg
)

This needs to be public to allow configuration of commands externally.

public void
addCommandArgument(Commandline
command line to which one argument should be added
c
,
String
argument to add
arg
)

This method adds a command line argument to an external command.

public void
addConfiguredCommandline(Commandline
command line to execute
c
)

Adds direct command-line to execute.

public void
addConfiguredCommandline(Commandline
commandline to insert
c
,
boolean
If true, c is inserted at the beginning of the vector of command lines
insertAtStart
)

Configures and adds the given Commandline.

public void
addModule(AbstractCvsTask.Module
Module
m
)

add a named module/package.

protected void
configureCommandline(Commandline
the command line which will be configured if the commandline is initially null, the function is a noop otherwise the function append to the commandline arguments concerning
  • cvs package
  • compression
  • quiet or reallyquiet
  • cvsroot
  • noexec
c
)

Configure a commandline element for things like cvsRoot, quiet, etc.

public void
private String
public String

Returns:

command line as string
getCommand
()

accessor to a command line as string This should be deprecated AntoineLL July 23d 2003

public String

Returns:

CVSROOT
getCvsRoot
()

access the CVSROOT variable

public String

Returns:

the CVS_RSH variable
getCvsRsh
()

access the CVS_RSH variable

public File

Returns:

directory where the checked out files should be placed
getDest
()

get the file where the checked out files should be placed

protected OutputStream

Returns:

output stream to which cvs' stderr should go to
getErrorStream
()

access the stream to which the stderr from cvs should go if this stream has already been set, it will be returned if the stream has not yet been set, if the attribute error has been set, the output stream will go to the file denoted by the error attribute otherwise the stderr output will go to ant's logging system

protected ExecuteStreamHandler

Returns:

handler for output and error streams
getExecuteStreamHandler
()

find the handler and instantiate it if it does not exist yet

protected List<AbstractCvsTask.Module>
protected OutputStream

Returns:

output stream to which cvs' stdout should go to
getOutputStream
()

access the stream to which the stdout from cvs should go if this stream has already been set, it will be returned if the stream has not yet been set, if the attribute output has been set, the output stream will go to the output file otherwise the output will go to ant's logging system

public String

Returns:

package/module
getPackage
()

access the package or module to operate upon

public File

Returns:

password file
getPassFile
()

find the password file

public int

Returns:

the port of CVS
getPort
()

access the port of CVS

public String

Returns:

tag or branch
getTag
()

tag or branch

protected void
removeCommandline(Commandline
command line which should be removed
c
)

remove a particular command from a vector of command lines

private StringBuilder

Returns:

a StringBuffer where the password has been removed (if available)
removeCvsPassword
(String
the CVS command line
cmdLine
)

Removes the cvs password from the command line, if given on the command line.

protected void
runCommand(Commandline
the command line to execute
toExecute
)

Sets up the environment for toExecute and then runs it.

public void
setAppend(boolean
true indicated you want to append
value
)

Whether to append output/error when redirecting to a file.

public void
setCommand(String
a command as string
c
)

The CVS command to execute.

public void
setCompression(boolean
If true, turns on compression using default level, AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL.
usecomp
)

If true, this is the same as compressionlevel="3".

public void
setCompressionLevel(int
compression level 1 to 9
level
)

If set to a value 1-9 it adds -zN to the cvs command line, else it disables compression.

public void
setCvsRoot(String
the CVSROOT variable
root
)

The CVSROOT variable.

public void
setCvsRsh(String
the CVS_RSH variable
rsh
)

The CVS_RSH variable.

public void
setDate(String
a date as string in a format that the CVS executable can understand see man cvs
p
)

Use the most recent revision no later than the given date.

public void
setDest(File
directory where the checked out files should be placed
dest
)

The directory where the checked out files should be placed.

public void
setError(File
a file to which stderr should go
error
)

The file to direct standard error from the command.

protected void
setErrorStream(OutputStream
an output stream willing to process stderr
errorStream
)

sets a stream to which the stderr from the cvs exe should go

public void
setExecuteStreamHandler(ExecuteStreamHandler
a handler able of processing the output and error streams from the cvs exe
handler
)

sets the handler

public void
setFailOnError(boolean
stop the build process if the command exits with a return code other than 0
failOnError
)

Stop the build process if the command exits with a return code other than 0.

public void
setNoexec(boolean
if true, report only and do not change any files.
ne
)

If true, report only and don't change any files.

public void
setOutput(File
a file to which stdout should go
output
)

The file to direct standard output from the command.

protected void
setOutputStream(OutputStream
stream to which the stdout from cvs should go
outputStream
)

sets a stream to which the output from the cvs executable should be sent

public void
setPackage(String
package or module to operate upon
p
)

The package/module to operate upon.

public void
setPassfile(File
password file to read passwords from
passFile
)

Password file to read passwords from.

public void
setPort(int
port of CVS
port
)

Port used by CVS to communicate with the server.

public void
setQuiet(boolean
if true, suppress informational messages
q
)

If true, suppress informational messages.

public void
setReallyquiet(boolean
if true, suppress all messages
q
)

If true, suppress all messages.

public void
setTag(String
tag
p
)

The tag of the package/module to operate upon.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

appendback to summary
private boolean append

whether or not to append stdout/stderr to existing files

cmdback to summary
private Commandline cmd
commandback to summary
private String command

the CVS command to execute.

commandlinesback to summary
private List<Commandline> commandlines

list of Commandline children

compressionback to summary
private int compression

compression level to use.

cvsPackageback to summary
private String cvsPackage

the package/module to check out.

cvsRootback to summary
private String cvsRoot

the CVSROOT variable.

cvsRshback to summary
private String cvsRsh

the CVS_RSH variable.

DEFAULT_COMMANDback to summary
private static final String DEFAULT_COMMAND

the default command.

DEFAULT_COMPRESSION_LEVELback to summary
public static final int DEFAULT_COMPRESSION_LEVEL

Default compression level to use, if compression is enabled via setCompression(true).

destback to summary
private File dest

the directory where the checked out files should be placed.

errorback to summary
private File error

the file to direct standard error from the command.

errorStreamback to summary
private OutputStream errorStream
executeStreamHandlerback to summary
private ExecuteStreamHandler executeStreamHandler

Create accessors for the following, to allow different handling of the output.

failOnErrorback to summary
private boolean failOnError

If true it will stop the build if cvs exits with error. Default is false. (Iulian)

MAXIMUM_COMRESSION_LEVELback to summary
private static final int MAXIMUM_COMRESSION_LEVEL
modulesback to summary
private List<AbstractCvsTask.Module> modules
noexecback to summary
private boolean noexec

report only, don't change any files.

outputback to summary
private File output

the file to direct standard output from the command.

outputStreamback to summary
private OutputStream outputStream
passFileback to summary
private File passFile

CVS password file

portback to summary
private int port

CVS port

quietback to summary
private boolean quiet

suppress information messages.

reallyquietback to summary
private boolean reallyquiet

suppress all messages.

tagback to summary
private String tag

the tag

Constructor Detail

AbstractCvsTaskback to summary
public AbstractCvsTask()

Method Detail

addCommandArgumentback to summary
public void addCommandArgument(String arg)

This needs to be public to allow configuration of commands externally.

Parameters
arg:String

command argument

addCommandArgumentback to summary
public void addCommandArgument(Commandline c, String arg)

This method adds a command line argument to an external command. I do not understand what this method does in this class ??? particularly not why it is public ???? AntoineLL July 23d 2003

Parameters
c:Commandline

command line to which one argument should be added

arg:String

argument to add

addConfiguredCommandlineback to summary
public void addConfiguredCommandline(Commandline c)

Adds direct command-line to execute.

Parameters
c:Commandline

command line to execute

addConfiguredCommandlineback to summary
public void addConfiguredCommandline(Commandline c, boolean insertAtStart)

Configures and adds the given Commandline.

Parameters
c:Commandline

commandline to insert

insertAtStart:boolean

If true, c is inserted at the beginning of the vector of command lines

addModuleback to summary
public void addModule(AbstractCvsTask.Module m)

add a named module/package.

Parameters
m:AbstractCvsTask.Module

Module

Since
Ant 1.8.0
configureCommandlineback to summary
protected void configureCommandline(Commandline c)

Configure a commandline element for things like cvsRoot, quiet, etc.

Parameters
c:Commandline

the command line which will be configured if the commandline is initially null, the function is a noop otherwise the function append to the commandline arguments concerning

  • cvs package
  • compression
  • quiet or reallyquiet
  • cvsroot
  • noexec
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

do the work

Annotations
@Override
Exceptions
BuildException:
if failonerror is set to true and the cvs command fails.
executeToStringback to summary
private String executeToString(Execute execute)
getCommandback to summary
public String getCommand()

accessor to a command line as string This should be deprecated AntoineLL July 23d 2003

Returns:String

command line as string

getCvsRootback to summary
public String getCvsRoot()

access the CVSROOT variable

Returns:String

CVSROOT

getCvsRshback to summary
public String getCvsRsh()

access the CVS_RSH variable

Returns:String

the CVS_RSH variable

getDestback to summary
public File getDest()

get the file where the checked out files should be placed

Returns:File

directory where the checked out files should be placed

getErrorStreamback to summary
protected OutputStream getErrorStream()

access the stream to which the stderr from cvs should go if this stream has already been set, it will be returned if the stream has not yet been set, if the attribute error has been set, the output stream will go to the file denoted by the error attribute otherwise the stderr output will go to ant's logging system

Returns:OutputStream

output stream to which cvs' stderr should go to

getExecuteStreamHandlerback to summary
protected ExecuteStreamHandler getExecuteStreamHandler()

find the handler and instantiate it if it does not exist yet

Returns:ExecuteStreamHandler

handler for output and error streams

getModulesback to summary
protected List<AbstractCvsTask.Module> getModules()
getOutputStreamback to summary
protected OutputStream getOutputStream()

access the stream to which the stdout from cvs should go if this stream has already been set, it will be returned if the stream has not yet been set, if the attribute output has been set, the output stream will go to the output file otherwise the output will go to ant's logging system

Returns:OutputStream

output stream to which cvs' stdout should go to

getPackageback to summary
public String getPackage()

access the package or module to operate upon

Returns:String

package/module

getPassFileback to summary
public File getPassFile()

find the password file

Returns:File

password file

getPortback to summary
public int getPort()

access the port of CVS

Returns:int

the port of CVS

getTagback to summary
public String getTag()

tag or branch

Returns:String

tag or branch

Since
ant 1.6.1
removeCommandlineback to summary
protected void removeCommandline(Commandline c)

remove a particular command from a vector of command lines

Parameters
c:Commandline

command line which should be removed

removeCvsPasswordback to summary
private StringBuilder removeCvsPassword(String cmdLine)

Removes the cvs password from the command line, if given on the command line. This password can be given on the command line in the cvsRoot -d:pserver:user:password@server:path It has to be noted that the password may be omitted altogether.

Parameters
cmdLine:String

the CVS command line

Returns:StringBuilder

a StringBuffer where the password has been removed (if available)

runCommandback to summary
protected void runCommand(Commandline toExecute) throws BuildException

Sets up the environment for toExecute and then runs it.

Parameters
toExecute:Commandline

the command line to execute

Exceptions
BuildException:
if failonError is set to true and the cvs command fails
setAppendback to summary
public void setAppend(boolean value)

Whether to append output/error when redirecting to a file.

Parameters
value:boolean

true indicated you want to append

setCommandback to summary
public void setCommand(String c)

The CVS command to execute. This should be deprecated, it is better to use the Commandline class ? AntoineLL July 23d 2003

Parameters
c:String

a command as string

setCompressionback to summary
public void setCompression(boolean usecomp)

If true, this is the same as compressionlevel="3".

Parameters
usecomp:boolean

If true, turns on compression using default level, AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL.

setCompressionLevelback to summary
public void setCompressionLevel(int level)

If set to a value 1-9 it adds -zN to the cvs command line, else it disables compression.

Parameters
level:int

compression level 1 to 9

setCvsRootback to summary
public void setCvsRoot(String root)

The CVSROOT variable.

Parameters
root:String

the CVSROOT variable

setCvsRshback to summary
public void setCvsRsh(String rsh)

The CVS_RSH variable.

Parameters
rsh:String

the CVS_RSH variable

setDateback to summary
public void setDate(String p)

Use the most recent revision no later than the given date.

Parameters
p:String

a date as string in a format that the CVS executable can understand see man cvs

setDestback to summary
public void setDest(File dest)

The directory where the checked out files should be placed.

Note that this is different from CVS's -d command line switch as Ant will never shorten pathnames to avoid empty directories.

Parameters
dest:File

directory where the checked out files should be placed

setErrorback to summary
public void setError(File error)

The file to direct standard error from the command.

Parameters
error:File

a file to which stderr should go

setErrorStreamback to summary
protected void setErrorStream(OutputStream errorStream)

sets a stream to which the stderr from the cvs exe should go

Parameters
errorStream:OutputStream

an output stream willing to process stderr

setExecuteStreamHandlerback to summary
public void setExecuteStreamHandler(ExecuteStreamHandler handler)

sets the handler

Parameters
handler:ExecuteStreamHandler

a handler able of processing the output and error streams from the cvs exe

setFailOnErrorback to summary
public void setFailOnError(boolean failOnError)

Stop the build process if the command exits with a return code other than 0. Defaults to false.

Parameters
failOnError:boolean

stop the build process if the command exits with a return code other than 0

setNoexecback to summary
public void setNoexec(boolean ne)

If true, report only and don't change any files.

Parameters
ne:boolean

if true, report only and do not change any files.

setOutputback to summary
public void setOutput(File output)

The file to direct standard output from the command.

Parameters
output:File

a file to which stdout should go

setOutputStreamback to summary
protected void setOutputStream(OutputStream outputStream)

sets a stream to which the output from the cvs executable should be sent

Parameters
outputStream:OutputStream

stream to which the stdout from cvs should go

setPackageback to summary
public void setPackage(String p)

The package/module to operate upon.

Parameters
p:String

package or module to operate upon

setPassfileback to summary
public void setPassfile(File passFile)

Password file to read passwords from.

Parameters
passFile:File

password file to read passwords from

setPortback to summary
public void setPort(int port)

Port used by CVS to communicate with the server.

Parameters
port:int

port of CVS

setQuietback to summary
public void setQuiet(boolean q)

If true, suppress informational messages.

Parameters
q:boolean

if true, suppress informational messages

setReallyquietback to summary
public void setReallyquiet(boolean q)

If true, suppress all messages.

Parameters
q:boolean

if true, suppress all messages

Since
Ant 1.6
setTagback to summary
public void setTag(String p)

The tag of the package/module to operate upon.

Parameters
p:String

tag

org.apache.tools.ant.taskdefs back to summary

public final Class AbstractCvsTask.Module

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
private String name

Constructor Detail

Moduleback to summary
public Module()

Method Detail

getNameback to summary
public String getName()
setNameback to summary
public void setName(String s)