【问题标题】:maven replacer plugin in not workingmaven替换插件不起作用
【发布时间】:2015-06-03 00:32:06
【问题描述】:

这里是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.jsonproject.version 更新

【问题讨论】:

    标签: maven maven-replacer-plugin


    【解决方案1】:

    确保您的插件声明位于&lt;build&gt;&lt;plugins&gt;

    而不是&lt;build&gt;&lt;pluginManagement&gt;&lt;plugins&gt;

    另外,如果您的项目是更大的 maven 项目的一部分,使用 ${project.build.directory} 而不是 target 会更安全:

    &lt;file&gt;target/swagger/api.json&lt;/file&gt;

    【讨论】:

      【解决方案2】:
      1. 考虑一下要替换它的 maven 构建阶段,在使用 swagger f.ex 生成文档之前选择一个阶段。 “验证”并将 swagger 文档生成设置为“编译”
        1. 将 $BUILD_NUMBER$ 兑换成 %BUILD_NUMBER%
        2. 考虑一下这种方式,您需要再次手动将值重置为 %BUILD_NUMBER%

      【讨论】:

        猜你喜欢
        • 2020-06-17
        • 2017-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-26
        • 2016-02-05
        • 2011-11-11
        • 2017-07-06
        相关资源
        最近更新 更多