|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.ProjectComponent | +--org.apache.tools.ant.Task | +--org.apache.tools.ant.taskdefs.Copy | +--org.enhydra.barracuda.taskdefs.CopyAndReplace
A consolidated copy and replace task that extends the basic Ant Copy taskdef.
In addition, once files have been copied, a replace function is also run on them. This replace will only affect the files that actually get copied; it will not affect any other files in the directory.
The replace occurs using a simply properties file, rather than specifying replace parameters via the xml. The format of this file looks something like this:
As you can see, the format is flexible. Tokens are identified with "token=" and values are identified by "value=". The actual token/value delimiters are taken to be the first character following the = sign. This could be a double quote, single quote, or any other character (ie. if the text you wish to replace contains both double and single quotes, you might want to use a ~ delimiter or something like that).
Note also that this taskdef support SSI replacement, which can be quite useful. By default, the copied files are NOT processed for SSIs; if you want to use this, turn is on using the 'ssi=true' attribute. SSI replacement occurs BEFORE the token replacement (ensuring that the text contained in the SSI gets processed for tokens as well).
Nested Class Summary | |
static class |
CopyAndReplace.BooleanAttribute
|
Field Summary | |
protected java.io.File |
mappingsFile
|
protected boolean |
ssi
|
Fields inherited from class org.apache.tools.ant.taskdefs.Copy |
destDir, destFile, dirCopyMap, file, fileCopyMap, filesets, filtering, flatten, forceOverwrite, includeEmpty, mapperElement, preserveLastModified, verbosity |
Fields inherited from class org.apache.tools.ant.Task |
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Constructor Summary | |
CopyAndReplace()
|
Method Summary | |
protected void |
doFileOperations()
Actually does the file (and possibly empty directory) copies. |
byte[] |
getFile(java.io.File targetFile,
java.io.File fromDir)
|
void |
setMappings(java.io.File mappingsFile)
Sets the mappings file. |
void |
setSsi(CopyAndReplace.BooleanAttribute issi)
Process files copied for ssi |
Methods inherited from class org.apache.tools.ant.taskdefs.Copy |
addFileset, buildMap, createFilterSet, createMapper, execute, getFileUtils, getFilterSets, scan, setFile, setFiltering, setFlatten, setIncludeEmptyDirs, setOverwrite, setPreserveLastModified, setTodir, setTofile, setVerbose, validateAttributes |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.io.File mappingsFile
protected boolean ssi
Constructor Detail |
public CopyAndReplace()
Method Detail |
public void setMappings(java.io.File mappingsFile)
public void setSsi(CopyAndReplace.BooleanAttribute issi)
protected void doFileOperations()
Actually does the file (and possibly empty directory) copies. This is a good method for subclasses to override.
Note that all the copy functionality occurs by simply deferring to the superclass implementation. The replace functionality follows:
first we make sure there is a mappings file
next we parse it to determine all token/value mapings
finally we iterate through the list of files that actually got copied and we create Replace task for each of them. This task contains all the various token/value mappings, and gets executed for each file, effectively making all the necessary text substitutions
doFileOperations
in class org.apache.tools.ant.taskdefs.Copy
public byte[] getFile(java.io.File targetFile, java.io.File fromDir)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |