我在我的maven版本中使用antrun插件来替换某些具有应用程序版本的JSP文件中的令牌@ version @。 这是我在做什么:替换Maven Antrun插件中的任务
<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="@[email protected]" value="${displayVersion}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
我传递displayVersion作为参数到Maven
mvn clean install -DdisplayVersion="Version-1.1"
这是Antrun插件
[INFO] [antrun:run {execution: default}]
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
main:
[echo] 9.4_70
[INFO] Executed tasks
控制台输出
虽然属性是被正确回应,它不会被我的JSP取代。 @ version @令牌被替换为{displayVersion}而不是它的实际值。
在你发布你实际使用'值antrun配置=“$ {显示}”',而不是'值=” $ {displayVersion}“',是原始代码中的拼写错误还是cut'n'paste问题? – skuro 2011-03-17 14:28:05
它是一个错字...我的坏。我已经编辑了这个问题来纠正相同的问题 – Arpit 2011-03-17 14:30:28