Reputation: 2541
I am planning to replace contents of some file from src directory into the war without changing the file in Src directory. So I am using the maven-replacer-plugin
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<!-- the replace should happen before the app is packaged -->
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<!-- replace the token in this file -->
<include>target/**/*.html</include>
</includes>
<regex>false</regex>
<!-- the name of the token to replace -->
<token>BUILD_TIME</token>
<!-- replace it with the maven project version -->
<value>${timestamp}</value>
</configuration>
I see the file getting replaced in target director during the prepare-package phase. This I confirm by just running mvn prepare-package and I see the BUILD_TIME being replace by the build time. But when the package phase is executed the content from src directory is being replaced. From the below screen shot I can see that during the next phases after prepare-package the web app resource is being copied from the src directory which is causing the issue.
I tried to use this pluggin during package phase also without any success(I am able to see the build time in the html of the target directories but not inside war).
Upvotes: 0
Views: 1153
Reputation: 2541
Finally found the issue, by default maven war pluggin uses the source directory to package the war. In order to override this we need to use warSourceDirectory to specify the location to pick from.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>target/illinois</warSourceDirectory>
</configuration>
</plugin>
Upvotes: 0