0

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?

amphibient
  • 29,770
  • 54
  • 146
  • 240

1 Answers1

1

Try using the path as follows

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

More information on different variable maven properties

Community
  • 1
  • 1
ravthiru
  • 8,878
  • 2
  • 43
  • 52
  • however, that changes the file in the source and i want to leave the source untouched (keep the token) and only change it in the build and the WAR file – amphibient Aug 23 '16 at 15:37
  • have you tried using ${project.build.directory}, but you need to provide proper phase ( as it has to be done before creating the war file) – ravthiru Aug 23 '16 at 23:12