Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-39214: [Java] Support reproducible build #39215

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions dev/release/01-prepare-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,17 @@ def test_version_pre_tag
end

Dir.glob("java/**/pom.xml") do |path|
version = "<version>#{@snapshot_version}</version>"
lines = File.readlines(path, chomp: true)
target_lines = lines.grep(/#{Regexp.escape(version)}/)
hunks = []
target_lines.each do |line|
new_line = line.gsub(@snapshot_version) do
@release_version
hunks = generate_hunks(File.readlines(path, chomp: true)) do |line|
if line.include?("<version>#{@snapshot_version}</version>")
new_line = line.gsub(@snapshot_version) do
@release_version
end
[line, new_line]
elsif line.include?("<project.build.outputTimestamp>")
[line, normalize_pom_xml_output_timestamp(line)]
else
[nil, nil]
end
hunks << [
"-#{line}",
"+#{new_line}",
]
end
expected_changes << {hunks: hunks, path: path}
end
Expand Down
53 changes: 17 additions & 36 deletions dev/release/post-11-bump-versions-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,37 +262,19 @@ def test_version_post_tag
end

import_path = "github.com/apache/arrow/go/v#{@snapshot_major_version}"
hunks = []
if release_type == :major
lines = File.readlines(path, chomp: true)
target_lines = lines.each_with_index.select do |line, i|
line.include?(import_path)
end
next if target_lines.empty?
n_context_lines = 3 # The default of Git's diff.context
target_hunks = [[target_lines.first[0]]]
previous_i = target_lines.first[1]
target_lines[1..-1].each do |line, i|
if i - previous_i < n_context_lines
target_hunks.last << line
else
target_hunks << [line]
end
previous_i = i
end
target_hunks.each do |lines|
hunk = []
lines.each do |line,|
hunk << "-#{line}"
end
lines.each do |line|
hunks = generate_hunks(File.readlines(path, chomp: true)) do |line|
if line.include?(import_path)
new_line = line.gsub("v#{@snapshot_major_version}") do
"v#{@next_major_version}"
end
hunk << "+#{new_line}"
[line, new_line]
else
[nil, nil]
end
hunks << hunk
end
else
hunks = []
end
if path == "go/parquet/writer_properties.go"
hunks << [
Expand All @@ -305,18 +287,17 @@ def test_version_post_tag
end

Dir.glob("java/**/pom.xml") do |path|
version = "<version>#{@snapshot_version}</version>"
lines = File.readlines(path, chomp: true)
target_lines = lines.grep(/#{Regexp.escape(version)}/)
hunks = []
target_lines.each do |line|
new_line = line.gsub(@snapshot_version) do
@next_snapshot_version
hunks = generate_hunks(File.readlines(path, chomp: true)) do |line|
if line.include?("<version>#{@snapshot_version}</version>")
new_line = line.gsub(@snapshot_version) do
@next_snapshot_version
end
[line, new_line]
elsif line.include?("<project.build.outputTimestamp>")
[line, normalize_pom_xml_output_timestamp(line)]
else
[nil, nil]
end
hunks << [
"-#{line}",
"+#{new_line}",
]
end
expected_changes << {hunks: hunks, path: path}
end
Expand Down
46 changes: 45 additions & 1 deletion dev/release/test-helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,59 @@ def parse_patch(patch)
when /\A@@/
in_hunk = true
diffs.last[:hunks] << []
when /\A[-+]/
when /\A-/
next unless in_hunk
diffs.last[:hunks].last << line.chomp
when /\A\+/
next unless in_hunk
diffs.last[:hunks].last << normalize_added_line(line.chomp)
end
end
diffs.sort_by do |diff|
diff[:path]
end
end

def generate_hunks(lines)
git_diff_context = 3 # The default of Git's diff.context
max_lines_for_same_hunk = git_diff_context * 2 + 1
previous_i = nil
grouped_change_blocks = []
lines.each_with_index do |line, i|
deleted, added = yield(line)
next if deleted.nil? and added.nil?
if previous_i.nil? or (i - previous_i) > max_lines_for_same_hunk
grouped_change_blocks << []
end
if i - 1 != previous_i
grouped_change_blocks.last << []
end
grouped_change_blocks.last.last << [deleted, added]
previous_i = i
end
grouped_change_blocks.collect do |change_blocks|
hunk = []
change_blocks.each do |continuous_changes|
continuous_changes.each do |deleted, _|
hunk << "-#{deleted}" if deleted
end
continuous_changes.each do |_, added|
hunk << "+#{added}" if added
end
end
hunk
end
end

def normalize_pom_xml_output_timestamp(line)
line.gsub(/<project\.build\.outputTimestamp>.+?</) do
"<project.build.outputTimestamp>1980-01-01T00:00:02Z<"
end
end

def normalize_added_line(line)
normalize_pom_xml_output_timestamp(line)
end
end

module VersionDetectable
Expand Down
4 changes: 4 additions & 0 deletions java/adapter/avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<description>(Contrib/Experimental) A library for converting Avro data to Arrow data.</description>
<url>http://maven.apache.org</url>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
jbonofre marked this conversation as resolved.
Show resolved Hide resolved
</properties>

<dependencies>

<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory-core -->
Expand Down
4 changes: 4 additions & 0 deletions java/adapter/jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<description>(Contrib/Experimental)A library for converting JDBC data to Arrow data.</description>
<url>http://maven.apache.org</url>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>

<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory-core -->
Expand Down
4 changes: 4 additions & 0 deletions java/algorithm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<name>Arrow Algorithms</name>
<description>(Experimental/Contrib) A collection of algorithms for working with ValueVectors.</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
3 changes: 2 additions & 1 deletion java/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>18</version>
<version>31</version>
</parent>

<groupId>org.apache.arrow</groupId>
Expand All @@ -26,6 +26,7 @@
<description>Arrow Bill of Materials</description>

<properties>
<minimalMavenBuildVersion>3.5.0</minimalMavenBuildVersion>
<arrow.vector.classifier/>
</properties>

Expand Down
1 change: 1 addition & 0 deletions java/c/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<description>Java implementation of C Data Interface</description>
<packaging>jar</packaging>
<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<arrow.c.jni.dist.dir>./build</arrow.c.jni.dist.dir>
</properties>

Expand Down
4 changes: 4 additions & 0 deletions java/compression/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<name>Arrow Compression</name>
<description>(Experimental/Contrib) A library for working with the compression/decompression of Arrow data.</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
1 change: 1 addition & 0 deletions java/dataset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<description>Java implementation of Arrow Dataset API/Framework</description>
<packaging>jar</packaging>
<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<arrow.cpp.build.dir>../../../cpp/release-build/</arrow.cpp.build.dir>
<protobuf.version>2.5.0</protobuf.version>
<parquet.version>1.13.1</parquet.version>
Expand Down
3 changes: 2 additions & 1 deletion java/flight/flight-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<packaging>jar</packaging>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<forkCount>1</forkCount>
</properties>

Expand Down Expand Up @@ -288,7 +289,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
Expand Down
6 changes: 5 additions & 1 deletion java/flight/flight-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<description>Integration tests for Flight RPC.</description>
<packaging>jar</packaging>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down Expand Up @@ -64,7 +68,7 @@
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
Expand Down
1 change: 1 addition & 0 deletions java/flight/flight-sql-jdbc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<url>https://arrow.apache.org</url>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<org.apache.arrow.flight.name>${project.parent.groupId}:${project.parent.artifactId}</org.apache.arrow.flight.name>
<org.apache.arrow.flight.version>${project.parent.version}</org.apache.arrow.flight.version>
<org.apache.arrow.flight.jdbc-driver.name>${project.name}</org.apache.arrow.flight.jdbc-driver.name>
Expand Down
4 changes: 4 additions & 0 deletions java/flight/flight-sql-jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<packaging>jar</packaging>
<url>https://arrow.apache.org</url>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
Expand Down
1 change: 1 addition & 0 deletions java/flight/flight-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<packaging>jar</packaging>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<forkCount>1</forkCount>
</properties>

Expand Down
4 changes: 4 additions & 0 deletions java/format/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<name>Arrow Format</name>
<description>Generated Java files from the IPC Flatbuffer definitions.</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>com.google.flatbuffers</groupId>
Expand Down
1 change: 1 addition & 0 deletions java/gandiva/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<name>Arrow Gandiva</name>
<description>Java wrappers around the native Gandiva SQL expression compiler.</description>
<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<protobuf.version>3.25.1</protobuf.version>
Expand Down
1 change: 1 addition & 0 deletions java/maven/module-info-compiler-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</prerequisites>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<maven.version>3.8.7</maven.version>
</properties>

Expand Down
4 changes: 4 additions & 0 deletions java/memory/memory-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<name>Arrow Memory - Core</name>
<description>Core off-heap memory management libraries for Arrow ValueVectors.</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down
4 changes: 4 additions & 0 deletions java/memory/memory-netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<name>Arrow Memory - Netty</name>
<description>Netty allocator and utils for allocating memory in Arrow</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
3 changes: 3 additions & 0 deletions java/memory/memory-unsafe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<name>Arrow Memory - Unsafe</name>
<description>Allocator and utils for allocating memory in Arrow based on sun.misc.Unsafe</description>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
Expand Down
1 change: 1 addition & 0 deletions java/performance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
</dependencies>

<properties>
<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.37</jmh.version>
<javac.target>1.8</javac.target>
Expand Down
Loading
Loading