Mat*_*att 2 maven-plugin maven
我想编写一个 Maven 插件,它在构建过程中在特定源文件中进行简单的查找和替换。这可能吗?
对的,这是可能的。您应该阅读Java 插件开发指南。
也许您可以使用现有插件,而不是创建新插件。
示例com.google.code.maven-replacer-plugin:replacer:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<configuration>
<file>FILE PATH (example: ${basedir}/src/main/webapp/index.html)</file>
<token>SEARCHED TEXT (example: .css)</token>
<value>REPLACEMENT (example: .min.css)</value>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果你想替换 XML 数据,那么你应该使用CDATA部分:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<configuration>
<file>${basedir}/src/main/webapp/WEB-INF/web.xml</file>
<token><![CDATA[SEARCHED TEXT (example: <foo>)]]></token>
<value><![CDATA[REPLACEMENT (example: <foo2>)]]></value>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2822 次 |
| 最近记录: |