|
||||||||||
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.figure8.join.services.scripting.ant.tasks.RemoteServiceTask org.figure8.join.services.scripting.ant.tasks.SubstituteParametersTask
public class SubstituteParametersTask
This is an Ant task to use for substituting deployment parameters, into source files,
by their values according to environment and deployment target.
As an example,
use a substituteParams that way to ensure substitution :
>substituteParams environmentKey="env01" targetName="full" regExp="\\$(\\w+)\\$"
toDir="${dest.dir}"<
>fileset dir="${src.dir}" includes="*.properties"/<
>fileset dir="${src2.dir}" includes="*.xml"/<
>substituteParams/<
This task connects to Join server in order to dynamically retrieve the parameters
name/value pairs for environment "env01" and target "full". It then uses the regular
expression pattern "\$(\w+)\$" (this is its default value and you may omit it - be
careful to double backslashes for Java string) to find the parameter names into source
files contained into filesets.
By default, if an exception occurs or if a found parameter has no value, the task
produces a "SubstituteTask.log" log file into destination directory. You may change
the name of this log file using the log attribute of task. If you may also want
the task to fail on error, set the failonerror attribute to true.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_LOGFILE
Constant representing the default name for log file |
static java.lang.String |
DEFAULT_REGEXP
Constant representing the default regular expression used : \$(\w+)\$ |
Fields inherited from class org.figure8.join.services.scripting.ant.tasks.RemoteServiceTask |
---|
REMOTE_URL_SUBCONTEXT |
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 | |
---|---|
SubstituteParametersTask()
Creates a new instance of SubstituteParametersTask |
Method Summary | |
---|---|
void |
addFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of files (nested fileset element) |
protected void |
doSubstitution(java.util.Map parametersMap)
Do the substitution using the given parameters map into the configured filesets |
protected java.util.List |
doSubstitutionInFile(java.io.File src,
java.io.File dest,
java.util.regex.Pattern pattern,
java.util.Map parametersMap)
Do the substitution work from a source file into a destination file |
void |
execute()
Execute this task : do the substitution according into configured filesets |
java.lang.String |
getEnvironmentKey()
|
java.lang.String |
getLogFile()
|
java.lang.String |
getRegExp()
|
java.lang.String |
getTargetName()
|
java.lang.String |
getToDir()
|
boolean |
isFailonerror()
|
protected java.util.Map |
retrieveParametersMap()
Connect to remote service for retrieving a map containing parameters. |
void |
setEnvironmentKey(java.lang.String environmentKey)
|
void |
setFailonerror(boolean failonerror)
|
void |
setLogFile(java.lang.String logFile)
|
void |
setRegExp(java.lang.String regExp)
|
void |
setTargetName(java.lang.String targetName)
|
void |
setToDir(java.lang.String toDir)
|
protected void |
validateAttributes()
Validate this task attributes before execution |
Methods inherited from class org.figure8.join.services.scripting.ant.tasks.RemoteServiceTask |
---|
getPassword, getUrl, getUser, loginToRemoteService, releaseRemoteService, retrieveRemoteService, setPassword, setUrl, setUser |
Methods inherited from class org.apache.tools.ant.Task |
---|
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
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 |
---|
public static final java.lang.String DEFAULT_REGEXP
public static final java.lang.String DEFAULT_LOGFILE
Constructor Detail |
---|
public SubstituteParametersTask()
Method Detail |
---|
public java.lang.String getEnvironmentKey()
public void setEnvironmentKey(java.lang.String environmentKey)
environmentKey
- The key of physical environment to use for retrieving parameter referencespublic java.lang.String getTargetName()
public void setTargetName(java.lang.String targetName)
targetName
- The name of deployment target to use for retrieving parameter referencespublic java.lang.String getRegExp()
public void setRegExp(java.lang.String regExp)
regExp
- The regular expression pattern for selecting parameters within filespublic java.lang.String getToDir()
public void setToDir(java.lang.String toDir)
toDir
- The destination directory for processed filespublic java.lang.String getLogFile()
public void setLogFile(java.lang.String logFile)
logFile
- The name of log file where to write errors or warningpublic boolean isFailonerror()
public void setFailonerror(boolean failonerror)
failonerror
- Flag telling if substitution exceptions thrown a BuildExceptionpublic void addFileset(org.apache.tools.ant.types.FileSet set)
set
- A FileSet containing files to processpublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
- if something wrong occurs during task processprotected void validateAttributes() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
- if a mandatory attribute is not presentprotected java.util.Map retrieveParametersMap() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected void doSubstitution(java.util.Map parametersMap) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
- if exception occurs during log file writing or if errors
and failonerror falgf is set to trueprotected java.util.List doSubstitutionInFile(java.io.File src, java.io.File dest, java.util.regex.Pattern pattern, java.util.Map parametersMap)
src
- The source file to substitute parameters indest
- The destination file to write with parameters valuespattern
- The regular expression pattern for selecting parameters into srcparametersMap
- The map containing parameter name/value pairs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |