amphibient
amphibient

Reputation: 31248

Replacing tokens in web.xml using Google Maven replacer for WAR packaging

My web.xml is under ${project.root}\src\main\webapp\WEB-INF.

I would like to use the com.google.code.maven-replacer-plugin to replace some tokens inside it when it is packaged in the WAR but not in the source directory.

I tried:

<plugin>
  <groupId>com.google.code.maven-replacer-plugin</groupId>
  <artifactId>replacer</artifactId>
  <version>1.5.2</version>
  <executions>
    <execution>
      <phase>prepare-package</phase>
      <goals>
        <goal>replace</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <file>src/main/webapp/WEB-INF/web.xml</file>
    <replacements>
      <replacement>
        <token>@@sec.level@@</token>
        <value>local</value>
      </replacement>
    </replacements>
  </configuration>
</plugin>

But I got

[ERROR] File '.\src\main\webapp\WEB-INF\web.xml' does not exist

Since this file is not copied under the target file structure and is just taken from the source directly into the WAR (or so I think), how do I reference its path in the above configuration->file parameter so that the replacer finds it and replaces the tokens?

Upvotes: 0

Views: 701

Answers (1)

ravthiru
ravthiru

Reputation: 9633

Try using the path as follows

${project.basedir}/src/main/webapp/WEB-INF/web.xml

More information on different variable maven properties

Upvotes: 1

Related Questions