Add a new property
Recipe ID
org.openrewrite.properties.AddPropertyArtifact
org.openrewrite:rewrite-propertiesAdds a new property to a property file. Attempts to place the new property in alphabetical order by the property keys. Whitespace before and after the = must be included in the property and value.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.properties.AddProperty --recipe-option "property=management.metrics.enable.process.files" --recipe-option "value=newPropValue"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite:rewrite-properties:8.88.0Options
| Name | Type | Description |
|---|---|---|
propertyrequired | String | The property key to add. e.g. management.metrics.enable.process.files |
valuerequired | String | The value of the new property key. e.g. newPropValue |
comment | String | A comment that will be added to the new property. e.g. This is a comment |
delimiter | String | Property entries support different delimiters (=, :, or whitespace). The default value is = unless provided the delimiter of the new property entry.e.g. : |
orderedInsertion | Boolean | Whether to attempt adding the property in an order following alphabetic sorting. The default value is true.e.g. false |
insertMode | InsertMode | Choose an insertion point relative to an existing property. Default is Last. Takes precedence over orderedInsertion. If the referenced property does not exist, falls back to default behavior. |
insertProperty | String | The key of an existing property to use as the reference point for the insert mode. Required when insertMode is Before or After.e.g. server.port |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats