The ReplaceText transform allows replacing one or several text tokens in files as they are being copied to their destination. The replacement values are the result of dynamic evaluation of SpEL expressions.

Since this transform is text oriented, it needs to know how to interpret the stream of bytes that make up the file contents into text. By default, all files are assumed to use UTF-8 encoding, but the UseEncoding transform can be used upfront to specify a different charset to use on (some) files.

Syntax Reference

type: ReplaceText
substitutions:
  - text: <string>
    with: <SpEL expression>
  - text: <string>
   <with>: <SpEL expression>
  - ..
condition: <SpEL expression>

Examples

Replacing the hardcoded string "hello-world-app" with the value of variable #artifactId in all .md, .xml and .yaml files:

include: ['**/*.md', '**/*.xml', '**/*.yaml']
chain:
  - type: ReplaceText
    substitutions:
      - text: "hello-world-app"
        with: "#artifactId"

Doing the same in the README-fr.md and README-de.md files, which are encoded using the ISO-8859-1 charset:

include: ['README-fr.md', 'README-de.md']
chain:
  - type: UseEncoding
    encoding: 'ISO-8859-1' 
  - type: ReplaceText
    substitutions:
      - text: "hello-world-app"
        with: "#artifactId"

See Also

check-circle-line exclamation-circle-line close-line
Scroll to top icon