GeezerVison is showing github.com — Fall back on SOURCE_DATE_EPOCH if it exists (3.x) (#281) · apache/maven-archiver@165e1eb
File tree
Expand file treeCollapse file tree
Open diff view settings
src/main/java/org/apache/maven/archiver
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: pom.xml +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
115 | 115 | <scope>test</scope> |
116 | 116 | </dependency> |
117 | 117 | </dependencies> |
| 118 | + |
| 119 | + <build> |
| 120 | + <pluginManagement> |
| 121 | + <plugins> |
| 122 | + <plugin> |
| 123 | + <groupId>org.apache.maven.plugins</groupId> |
| 124 | + <artifactId>maven-surefire-plugin</artifactId> |
| 125 | + <configuration> |
| 126 | + <redirectTestOutputToFile>true</redirectTestOutputToFile> |
| 127 | + <excludedEnvironmentVariables> |
| 128 | + <excludedEnvironmentVariable>SOURCE_DATE_EPOCH</excludedEnvironmentVariable> |
| 129 | + </excludedEnvironmentVariables> |
| 130 | + </configuration> |
| 131 | + </plugin> |
| 132 | + </plugins> |
| 133 | + </pluginManagement> |
| 134 | + </build> |
| 135 | + |
118 | 136 | </project> |
Collapse file
Copy file name to clipboardExpand all lines: src/main/java/org/apache/maven/archiver/MavenArchiver.java +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -755,9 +755,15 @@ public Date configureReproducible(String outputTimestamp) { |
755 | 755 | * section 4.4.6. |
756 | 756 | */ |
757 | 757 | public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp) { |
758 | | - // Fail-fast on nulls |
759 | | - if (outputTimestamp == null) { |
760 | | - return Optional.empty(); |
| 758 | + final String sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH"); |
| 759 | + // Fail fast on null and no timestamp configured (1 character configuration is useful to override |
| 760 | + // a full value during pom inheritance) |
| 761 | + if (outputTimestamp == null || (outputTimestamp.length() < 2 && !isNumeric(outputTimestamp))) { |
| 762 | + if (sourceDateEpoch == null) { |
| 763 | + return Optional.empty(); |
| 764 | + } else { |
| 765 | + outputTimestamp = sourceDateEpoch; |
| 766 | + } |
761 | 767 | } |
762 | 768 |
|
763 | 769 | // Number representing seconds since the epoch |
@@ -771,12 +777,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp |
771 | 777 | return Optional.of(date); |
772 | 778 | } |
773 | 779 |
|
774 | | - // no timestamp configured (1 character configuration is useful to override a full value during pom |
775 | | - // inheritance) |
776 | | - if (outputTimestamp.length() < 2) { |
777 | | - return Optional.empty(); |
778 | | - } |
779 | | - |
780 | 780 | try { |
781 | 781 | // Parse the date in UTC such as '2011-12-03T10:15:30Z' or with an offset '2019-10-05T20:37:42+06:00'. |
782 | 782 | final Instant date = OffsetDateTime.parse(outputTimestamp) |
|