-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set a property based on the maven.build.timestamp
- Loading branch information
1 parent
e557609
commit 0fd59ec
Showing
9 changed files
with
265 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>localdomain.localhost</groupId> | ||
<artifactId>timestamp-timesource</artifactId> | ||
<version>1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>timestamp-timesource-module-1</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Timestamp TimeSource Module 1</name> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<excludes> | ||
<exclude>test.properties</exclude> | ||
</excludes> | ||
<filtering>false</filtering> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>test.properties</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
2 changes: 2 additions & 0 deletions
2
src/it/timestamp-timesource/module-1/src/main/resources/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.version=${module.build.timestamp} | ||
session.version=${session.build.timestamp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>localdomain.localhost</groupId> | ||
<artifactId>timestamp-timesource</artifactId> | ||
<version>1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>timestamp-timesource-module-2</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Timestamp TimeSource Module 2</name> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<excludes> | ||
<exclude>test.properties</exclude> | ||
</excludes> | ||
<filtering>false</filtering> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>test.properties</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
2 changes: 2 additions & 0 deletions
2
src/it/timestamp-timesource/module-2/src/main/resources/test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.version=${module.build.timestamp} | ||
session.version=${session.build.timestamp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>localdomain.localhost</groupId> | ||
<artifactId>timestamp-timesource</artifactId> | ||
<version>1-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<name>Timestamp TimeSource</name> | ||
<description> | ||
Tests that a fixed timestamp gets generated | ||
</description> | ||
|
||
<modules> | ||
<module>module-1</module> | ||
<module>module-2</module> | ||
</modules> | ||
|
||
<properties> | ||
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss.SSS z</maven.build.timestamp.format> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>module-timestamp-property</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>timestamp-property</goal> | ||
</goals> | ||
<configuration> | ||
<name>module.build.timestamp</name> | ||
<pattern>${maven.build.timestamp.format}</pattern> | ||
<timeZone>Europe/Amsterdam</timeZone> | ||
<!-- <timeSource>current</timeSource> --> | ||
</configuration> | ||
</execution> | ||
|
||
<execution> | ||
<id>session-timestamp-property</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>timestamp-property</goal> | ||
</goals> | ||
<configuration> | ||
<name>session.build.timestamp</name> | ||
<pattern>${maven.build.timestamp.format}</pattern> | ||
<timeZone>Europe/Amsterdam</timeZone> | ||
<timeSource>build</timeSource> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
try | ||
{ | ||
File module1File = new File( basedir, "module-1/target/classes/test.properties" ); | ||
File module2File = new File( basedir, "module-2/target/classes/test.properties" ); | ||
|
||
Properties module1Props = new Properties(); | ||
module1Props.load( new FileInputStream( module1File ) ); | ||
Properties module2Props = new Properties(); | ||
module2Props.load( new FileInputStream( module2File ) ); | ||
|
||
String module1ModuleVersion = module1Props.getProperty( "module.version" ); | ||
String module1SessionVersion = module1Props.getProperty( "session.version" ); | ||
String module2ModuleVersion = module2Props.getProperty( "module.version" ); | ||
String module2SessionVersion = module2Props.getProperty( "session.version" ); | ||
|
||
if ( module1ModuleVersion.indexOf( "${module.build.timestamp}" ) >= 0 | ||
|| module2ModuleVersion.indexOf( "${module.build.timestamp}" ) >= 0) | ||
{ | ||
System.err.println( "Module timestamp not set" ); | ||
return false; | ||
} | ||
else if ( module1SessionVersion.indexOf( "${session.build.timestamp}" ) >= 0 | ||
|| module2SessionVersion.indexOf( "${session.build.timestamp}" ) >= 0) | ||
{ | ||
System.err.println( "Session timestamp not set" ); | ||
return false; | ||
} | ||
|
||
if ( module1ModuleVersion.equals( module2ModuleVersion ) ) | ||
{ | ||
System.err.println( "Module timestamps should not match by design" ); | ||
return false; | ||
} | ||
else if ( !module1SessionVersion.equals( module2SessionVersion ) ) | ||
{ | ||
System.err.println( "Session timestamps should match by design" ); | ||
return false; | ||
} | ||
} | ||
catch( Throwable t ) | ||
{ | ||
t.printStackTrace(); | ||
return false; | ||
} | ||
|
||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters