Maven日期格式不正确

时间:2013-11-05 16:22:28

标签: linux windows maven date jenkins

我已打开过滤我的pom.xml文件以获取网络资源。我正在使用maven更新jsp中的build-date。

为此,我在pom.xml中写了以下几行。

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.build.timestamp.format>MMM dd, yyyy</maven.build.timestamp.format>
        <build-date>${maven.build.timestamp}</build-date>
    </properties>

        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <id>default-war</id>
                <phase>package</phase>
                <goals>
                    <goal>war</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <webResources>
                <resource>
                    <directory>src/main/webapp</directory>
                    <filtering>true</filtering>
                </resource>
            </webResources>
        </configuration>
    </plugin>

在我的jsp中,我写日期为 -

<span class="note">Last updated on ${build-date}</span>

当我在我的Windows系统上构建它时,它完美地运行并以正确的格式替换日期(MMM dd,yyyy)但是当我在linux系统上使用jenkins构建这个项目时,日期格式不正确(不是MMM dd) ,yyyy)。它以其他一些格式显示,例如它显示20131022-1416。

我无法找到问题。是由于Linux系统,还是jenkins,还是不同的maven版本。

1 个答案:

答案 0 :(得分:1)

我有同样的问题,似乎有一个maven问题。要绕过我已使用此maven-timestamp-plugin填充$ {timestamp} maven变量,然后我在release.properties文件中引用该变量:

pom config:

<plugin>
  <!-- workaround for ${maven.build.timestamp} not being available when filtering resources -->
  <groupId>com.keyboardsamurais.maven</groupId>
  <artifactId>maven-timestamp-plugin</artifactId>
  <version>1.0</version>
  <configuration>
    <propertyName>timestamp</propertyName>
    <timestampPattern>dd/MM/yyyy HH:mm:ss z</timestampPattern>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>create</goal>
      </goals>
    </execution>
  </executions>
</plugin>

属性文件:

# date when the current release was built
build.date=${timestamp}
相关问题