← All recipes
Open source

Add a new property

Recipe IDorg.openrewrite.properties.AddProperty
Artifactorg.openrewrite:rewrite-properties

Adds 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.

Single recipeApache 2.0

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.0

Options

NameTypeDescription
propertyrequiredStringThe property key to add.
e.g. management.metrics.enable.process.files
valuerequiredStringThe value of the new property key.
e.g. newPropValue
commentStringA comment that will be added to the new property.
e.g. This is a comment
delimiterStringProperty entries support different delimiters (=, :, or whitespace). The default value is = unless provided the delimiter of the new property entry.
e.g. :
orderedInsertionBooleanWhether to attempt adding the property in an order following alphabetic sorting. The default value is true.
e.g. false
insertModeInsertModeChoose 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.
insertPropertyStringThe 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