linux - Maven 日期格式不正确

标签 linux windows maven date jenkins

我已经在我的 pom.xml 文件上打开了对 Web 资源的过滤。我正在使用 Maven 在 jsp 中更新构建日期。

为此,我在 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 , 年)。它以其他格式显示,例如它显示 20131022-1416。

我找不到问题所在。是因为 linux 系统,还是 jenkins,或者不同的 maven 版本。

最佳答案

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

pom 配置:

<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}

关于linux - Maven 日期格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19793762/

相关文章:

linux - 有多少方法可以在客户端尽快减少TIME_WAIT的数量

linux - 是否可以用 AWK 编写语言解析器?

ruby-on-rails - 并发 Net::HTTP.get 到同一个域

python - 从 python 访问备用剪贴板格式

javascript - 在maven Spark java应用程序中运行html文件

linux - 创建指向所有子文件夹的大量符号链接(symbolic link)

c++ - 在终端中正确输出 c++ windows wstring 日志

windows - SVN Committing 从今天开始就坏了

java - maven:如何为本地安装的依赖指定 "systemPath"?

git - wagon-git 和 Gradle