buildnumber-maven-plugin两次增加buildNumber

时间:2017-07-20 20:51:04

标签: java maven plugins

我是Maven的新用户,并且很难获得buildnumber-maven-plugin来做我期望的事情。本质上,我希望maven构建我的项目并创建结果的JAR文件,并在manifest.mf文件中设置内部版本号。我将在下面包含我的大部分pom.xml文件。

当我运行:mvn clean compile package时,我在输出中看到buildNumber的两个提及:

...
[INFO] --- buildnumber-maven-plugin:1.4:create (buildnumber) @ xcase ---
[INFO] Storing buildNumber: 12 at timestamp: 1500583427060
...
[INFO] --- buildnumber-maven-plugin:1.4:create (buildnumber) @ xcase ---
[INFO] Storing buildNumber: 13 at timestamp: 1500583444250
...

在我的清单文件中,我可以看到构建是:

实施 - 建设:13

如果我再次运行mvn命令,那么它会增加到15.为什么会这样?

以下是我的pom.xml文件的相关片段:

  <build>
    <outputDirectory>build</outputDirectory>
    <plugins>
      <plugin>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <configuration>
          <buildNumberPropertyName>buildNumber</buildNumberPropertyName>
          <doCheck>false</doCheck>
          <doUpdate>false</doUpdate>
          <format>{0,number,integer}</format>
          <items>
            <item>buildNumber</item>
          </items>
          <revisionOnScmFailure>true</revisionOnScmFailure>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>create</goal>
            </goals>
            <id>buildnumber</id>
          </execution>
        </executions>
        <groupId>org.codehaus.mojo</groupId>
        <version>1.4</version>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/build</outputDirectory>
              <resources>          
                <resource>
                  <directory>${basedir}</directory>
                  <filtering>true</filtering>
                  <excludes>
                    <exclude>*local*.properties</exclude>
                  </excludes>
                  <includes>
                    <include>*.properties</include>
                  </includes>
                </resource>
                <resource>
                  <directory>${basedir}/src/java</directory>
                  <filtering>true</filtering>
                  <includes>
                    <include>log4j2.xml</include>
                  </includes>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.1</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
            <manifestEntries>
              <Implementation-Build>${buildNumber}</Implementation-Build>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
    <sourceDirectory>src/java</sourceDirectory>
  </build>

0 个答案:

没有答案