@CacheableTask public class WriteProperties extends DefaultTask
Properties
in a way that the results can be expected to be reproducible.
There are a number of differences compared to how properties are stored:
Like with Properties
, Unicode characters are escaped when using the
default Latin-1 (ISO-8559-1) encoding.
Properties.store(OutputStream, String)
Task.Namer
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
Constructor | Description |
---|---|
WriteProperties() |
Modifier and Type | Method | Description |
---|---|---|
java.lang.String |
getComment() |
Returns the optional comment to add at the beginning of the properties file.
|
java.lang.String |
getEncoding() |
Returns the encoding used to write the properties file.
|
java.lang.String |
getLineSeparator() |
Returns the line separator to be used when creating the properties file.
|
java.io.File |
getOutputFile() |
Returns the output file to write the properties to.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties() |
Returns an immutable view of properties to be written to the properties file.
|
void |
properties(java.util.Map<java.lang.String,java.lang.Object> properties) |
Adds multiple properties to be written to the properties file.
|
void |
property(java.lang.String name,
java.lang.Object value) |
Adds a property to be written to the properties file.
|
void |
setComment(java.lang.String comment) |
Sets the optional comment to add at the beginning of the properties file.
|
void |
setEncoding(java.lang.String encoding) |
Sets the encoding used to write the properties file.
|
void |
setLineSeparator(java.lang.String lineSeparator) |
Sets the line separator to be used when creating the properties file.
|
void |
setOutputFile(java.io.File outputFile) |
Sets the output file to write the properties to.
|
void |
setOutputFile(java.lang.Object outputFile) |
Sets the output file to write the properties to.
|
void |
setProperties(java.util.Map<java.lang.String,java.lang.Object> properties) |
Sets all properties to be written to the properties file replacing any existing properties.
|
void |
writeProperties() |
appendParallelSafeAction, compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTaskIdentity, getTemporaryDir, getTemporaryDirFactory, getTimeout, hasProperty, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, replaceLogger, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString
newInputDirectory, newInputFile, newOutputDirectory, newOutputFile
@Input public java.util.Map<java.lang.String,java.lang.String> getProperties()
public void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
properties(Map)
,
property(String, Object)
public void property(java.lang.String name, java.lang.Object value)
A property's value will be coerced to a String
with String#valueOf(Object)
or a
Callable
returning a value to be coerced into a String
.
Values are not allowed to be null.
name
- Name of the propertyvalue
- Value of the propertypublic void properties(java.util.Map<java.lang.String,java.lang.Object> properties)
This is a convenience method for calling property(String, Object)
multiple times.
properties
- Properties to be addedproperty(String, Object)
@Input public java.lang.String getLineSeparator()
public void setLineSeparator(java.lang.String lineSeparator)
@Nullable @Optional @Input public java.lang.String getComment()
public void setComment(@Nullable java.lang.String comment)
@Input public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
@OutputFile public java.io.File getOutputFile()
public void setOutputFile(java.io.File outputFile)
public void setOutputFile(java.lang.Object outputFile)
public void writeProperties() throws java.io.IOException
java.io.IOException