A Gradle task for instantiating Velocity templates using the Velocity engine.
| Fields inherited from class | Fields |
|---|---|
class org.gradle.api.DefaultTask |
TASK_NAME, TASK_DESCRIPTION, TASK_GROUP, TASK_TYPE, TASK_DEPENDS_ON, TASK_OVERWRITE, TASK_ACTION, TASK_CONSTRUCTOR_ARGS |
| Type | Name and description |
|---|---|
static java.lang.String |
DEFAULT_VELOCITY_INPUT_PATHThe default input path to locate template files with. |
static java.lang.String |
DEFAULT_VELOCITY_TASK_NAMEThe default task name. |
java.util.Map<java.lang.String, java.lang.Object> |
contextValuesThe Velocity context to instantiate the input templates with. |
java.lang.String |
inputPathThe path where the input templates are located. |
java.io.File |
outputDirThe location to write the instantiated templates to. |
boolean |
sort |
boolean |
strictIf the instantiation is strict then an exception will be thrown if any template variables remain in the instantiated templates after the context has been applied. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
apply()Executes the task. |
|
protected java.util.Map<java.io.File, java.util.List<java.lang.String>> |
checkCompleteInstantiation(java.io.File dir)Creates a map of instantated template files to the list of lines in the files where a template variable failed to be instantiated. |
|
java.util.List<java.lang.String> |
checkInstantiation(java.io.File instantiated)Returns a list of lines with uninstantiated template variables, from the parameter file. |
|
org.gradle.api.Task |
configure(groovy.lang.Closure closure)Configures the task. |
|
protected void |
configureChecking()If instantiation is strict, a check is configured to make sure an exception is thrown if any template variables are missing from the context. |
|
void |
configureDefaults()Applies default values. |
|
java.util.Map<java.lang.String, java.lang.Object> |
context(groovy.lang.Closure closure)Applies the parameter closure to the template context. |
|
java.util.Map<java.lang.String, java.lang.Object> |
context(java.util.Map<java.lang.String, java.lang.Object> values)Adds the key-value pairs in the parameter map to the Velocity context. |
|
org.apache.velocity.app.VelocityEngine |
createEngine(org.gradle.api.file.FileTree inputFiles)Creates a Velocity engine instance for the input files. |
|
TemplateVisitor |
createVisitor(org.apache.velocity.app.VelocityEngine engine)Creates a template visitor for the parameter engine. |
|
java.util.Map<java.lang.String, java.lang.Object> |
getContext()The Velocity template context for instantiation. |
|
java.io.File |
getInputFile()The directory where the templates are located. |
|
org.gradle.api.file.FileTree |
getInputFiles()Converts the input directory to a file tree. |
|
java.io.File |
getOutputDir()The output directory to write the instantiated templates to. |
|
boolean |
isUninstantiated(java.lang.String line)Determines whether a line has an uninstantiated variable. |
|
void |
throwIfUninstantiated(java.util.Map<java.io.File, java.util.List<java.lang.String>> uninstantiated)Throws a Gradle exception if the parameter map is non-empty. |
| Methods inherited from class | Name |
|---|---|
class org.gradle.api.DefaultTask |
org.gradle.api.DefaultTask#getProject(), org.gradle.api.DefaultTask#setDescription(java.lang.String), org.gradle.api.DefaultTask#setGroup(java.lang.String), org.gradle.api.DefaultTask#getAnt(), org.gradle.api.DefaultTask#getLogging(), org.gradle.api.DefaultTask#getLogging(), org.gradle.api.DefaultTask#getDidWork(), org.gradle.api.DefaultTask#setDidWork(boolean), org.gradle.api.DefaultTask#doFirst(org.gradle.api.Action), org.gradle.api.DefaultTask#doFirst(java.lang.String, org.gradle.api.Action), org.gradle.api.DefaultTask#doFirst(groovy.lang.Closure), org.gradle.api.DefaultTask#doLast(groovy.lang.Closure), org.gradle.api.DefaultTask#doLast(java.lang.String, org.gradle.api.Action), org.gradle.api.DefaultTask#doLast(org.gradle.api.Action), org.gradle.api.DefaultTask#getEnabled(), org.gradle.api.DefaultTask#getOutputs(), org.gradle.api.DefaultTask#getOutputs(), org.gradle.api.DefaultTask#getDestroyables(), org.gradle.api.DefaultTask#getLocalState(), org.gradle.api.DefaultTask#getTemporaryDir(), org.gradle.api.DefaultTask#mustRunAfter([Ljava.lang.Object;), org.gradle.api.DefaultTask#setMustRunAfter(java.lang.Iterable), org.gradle.api.DefaultTask#getMustRunAfter(), org.gradle.api.DefaultTask#finalizedBy([Ljava.lang.Object;), org.gradle.api.DefaultTask#setFinalizedBy(java.lang.Iterable), org.gradle.api.DefaultTask#getFinalizedBy(), org.gradle.api.DefaultTask#shouldRunAfter([Ljava.lang.Object;), org.gradle.api.DefaultTask#onlyIf(groovy.lang.Closure), org.gradle.api.DefaultTask#onlyIf(org.gradle.api.specs.Spec), org.gradle.api.DefaultTask#setOnlyIf(groovy.lang.Closure), org.gradle.api.DefaultTask#setOnlyIf(org.gradle.api.specs.Spec), org.gradle.api.DefaultTask#usesService(org.gradle.api.provider.Provider), org.gradle.api.DefaultTask#getTaskDependencies(), org.gradle.api.DefaultTask#getTaskDependencies(), org.gradle.api.DefaultTask#getShouldRunAfter(), org.gradle.api.DefaultTask#setActions(java.util.List), org.gradle.api.DefaultTask#getDependsOn(), org.gradle.api.DefaultTask#setShouldRunAfter(java.lang.Iterable), org.gradle.api.DefaultTask#setDependsOn(java.lang.Iterable), org.gradle.api.DefaultTask#dependsOn([Ljava.lang.Object;), org.gradle.api.DefaultTask#getLogger(), org.gradle.api.DefaultTask#getTimeout(), org.gradle.api.DefaultTask#setProperty(java.lang.String, java.lang.Object), org.gradle.api.DefaultTask#compareTo(org.gradle.api.Task), org.gradle.api.DefaultTask#compareTo(java.lang.Object), org.gradle.api.DefaultTask#getName(), org.gradle.api.DefaultTask#getActions(), org.gradle.api.DefaultTask#getState(), org.gradle.api.DefaultTask#getState(), org.gradle.api.DefaultTask#getPath(), org.gradle.api.DefaultTask#getExtensions(), org.gradle.api.DefaultTask#property(java.lang.String), org.gradle.api.DefaultTask#configure(groovy.lang.Closure), org.gradle.api.DefaultTask#configure(groovy.lang.Closure), org.gradle.api.DefaultTask#getDescription(), org.gradle.api.DefaultTask#setEnabled(boolean), org.gradle.api.DefaultTask#hasProperty(java.lang.String), org.gradle.api.DefaultTask#getGroup(), org.gradle.api.DefaultTask#getInputs(), org.gradle.api.DefaultTask#getInputs(), org.gradle.api.DefaultTask#getIdentityPath(), org.gradle.api.DefaultTask#getStandardOutputCapture(), org.gradle.api.DefaultTask#getConvention(), org.gradle.api.DefaultTask#getAsDynamicObject(), org.gradle.api.DefaultTask#getTaskIdentity(), org.gradle.api.DefaultTask#injectIntoNewInstance(org.gradle.api.internal.project.ProjectInternal, org.gradle.api.internal.project.taskfactory.TaskIdentity, java.util.concurrent.Callable), org.gradle.api.DefaultTask#getTaskActions(), org.gradle.api.DefaultTask#hasTaskActions(), org.gradle.api.DefaultTask#getOnlyIf(), org.gradle.api.DefaultTask#getImpliesSubProjects(), org.gradle.api.DefaultTask#setImpliesSubProjects(boolean), org.gradle.api.DefaultTask#replaceLogger(org.gradle.api.logging.Logger), org.gradle.api.DefaultTask#getTemporaryDirFactory(), org.gradle.api.DefaultTask#prependParallelSafeAction(org.gradle.api.Action), org.gradle.api.DefaultTask#appendParallelSafeAction(org.gradle.api.Action), org.gradle.api.DefaultTask#isHasCustomActions(), org.gradle.api.DefaultTask#getRequiredServices(), org.gradle.api.DefaultTask#getSharedResources(), org.gradle.api.DefaultTask#isEnabled(), org.gradle.api.DefaultTask#wait(long, int), org.gradle.api.DefaultTask#wait(long), org.gradle.api.DefaultTask#wait(), org.gradle.api.DefaultTask#equals(java.lang.Object), org.gradle.api.DefaultTask#toString(), org.gradle.api.DefaultTask#hashCode(), org.gradle.api.DefaultTask#getClass(), org.gradle.api.DefaultTask#notify(), org.gradle.api.DefaultTask#notifyAll() |
The default input path to locate template files with.
The default task name.
The Velocity context to instantiate the input templates with.
The path where the input templates are located.
The location to write the instantiated templates to.
If the instantiation is strict then an exception will be thrown if any template variables remain in the instantiated templates after the context has been applied. Defaults to false.
Executes the task.
Creates a map of instantated template files to the list of lines in the files where a template variable failed to be instantiated. If every variable has a context value then the map will be empty; if one or more variables are missing from the context then one or more files will appear in the output, and map to the lines where instantiation failed.
dir - The directory containing the instantiated templates to checkReturns a list of lines with uninstantiated template variables, from the parameter file. The output is empty if everything was instantiated.
instantiated - The file to checkConfigures the task. This method is re-entrant, the task can be configured any number of times, or not at all.
closure - The configuration closureIf instantiation is strict, a check is configured to make sure an exception is thrown if any template variables are missing from the context.
Applies default values.
Applies the parameter closure to the template context. Syntactic sugar.
closure - A closure to add values to the Velocity contextAdds the key-value pairs in the parameter map to the Velocity context.
values - The values to addCreates a Velocity engine instance for the input files.
inputFiles - The input files to instantiate as Velocity templatesCreates a template visitor for the parameter engine.
engine - The Velocity engine being usedThe Velocity template context for instantiation.
The directory where the templates are located. Defaults to
src/main/templates.
Converts the input directory to a file tree.
The output directory to write the instantiated templates to. Defaults to
<buildDir>/velocity.
Determines whether a line has an uninstantiated variable. The check simply
looks for the start of a variable insertion, e.g. ${. This
probably fails in a lot of cases, but has proven sufficiently useful for
a lot of cases.
line - The line to check\${ patternThrows a Gradle exception if the parameter map is non-empty.
uninstantiated - The map of uninstantiated template variable occurrences