# WriteProperties

API Documentation: | `WriteProperties`

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.

### Properties

Property | Description
`comment` | The optional comment to add at the beginning of the properties file.
`destinationFile` | The output properties file.
`encoding` | The encoding used to write the properties file. Defaults to ISO_8859_1. If set to anything different, unicode escaping is turned off.
`lineSeparator` | The line separator to be used when creating the properties file. Defaults to `\n`.
`outputFile` | Deprecated The output file to write the properties to.
`properties` | Returns an immutable view of properties to be written to the properties file.

### Methods

Method | Description
`properties(properties)` | Adds multiple properties to be written to the properties file.
`property(name, value)` | Adds a property to be written to the properties file.

### Script blocks

No script blocks

### Property details

#### `String` `comment`

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

Default:
  `null`

#### `RegularFileProperty` `destinationFile`

The output properties file.

Default:
  `null`

#### `String` `encoding`

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

Default:
  `ISO-8859-1`

#### `String` `lineSeparator`

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

Default:
  `'\n'`

#### `File` `outputFile`

Note: This property is deprecated and will be removed in the next major version of Gradle.

The output file to write the properties to.

Default:
  `null`

#### ``Map`<`String`, `String`>` `properties`

Returns an immutable view of properties to be written to the properties file.

Default:
  `[:]`

### Method details

#### `void` `properties`(``Map`<`String`, `Object`>` properties)

Adds multiple properties to be written to the properties file.

This is a convenience method for calling `WriteProperties.property(java.lang.String, java.lang.Object)` multiple times.

#### `void` `property`(`String` name, `Object` value)

Adds a property to be written to the properties file.

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.