gpt4 book ai didi

maven - 在 Maven Antrun 插件中替换任务

转载 作者:行者123 更新时间:2023-12-01 10:10:47 24 4
gpt4 key购买 nike

我在我的 Maven 构建中使用 antrun 插件来替换 token @版本@ 在一些带有应用程序版本的 JSP 文件中。
这就是我正在做的:

<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>

我路过 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 中并没有被替换。
@版本@ token 被替换为 {displayVersion} 而不是它的实际值(value)。

最佳答案

按照 Aaron 的建议和 set the delimiters 使用 Maven 资源过滤在 Maven 资源插件中:

<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>

关于maven - 在 Maven Antrun 插件中替换任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5340361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com