logo maven-replacer-plugin Maven Mojo

Maven plugin to replace tokens in a given file with a value

homepage: code.google.com/p/maven-replacer-plugin
fresh index:
last release: 8 years ago, first release: 10 years ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
replacer:replace (phase: compile)

Goal replaces token with value inside file

replacer:help

Display help information on replacer. Call mvn replacer:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

Often used code snippets:

<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.2</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <id>replace-for-swagger-genenerated-code-publisher</id>
      <goals>
        <goal>replace</goal>
      </goals>
      <configuration>
        <file>${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java</file>
        <replacements>
          <replacement>
            <token>CURRENT_TENANT</token>
            <value>current_tenant</value>
          </replacement>
          <replacement>
            <token>ALL_TENANTS</token>
            <value>all_tenants</value>
          </replacement>
          <replacement>
            <token>SPECIFIC_TENANTS</token>
            <value>specific_tenants</value>
          </replacement>
        </replacements>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.3</version>
  <configuration>
    <basedir>${basedir}/target/xwiki/</basedir>
    <regex>false</regex>
    <commentsEnabled>false</commentsEnabled>
    <skip>${skipTests}</skip>
  </configuration>
  <executions>
    <execution>
      <id>change-web-pom</id>
      <phase>generate-test-resources</phase>
      <goals>
        <goal>replace</goal>
      </goals>
      <configuration>
        <filesToInclude>webapps/xwiki/META-INF/extension.xed</filesToInclude>
        <replacements>
          <replacement>
            <token>&amp;lt;maven.artifactid&amp;gt;xwiki-platform-web&amp;lt;/maven.artifactid&amp;gt;</token>
            <value>&amp;lt;maven.artifactid&amp;gt;xwiki-platform-web&amp;lt;/maven.artifactid&amp;gt;
                    &amp;lt;xwiki.extension.distribution.wikiui&amp;gt;org.xwiki.platform:xwiki-platform-wiki-ui-wiki&amp;lt;/xwiki.extension.distribution.wikiui&amp;gt;</value>
          </replacement>
        </replacements>
      </configuration>
    </execution>
    <execution>
      <id>change-xwiki.properties</id>
      <phase>generate-test-resources</phase>
      <goals>
        <goal>replace</goal>
      </goals>
      <configuration>
        <filesToInclude>webapps/xwiki/WEB-INF/xwiki.properties</filesToInclude>
        <replacements>
          <replacement>
            <token># distribution.automaticStartOnMainWiki=true</token>
            <value>distribution.automaticStartOnMainWiki=false</value>
          </replacement>
        </replacements>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.3</version>
  <configuration>
    <basedir>${basedir}/target/xwiki/</basedir>
    <regex>false</regex>
    <commentsEnabled>false</commentsEnabled>
    <skip>${skipTests}</skip>
  </configuration>
  <executions>
    <execution>
      <id>change-xwiki.properties</id>
      <phase>generate-test-resources</phase>
      <goals>
        <goal>replace</goal>
      </goals>
      <configuration>
        <filesToInclude>webapps/xwiki/WEB-INF/xwiki.properties</filesToInclude>
        <replacements>
          <replacement>
            <token># watchlist.enabled = false</token>
            <value>watchlist.enabled = true</value>
          </replacement>
        </replacements>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.2</version>
  <configuration>
    <includes>
      <include>**/*Constants_de.properties</include>
      <include>**/*Constants_es.properties</include>
      <include>**/*Constants_fr.properties</include>
      <include>**/*Constants_ja.properties</include>
      <include>**/*Constants_pt_BR.properties</include>
      <include>**/*Constants_zh_CN.properties</include>
      <include>**/*Constants_ru.properties</include>
    </includes>
    <excludes>
      <exclude>**/ErraiApp.properties</exclude>
    </excludes>
    <replacements>
      <replacement>
        <token>''</token>
        <value>'</value>
      </replacement>
      <replacement>
        <token>'</token>
        <value>''</value>
      </replacement>
    </replacements>
  </configuration>
</plugin>
<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.3</version>
  <executions>
    <execution>
      <phase>process-sources</phase>
      <goals>
        <goal>replace</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <ignoreMissingFile>false</ignoreMissingFile>
    <file>${project.build.sourceDirectory}/junit/runner/Version.java.template</file>
    <outputFile>${project.build.sourceDirectory}/junit/runner/Version.java</outputFile>
    <regex>false</regex>
    <token>@version@</token>
    <value>${project.version}</value>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.