0

I have turned on filtering on my pom.xml file for web resources. I am updating build-date in a jsp using maven.

For this, I have written following lines in 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>

In my jsp, I am writing date as -

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

When I build it on my windows system, it works perfectly and replaces date in correct format (MMM dd, yyyy) but when I build this project using jenkins on linux system, date is not in the correct format (not MMM dd, yyyy). It shows in some other format e.g. it shows 20131022-1416.

I am unable to find the problem. Is it due to linux system, or jenkins, or different maven version.

4

1 回答 1

1

我有同样的问题,似乎有一个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}
于 2013-11-05T17:09:21.590 回答