A maven plugin for replacing content in files, filenames and directories.
Note
This is a fork of floverfelt/find-and-replace-maven-plugin with some additional functionality.
A short usage guide is available in the plugin docs.
Example: Replace underscores with hyphen
<plugin>
<groupId>software.xdev</groupId>
<artifactId>find-and-replace-maven-plugin</artifactId>
<executions>
<execution>
<id>replace-underscore-with-hyphen</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>testing/</baseDir>
<fileMask>test.txt</fileMask>
<findRegex>_</findRegex>
<replaceValue>-</replaceValue>
</configuration>
</execution>
</executions>
</plugin>
Replace contents of auto-generated files (OpenAPI generator)
<plugin>
<groupId>software.xdev</groupId>
<artifactId>find-and-replace-maven-plugin</artifactId>
<executions>
<execution>
<!-- Remove so that we don't need additional dependency -->
<id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir>
<fileMask>ApiClient.java</fileMask>
<!-- @formatter:off DO NOT INTRODUCE LINE BREAK -->
<findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex>
<!-- @formatter:on -->
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
<execution>
<!-- Changes with each generator version -->
<id>remove-generated-annotation</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
<recursive>true</recursive>
<fileMask>.java</fileMask>
<findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex>
<replaceAll>false</replaceAll>
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
<execution>
<!-- Requiring Java serialization indicates a serious misuse of the API -->
<id>remove-serialVersionUID</id>
<phase>process-sources</phase>
<goals>
<goal>file-contents</goal>
</goals>
<configuration>
<baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir>
<recursive>true</recursive>
<fileMask>.java</fileMask>
<findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex>
<replaceAll>false</replaceAll>
<replaceLineBased>false</replaceLineBased>
</configuration>
</execution>
</executions>
</plugin>
Installation guide for the latest release
If you need support as soon as possible and you can't wait for any pull request, feel free to use our support.
See the contributing guide for detailed instructions on how to get started with our project.
View the license of the current project or the summary including all dependencies