GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • pom.xml
  • src/main/java/org/apache/maven/archiver
    • MavenArchiver.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pom.xml‎

Copy file name to clipboardExpand all lines: pom.xml
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,22 @@
115115
<scope>test</scope>
116116
</dependency>
117117
</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+
118136
</project>
Collapse file

‎src/main/java/org/apache/maven/archiver/MavenArchiver.java‎

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 numberDiff line numberDiff line change
@@ -755,9 +755,15 @@ public Date configureReproducible(String outputTimestamp) {
755755
* section 4.4.6.
756756
*/
757757
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+
}
761767
}
762768

763769
// Number representing seconds since the epoch
@@ -771,12 +777,6 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
771777
return Optional.of(date);
772778
}
773779

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-
780780
try {
781781
// Parse the date in UTC such as '2011-12-03T10:15:30Z' or with an offset '2019-10-05T20:37:42+06:00'.
782782
final Instant date = OffsetDateTime.parse(outputTimestamp)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.