Skip to content

Commit

Permalink
Apply reproducible builds to plugins (#4746)
Browse files Browse the repository at this point in the history
As per gradle [docs] add support to remove timestamps and package with
same order which is required from [reproducible] builds

This is a result of the discussion in
opensearch-project/opensearch-plugin-template-java#38
to apply for all plugins going forward.

[docs]:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
[reproducible]: https://reproducible-builds.org/

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
Co-authored-by: Daniel (dB.) Doubrovkine <dblock@amazon.com>
  • Loading branch information
inglor and dblock committed Oct 14, 2022
1 parent f1995b9 commit e44158d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Introduce experimental searchable snapshot API ([#4680](https://github.com/opensearch-project/OpenSearch/pull/4680))
- Recommissioning of zone. REST layer support. ([#4624](https://github.com/opensearch-project/OpenSearch/pull/4604))
- Added in-flight cancellation of SearchShardTask based on resource consumption ([#4565](https://github.com/opensearch-project/OpenSearch/pull/4565))
- Apply reproducible builds configuration for OpenSearch plugins through gradle plugin ([#4746](https://github.com/opensearch-project/OpenSearch/pull/4746))

### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
package org.opensearch.gradle.plugin

import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.opensearch.gradle.BuildPlugin
import org.opensearch.gradle.NoticeTask
import org.opensearch.gradle.Version
import org.opensearch.gradle.VersionProperties
import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin
import org.opensearch.gradle.info.BuildParams
import org.opensearch.gradle.plugin.PluginPropertiesExtension
import org.opensearch.gradle.test.RestTestBasePlugin
import org.opensearch.gradle.testclusters.RunTask
import org.opensearch.gradle.util.Util
Expand Down Expand Up @@ -134,6 +134,12 @@ class PluginBuildPlugin implements Plugin<Project> {
}
project.configurations.getByName('default')
.extendsFrom(project.configurations.getByName('runtimeClasspath'))
project.tasks.withType(AbstractArchiveTask.class).configureEach { task ->
// ignore file timestamps
// be consistent in archive file order
task.preserveFileTimestamps = false
task.reproducibleFileOrder = true
}
// allow running ES with this plugin in the foreground of a build
project.tasks.register('run', RunTask) {
dependsOn(project.tasks.bundlePlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

package org.opensearch.gradle.plugin;

import org.gradle.api.tasks.bundling.AbstractArchiveTask;
import org.opensearch.gradle.BwcVersions;
import org.opensearch.gradle.test.GradleUnitTestCase;
import org.gradle.api.Project;
Expand Down Expand Up @@ -64,6 +65,10 @@ public void testApply() {
assertNotNull("plugin extensions has the right type", project.getExtensions().findByType(PluginPropertiesExtension.class));

assertNull("plugin should not create the integTest task", project.getTasks().findByName("integTest"));
project.getTasks().withType(AbstractArchiveTask.class).forEach(t -> {
assertFalse(String.format("task '%s' should not preserve timestamps", t.getName()), t.isPreserveFileTimestamps());
assertTrue(String.format("task '%s' should have reproducible file order", t.getName()), t.isReproducibleFileOrder());
});
}

@Ignore("https://github.com/elastic/elasticsearch/issues/47123")
Expand Down

0 comments on commit e44158d

Please sign in to comment.