public class Velocity
extends org.gradle.api.DefaultTask
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_VELOCITY_INPUT_PATH
The default input path to locate template files with.
|
static java.lang.String |
DEFAULT_VELOCITY_TASK_NAME
The default task name.
|
| Constructor and Description |
|---|
Velocity() |
| Modifier and Type | Method 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.
|
protected void |
checkExecution()
Checks that the task executed correctly.
|
java.util.List<java.lang.String> |
checkInstantiation(java.nio.file.Path 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.
|
void |
configureDefaults()
Applies default values.
|
java.util.Map<java.lang.String,java.lang.Object> |
context(groovy.lang.Closure<java.lang.Void> closure)
Applies the parameter closure to the template context.
|
java.util.Map<java.lang.String,java.lang.Object> |
context(java.io.File propertiesFile)
Adds the key-value pairs in the parameter properties file to the context.
|
java.util.Map<java.lang.String,java.lang.Object> |
context(java.io.InputStream propertiesStream)
Adds the key-value pairs in the parameter properties stream to the 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.util.Map<java.lang.String,java.lang.Object> |
getContextValues()
Getter.
|
groovy.lang.Closure<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.lang.String |
getInputPath()
Accessor.
|
java.io.File |
getOutputDir()
The output directory to write the instantiated templates to.
|
boolean |
isSort()
Getter.
|
boolean |
isStrict()
Getter.
|
boolean |
isUninstantiated(java.lang.String line)
Determines whether a line has an uninstantiated variable.
|
void |
setContextValues(java.util.Map<java.lang.String,java.lang.Object> contextValues)
Setter.
|
void |
setInputPath(java.lang.String inputPath)
Setter.
|
void |
setOutputDir(java.io.File outputDir)
Setter.
|
void |
setSort(boolean sort)
Setter.
|
void |
setStrict(boolean strict)
Setter.
|
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.
|
compareTo, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceappendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectspublic static final java.lang.String DEFAULT_VELOCITY_INPUT_PATH
public static final java.lang.String DEFAULT_VELOCITY_TASK_NAME
public java.lang.String getInputPath()
public void setInputPath(java.lang.String inputPath)
inputPath - The input path to use.public java.io.File getOutputDir()
<buildDir>/velocity.public void setOutputDir(java.io.File outputDir)
outputDir - The output directory to use.public java.util.Map<java.lang.String,java.lang.Object> getContextValues()
public void setContextValues(java.util.Map<java.lang.String,java.lang.Object> contextValues)
contextValues - The context values to set.public boolean isStrict()
public void setStrict(boolean strict)
strict - The strictness flag to set.public boolean isSort()
public void setSort(boolean sort)
sort - The sorting flag to set.@Optional @InputDirectory public groovy.lang.Closure<java.io.File> getInputFile()
src/main/templates.@Input public java.util.Map<java.lang.String,java.lang.Object> getContext()
public java.util.Map<java.lang.String,java.lang.Object> context(groovy.lang.Closure<java.lang.Void> closure)
closure - A closure to add values to the Velocity contextpublic java.util.Map<java.lang.String,java.lang.Object> context(java.util.Map<java.lang.String,java.lang.Object> values)
values - The values to addpublic java.util.Map<java.lang.String,java.lang.Object> context(java.io.InputStream propertiesStream)
propertiesStream - A stream opened from a Java properties file or equivalentpublic java.util.Map<java.lang.String,java.lang.Object> context(java.io.File propertiesFile)
propertiesFile - The Java properties file to addpublic org.gradle.api.Task configure(groovy.lang.Closure closure)
configure in interface org.gradle.api.Taskconfigure in interface org.gradle.util.Configurable<org.gradle.api.Task>configure in class org.gradle.api.DefaultTaskclosure - The configuration closurepublic void configureDefaults()
public void apply()
@Internal public org.gradle.api.file.FileTree getInputFiles()
public TemplateVisitor createVisitor(org.apache.velocity.app.VelocityEngine engine)
engine - The Velocity engine being usedTemplateVisitorpublic org.apache.velocity.app.VelocityEngine createEngine(org.gradle.api.file.FileTree inputFiles)
inputFiles - The input files to instantiate as Velocity templatesprotected void checkExecution()
org.gradle.api.GradleException - If the task did not complete template instantiation.protected java.util.Map<java.io.File,java.util.List<java.lang.String>> checkCompleteInstantiation(java.io.File dir)
dir - The directory containing the instantiated templates to checkpublic java.util.List<java.lang.String> checkInstantiation(java.nio.file.Path instantiated)
instantiated - The file to checkpublic boolean isUninstantiated(java.lang.String line)
${. This
probably fails in a lot of cases, but has proven sufficiently useful for
a lot of cases.line - The line to check${ patternpublic void throwIfUninstantiated(java.util.Map<java.io.File,java.util.List<java.lang.String>> uninstantiated)
uninstantiated - The map of uninstantiated template variable occurrences