Commit 6da253b 1 parent 1f9517c commit 6da253b Copy full SHA for 6da253b
File tree 3 files changed +25
-1
lines changed
buildSrc/src/main/java/org/opensearch/gradle
3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,14 @@ allprojects {
274
274
javadoc. options. addStringOption(' Xdoclint:all,-missing' , ' -quiet' )
275
275
}
276
276
277
+ // support for reproducible builds
278
+ tasks. withType(AbstractArchiveTask ). configureEach {
279
+ // ignore file timestamps
280
+ // be consistent in archive file order
281
+ preserveFileTimestamps = false
282
+ reproducibleFileOrder = true
283
+ }
284
+
277
285
project. afterEvaluate {
278
286
// Handle javadoc dependencies across projects. Order matters: the linksOffline for
279
287
// org.opensearch:opensearch must be the last one or all the links for the
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ public void apply(Project project) {
121
121
params .setGradleJavaVersion (Jvm .current ().getJavaVersion ());
122
122
params .setGitRevision (gitInfo .getRevision ());
123
123
params .setGitOrigin (gitInfo .getOrigin ());
124
- params .setBuildDate (ZonedDateTime .now (ZoneOffset .UTC ));
124
+ params .setBuildDate (Util . getBuildDate ( ZonedDateTime .now (ZoneOffset .UTC ) ));
125
125
params .setTestSeed (getTestSeed ());
126
126
params .setIsCi (System .getenv ("JENKINS_URL" ) != null );
127
127
params .setIsInternal (isInternal );
Original file line number Diff line number Diff line change 48
48
import java .io .UncheckedIOException ;
49
49
import java .net .URI ;
50
50
import java .net .URISyntaxException ;
51
+ import java .time .Instant ;
52
+ import java .time .ZoneOffset ;
53
+ import java .time .ZonedDateTime ;
51
54
import java .util .Locale ;
52
55
import java .util .Optional ;
53
56
import java .util .function .Supplier ;
@@ -187,4 +190,17 @@ public String toString() {
187
190
}
188
191
};
189
192
}
193
+
194
+ public static ZonedDateTime getBuildDate (ZonedDateTime defaultValue ) {
195
+ final String sourceDateEpoch = System .getenv ("SOURCE_DATE_EPOCH" );
196
+ if (sourceDateEpoch != null ) {
197
+ try {
198
+ return ZonedDateTime .ofInstant (Instant .ofEpochSecond (Long .parseLong (sourceDateEpoch )), ZoneOffset .UTC );
199
+ } catch (NumberFormatException e ) {
200
+ throw new GradleException ("Sysprop [SOURCE_DATE_EPOCH] must be of type [long]" , e );
201
+ }
202
+ } else {
203
+ return defaultValue ;
204
+ }
205
+ }
190
206
}
You can’t perform that action at this time.
0 commit comments