Replace task in Maven Antrun Plugin

I use the antrun plugin in my maven assembly to replace the @version @ token in some JSP files with the application version. This is what I do:

<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 pass displayVersion as parameter to maven

mvn clean install -DdisplayVersion="Version-1.1"

And this is the console output for the 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 correctly repeated, it is not replaced in my JSP. The current @version @ is replaced with {displayVersion} , not the actual value.

+3
source share
2 answers

Use the Maven Resources Filtering suggested by Aaron 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 standard delimiters -->
        <delimiter>${*}</delimiter>
        <!-- enable your @delimiters@ -->
        <delimiter>@</delimiter>
      </delimiters>
    </configuration>
</plugin>
+6

Maven ; , JSP ( jspc), , .

+1

All Articles