mirror of https://github.com/apache/maven.git
[MNG-2562] expose current time as a property for POM interpolation
o Extended IT to check custom format support as well git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@783803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ff97d2d940
commit
5f8b556477
|
@ -36,10 +36,10 @@ public class MavenITmng2562TimestampTest
|
|||
super( "[2.1.0-M1,)" ); // 2.1.0+ only
|
||||
}
|
||||
|
||||
public void testitMNG2562()
|
||||
public void testitDefaultFormat()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562" );
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562/default" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
|
@ -48,11 +48,38 @@ public class MavenITmng2562TimestampTest
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/pom.properties" );
|
||||
String timestamp = props.getProperty( "project.properties.timestamp", "" );
|
||||
assertTrue( timestamp, timestamp.matches( "[0-9]{8}-[0-9]{4}" ) );
|
||||
Date date = new SimpleDateFormat( "yyyyMMdd-HHmm" ).parse( timestamp );
|
||||
assertTrue( new Date() + " vs " + date, Math.abs( System.currentTimeMillis() - date.getTime() ) < 24 * 60 * 60 * 1000 );
|
||||
|
||||
String timestamp1 = props.getProperty( "project.properties.timestamp1", "" );
|
||||
assertTrue( timestamp1, timestamp1.matches( "[0-9]{8}-[0-9]{4}" ) );
|
||||
Date date = new SimpleDateFormat( "yyyyMMdd-HHmm" ).parse( timestamp1 );
|
||||
assertTrue( now + " vs " + date, Math.abs( now.getTime() - date.getTime() ) < 24 * 60 * 60 * 1000 );
|
||||
|
||||
String timestamp2 = props.getProperty( "project.properties.timestamp2", "" );
|
||||
assertEquals( timestamp1, timestamp2 );
|
||||
}
|
||||
|
||||
public void testitCustomFormat()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562/custom" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/pom.properties" );
|
||||
|
||||
String timestamp1 = props.getProperty( "project.properties.timestamp", "" );
|
||||
Date date = new SimpleDateFormat( "mm:HH dd-MM-yyyy" ).parse( timestamp1 );
|
||||
assertTrue( now + " vs " + date, Math.abs( now.getTime() - date.getTime() ) < 24 * 60 * 60 * 1000 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng2562</groupId>
|
||||
<artifactId>timestamp</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0</version>
|
||||
|
||||
<name>Maven Integration Test :: MNG-2562</name>
|
||||
<description>
|
||||
Verify that the format of the timestamp can be customized via maven.build.timestamp.format.
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>mm:HH dd-MM-yyyy</maven.build.timestamp.format>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<artifactId>maven-it-plugin-expression</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>eval</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<outputFile>target/pom.properties</outputFile>
|
||||
<expressions>
|
||||
<expression>project/properties</expression>
|
||||
</expressions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -32,7 +32,8 @@ under the License.
|
|||
</description>
|
||||
|
||||
<properties>
|
||||
<timestamp>${build.timestamp}</timestamp>
|
||||
<timestamp1>${maven.build.timestamp}</timestamp1>
|
||||
<timestamp2>${build.timestamp}</timestamp2>
|
||||
</properties>
|
||||
|
||||
<build>
|
Loading…
Reference in New Issue