org.gradle.api.tasks

## 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>

      @Incubating
      @CacheableTask
      public class WriteProperties
      extends DefaultTask

  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:
    `Properties.store(OutputStream, String)`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.gradle.api.Task

      `Task.Namer`

  - ### Field Summary

    - ### Fields inherited from interface org.gradle.api.Task

      `TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WriteProperties()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getComment()` Returns the optional comment to add at the beginning of the properties file.
    `String` | `getEncoding()` Returns the encoding used to write the properties file.
    `String` | `getLineSeparator()` Returns the line separator to be used when creating the properties file.
    `File` | `getOutputFile()` Returns the output file to write the properties to.
    `Properties` | `getProperties()` Returns the properties to be written to the output file.
    `void` | `setComment(String comment)` Sets the optional comment to add at the beginning of the properties file.
    `void` | `setEncoding(String encoding)` Sets the encoding used to write the properties file.
    `void` | `setLineSeparator(String lineSeparator)` Sets the line separator to be used when creating the properties file.
    `void` | `setOutputFile(Object outputFile)` Sets the output file to write the properties to.
    `void` | `setProperties(Map<?,?> properties)` Sets all properties to be written to the output file.
    `void` | `writeProperties()`

    - ### Methods inherited from class org.gradle.api.internal.AbstractTask

      `addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doLast, doLast, execute, finalizedBy, getActionClassLoaders, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### WriteProperties

          public WriteProperties()

  - ### Method Detail

    - #### getProperties

          @Input
          public Properties getProperties()

      Returns the properties to be written to the output file.

    - #### setProperties

          public void setProperties(Map<?,?> properties)

      Sets all properties to be written to the output file.

    - #### getLineSeparator

          @Input
          public String getLineSeparator()

      Returns the line separator to be used when creating the properties file. Defaults to `\n`.

    - #### setLineSeparator

          public void setLineSeparator(String lineSeparator)

      Sets the line separator to be used when creating the properties file.

    - #### getComment

          @Input
          @Optional
          public String getComment()

      Returns the optional comment to add at the beginning of the properties file.

    - #### setComment

          public void setComment(String comment)

      Sets the optional comment to add at the beginning of the properties file.

    - #### getEncoding

          @Input
          public String getEncoding()

      Returns the encoding used to write the properties file. Defaults to ISO_8859_1. If set to anything different, unicode escaping is turned off.

    - #### setEncoding

          public void setEncoding(String encoding)

      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

          @OutputFile
          public File getOutputFile()

      Returns the output file to write the properties to.

    - #### setOutputFile

          public void setOutputFile(Object outputFile)

      Sets the output file to write the properties to.

    - #### writeProperties

          public void writeProperties()
                               throws IOException

      Throws:
        `IOException`