I am using antrun plugin in my maven build to replace a token @version@ in some of the JSP files with the application version. This is what I am doing:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<echo>${displayVersion}</echo>
<replace file="src/main/webapp/admin/decorators/default.jsp" token="@version@" value="${displayVersion}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I am passing displayVersion as a parameter to maven
mvn clean install -DdisplayVersion="Version-1.1"
And this is the console output for Antrun Plugin
[INFO] [antrun:run {execution: default}]
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
main:
[echo] 9.4_70
[INFO] Executed tasks
Although the property is being echoed properly, it's not substituted in my JSP. The @version@ token is replaced by {displayVersion} and not it's actual value.
Use Maven Resources Filtering as Aaron suggested and set the delimiters in the Maven Resource Plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<delimiters>
<!-- enable maven's standard delimiters -->
<delimiter>${*}</delimiter>
<!-- enable your @delimiters@ -->
<delimiter>@</delimiter>
</delimiters>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With