这是相关部分pom.xml
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>pre-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/swagger/api.json</file>
<regex>false</regex>
<token>$BUILD_NUMBER$</token>
<value>${project.version}</value>
</configuration>
</plugin>
这是api.json
文件
{
"apiVersion": "$BUILD_NUMBER$"
"developers": ["foo", "bar"]
}
运行后mvn clean package
,我看不到target/swagger/api.json
被更新project.version