Class WriteProperties
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.tasks.WriteProperties
- All Implemented Interfaces:
Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Task, org.gradle.util.Configurable<Task>
Writes a
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:
- no timestamp comment is generated at the beginning of the file
- the lines in the resulting files are separated by a pre-set separator (defaults to '\n') instead of the system default line separator
- the properties are sorted alphabetically
Like with Properties, Unicode characters are escaped when using the
default Latin-1 (ISO-8559-1) encoding.
- Since:
- 3.3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Task
Task.Namer -
Field Summary
Fields inherited from interface Task
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the optional comment to add at the beginning of the properties file.Returns the encoding used to write the properties file.Returns the line separator to be used when creating the properties file.Returns the output file to write the properties to.Returns an immutable view of properties to be written to the properties file.voidproperties(Map<String, Object> properties) Adds multiple properties to be written to the properties file.voidAdds a property to be written to the properties file.voidsetComment(String comment) Sets the optional comment to add at the beginning of the properties file.voidsetEncoding(String encoding) Sets the encoding used to write the properties file.voidsetLineSeparator(String lineSeparator) Sets the line separator to be used when creating the properties file.voidsetOutputFile(File outputFile) Sets the output file to write the properties to.voidsetOutputFile(Object outputFile) Sets the output file to write the properties to.voidsetProperties(Map<String, Object> properties) Sets all properties to be written to the properties file replacing any existing properties.voidMethods inherited from class DefaultTask
newInputDirectory, newInputFile, newOutputDirectory, newOutputFileMethods inherited from class org.gradle.api.internal.AbstractTask
addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString
-
Constructor Details
-
WriteProperties
public WriteProperties()
-
-
Method Details
-
getProperties
Returns an immutable view of properties to be written to the properties file.- Since:
- 3.3
-
setProperties
-
property
Adds a property to be written to the properties file.A property's value will be coerced to a
StringwithString#valueOf(Object)or aCallablereturning a value to be coerced into aString.Values are not allowed to be null.
- Parameters:
name- Name of the propertyvalue- Value of the property- Since:
- 3.4
-
properties
Adds multiple properties to be written to the properties file.This is a convenience method for calling
property(String, Object)multiple times.- Parameters:
properties- Properties to be added- Since:
- 3.4
- See Also:
-
getLineSeparator
-
setLineSeparator
Sets the line separator to be used when creating the properties file. -
getComment
-
setComment
Sets the optional comment to add at the beginning of the properties file. -
getEncoding
-
setEncoding
Sets the encoding used to write the properties file. Defaults to ISO_8859_1. If set to anything different, unicode escaping is turned off. -
getOutputFile
Returns the output file to write the properties to. -
setOutputFile
Sets the output file to write the properties to.- Since:
- 4.0
-
setOutputFile
Sets the output file to write the properties to. -
writeProperties
- Throws:
IOException
-