Skip to content

Commit da6f7b4

Browse files
authored
Fix Build Issues with Iceberg Upgrade (#36255)
* Fix Build Issues with Iceberg Upgrade * Add common build file * Order import command
1 parent 3a419b6 commit da6f7b4

File tree

3 files changed

+59
-33
lines changed

3 files changed

+59
-33
lines changed

examples/java/build.gradle

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ext.summary = """Apache Beam SDK provides a simple, Java-based
3636
interface for processing virtually any size data. This
3737
artifact includes all Apache Beam Java SDK examples."""
3838

39+
apply from: "$projectDir/common.gradle"
40+
3941
/** Define the list of runners which execute a precommit test.
4042
* Some runners are run from separate projects, see the preCommit task below
4143
* for details.
@@ -174,39 +176,6 @@ task preCommit() {
174176
}
175177
}
176178

177-
/*
178-
* A convenient task to run individual example directly on Beam repo.
179-
*
180-
* Usage:
181-
* ./gradlew :examples:java:execute -PmainClass=org.apache.beam.examples.<ClassName>`\
182-
* -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \
183-
* <pipeline options>"
184-
*/
185-
tasks.create(name:"execute", type:JavaExec) {
186-
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE"
187-
def execArgs = project.findProperty("exec.args")
188-
String runner
189-
if (execArgs) {
190-
// configure runner dependency from args
191-
def runnerPattern = /runner[ =]([A-Za-z]+)/
192-
def matcher = execArgs =~ runnerPattern
193-
if (matcher) {
194-
runner = matcher[0][1]
195-
runner = runner.substring(0, 1).toLowerCase() + runner.substring(1);
196-
if (!(runner in (preCommitRunners + nonPreCommitRunners))) {
197-
throw new GradleException("Unsupported runner: " + runner)
198-
}
199-
}
200-
}
201-
if (runner) {
202-
classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit"
203-
} else {
204-
classpath = sourceSets.main.runtimeClasspath
205-
}
206-
systemProperties System.getProperties()
207-
args execArgs ? execArgs.split() : []
208-
}
209-
210179
// Run this task to validate the Java environment setup for contributors
211180
task wordCount(type:JavaExec) {
212181
description "Run the Java word count example"

examples/java/common.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* License); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/*
20+
* A convenient task to run individual example directly on Beam repo.
21+
*
22+
* Usage:
23+
* ./gradlew :examples:java:execute -PmainClass=org.apache.beam.examples.<ClassName>`\
24+
* -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \
25+
* <pipeline options>"
26+
*/
27+
tasks.create(name:"execute", type:JavaExec) {
28+
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE"
29+
def execArgs = project.findProperty("exec.args")
30+
String runner
31+
if (execArgs) {
32+
// configure runner dependency from args
33+
def runnerPattern = /runner[ =]([A-Za-z]+)/
34+
def matcher = execArgs =~ runnerPattern
35+
if (matcher) {
36+
runner = matcher[0][1]
37+
runner = runner.substring(0, 1).toLowerCase() + runner.substring(1);
38+
if (!(runner in (preCommitRunners + nonPreCommitRunners))) {
39+
throw new GradleException("Unsupported runner: " + runner)
40+
}
41+
}
42+
}
43+
if (runner) {
44+
classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit"
45+
} else {
46+
classpath = sourceSets.main.runtimeClasspath
47+
}
48+
systemProperties System.getProperties()
49+
args execArgs ? execArgs.split() : []
50+
}

examples/java/iceberg/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ applyJavaNature(
3333
description = "Apache Beam :: Examples :: Java :: Iceberg"
3434
ext.summary = """Apache Beam Java SDK examples using IcebergIO."""
3535

36+
apply from: "$project.rootDir/examples/java/common.gradle"
37+
3638
/** Define the list of runners which execute a precommit test.
3739
* Some runners are run from separate projects, see the preCommit task below
3840
* for details.
@@ -87,3 +89,8 @@ dependencies {
8789
runtimeOnly project(path: project.getProperty("runnerDependency"))
8890
}
8991
}
92+
93+
configurations.all {
94+
// iceberg-core needs avro:1.12.0
95+
resolutionStrategy.force 'org.apache.avro:avro:1.12.0'
96+
}

0 commit comments

Comments
 (0)