From 2683721e396f74d5b247f8c06e3ae9587fe5d07d Mon Sep 17 00:00:00 2001 From: Tarun Annapareddy Date: Tue, 23 Sep 2025 15:52:46 -0700 Subject: [PATCH 1/3] Fix Build Issues with Iceberg Upgrade --- examples/java/iceberg/build.gradle | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/examples/java/iceberg/build.gradle b/examples/java/iceberg/build.gradle index 09ef64d32ee3..636e8da7afc0 100644 --- a/examples/java/iceberg/build.gradle +++ b/examples/java/iceberg/build.gradle @@ -87,3 +87,41 @@ dependencies { runtimeOnly project(path: project.getProperty("runnerDependency")) } } + +/* + * A convenient task to run individual example directly on Beam repo. + * + * Usage: + * ./gradlew :examples:java:iceberg:execute -PmainClass=org.apache.beam.examples.iceberg.`\ + * -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \ + * " + */ +tasks.create(name:"execute", type:JavaExec) { + mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE" + def execArgs = project.findProperty("exec.args") + String runner + if (execArgs) { + // configure runner dependency from args + def runnerPattern = /runner[ =]([A-Za-z]+)/ + def matcher = execArgs =~ runnerPattern + if (matcher) { + runner = matcher[0][1] + runner = runner.substring(0, 1).toLowerCase() + runner.substring(1); + if (!(runner in (preCommitRunners + nonPreCommitRunners))) { + throw new GradleException("Unsupported runner: " + runner) + } + } + } + if (runner) { + classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit" + } else { + classpath = sourceSets.main.runtimeClasspath + } + systemProperties System.getProperties() + args execArgs ? execArgs.split() : [] +} + +configurations.all { + // iceberg-core needs avro:1.12.0 + resolutionStrategy.force 'org.apache.avro:avro:1.12.0' +} From abb90af54b27577b51bd7b2a3565c0dfc10c21bc Mon Sep 17 00:00:00 2001 From: Tarun Annapareddy Date: Wed, 24 Sep 2025 09:29:48 -0700 Subject: [PATCH 2/3] Add common build file --- examples/java/build.gradle | 33 +------------------- examples/java/common.gradle | 50 ++++++++++++++++++++++++++++++ examples/java/iceberg/build.gradle | 33 +------------------- 3 files changed, 52 insertions(+), 64 deletions(-) create mode 100644 examples/java/common.gradle diff --git a/examples/java/build.gradle b/examples/java/build.gradle index 6f35a109998c..c1ebc5f22455 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -174,38 +174,7 @@ task preCommit() { } } -/* - * A convenient task to run individual example directly on Beam repo. - * - * Usage: - * ./gradlew :examples:java:execute -PmainClass=org.apache.beam.examples.`\ - * -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \ - * " - */ -tasks.create(name:"execute", type:JavaExec) { - mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE" - def execArgs = project.findProperty("exec.args") - String runner - if (execArgs) { - // configure runner dependency from args - def runnerPattern = /runner[ =]([A-Za-z]+)/ - def matcher = execArgs =~ runnerPattern - if (matcher) { - runner = matcher[0][1] - runner = runner.substring(0, 1).toLowerCase() + runner.substring(1); - if (!(runner in (preCommitRunners + nonPreCommitRunners))) { - throw new GradleException("Unsupported runner: " + runner) - } - } - } - if (runner) { - classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit" - } else { - classpath = sourceSets.main.runtimeClasspath - } - systemProperties System.getProperties() - args execArgs ? execArgs.split() : [] -} +apply from: "$projectDir/common.gradle" // Run this task to validate the Java environment setup for contributors task wordCount(type:JavaExec) { diff --git a/examples/java/common.gradle b/examples/java/common.gradle new file mode 100644 index 000000000000..b8a3ef27f9a8 --- /dev/null +++ b/examples/java/common.gradle @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /* + * A convenient task to run individual example directly on Beam repo. + * + * Usage: + * ./gradlew :examples:java:execute -PmainClass=org.apache.beam.examples.`\ + * -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \ + * " + */ +tasks.create(name:"execute", type:JavaExec) { + mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE" + def execArgs = project.findProperty("exec.args") + String runner + if (execArgs) { + // configure runner dependency from args + def runnerPattern = /runner[ =]([A-Za-z]+)/ + def matcher = execArgs =~ runnerPattern + if (matcher) { + runner = matcher[0][1] + runner = runner.substring(0, 1).toLowerCase() + runner.substring(1); + if (!(runner in (preCommitRunners + nonPreCommitRunners))) { + throw new GradleException("Unsupported runner: " + runner) + } + } + } + if (runner) { + classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit" + } else { + classpath = sourceSets.main.runtimeClasspath + } + systemProperties System.getProperties() + args execArgs ? execArgs.split() : [] +} diff --git a/examples/java/iceberg/build.gradle b/examples/java/iceberg/build.gradle index 636e8da7afc0..76a4075d6a29 100644 --- a/examples/java/iceberg/build.gradle +++ b/examples/java/iceberg/build.gradle @@ -88,38 +88,7 @@ dependencies { } } -/* - * A convenient task to run individual example directly on Beam repo. - * - * Usage: - * ./gradlew :examples:java:iceberg:execute -PmainClass=org.apache.beam.examples.iceberg.`\ - * -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \ - * " - */ -tasks.create(name:"execute", type:JavaExec) { - mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NONE" - def execArgs = project.findProperty("exec.args") - String runner - if (execArgs) { - // configure runner dependency from args - def runnerPattern = /runner[ =]([A-Za-z]+)/ - def matcher = execArgs =~ runnerPattern - if (matcher) { - runner = matcher[0][1] - runner = runner.substring(0, 1).toLowerCase() + runner.substring(1); - if (!(runner in (preCommitRunners + nonPreCommitRunners))) { - throw new GradleException("Unsupported runner: " + runner) - } - } - } - if (runner) { - classpath = sourceSets.main.runtimeClasspath + configurations."${runner}PreCommit" - } else { - classpath = sourceSets.main.runtimeClasspath - } - systemProperties System.getProperties() - args execArgs ? execArgs.split() : [] -} +apply from: "$project.rootDir/examples/java/common.gradle" configurations.all { // iceberg-core needs avro:1.12.0 From 9d8dddd7d51bfe19d8e212db6eca398c96119bd5 Mon Sep 17 00:00:00 2001 From: Tarun Annapareddy Date: Wed, 24 Sep 2025 09:36:43 -0700 Subject: [PATCH 3/3] Order import command --- examples/java/build.gradle | 4 ++-- examples/java/iceberg/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/java/build.gradle b/examples/java/build.gradle index c1ebc5f22455..cdbcb5ce8bf9 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -36,6 +36,8 @@ ext.summary = """Apache Beam SDK provides a simple, Java-based interface for processing virtually any size data. This artifact includes all Apache Beam Java SDK examples.""" +apply from: "$projectDir/common.gradle" + /** Define the list of runners which execute a precommit test. * Some runners are run from separate projects, see the preCommit task below * for details. @@ -174,8 +176,6 @@ task preCommit() { } } -apply from: "$projectDir/common.gradle" - // Run this task to validate the Java environment setup for contributors task wordCount(type:JavaExec) { description "Run the Java word count example" diff --git a/examples/java/iceberg/build.gradle b/examples/java/iceberg/build.gradle index 76a4075d6a29..4d258e9be5ac 100644 --- a/examples/java/iceberg/build.gradle +++ b/examples/java/iceberg/build.gradle @@ -33,6 +33,8 @@ applyJavaNature( description = "Apache Beam :: Examples :: Java :: Iceberg" ext.summary = """Apache Beam Java SDK examples using IcebergIO.""" +apply from: "$project.rootDir/examples/java/common.gradle" + /** Define the list of runners which execute a precommit test. * Some runners are run from separate projects, see the preCommit task below * for details. @@ -88,8 +90,6 @@ dependencies { } } -apply from: "$project.rootDir/examples/java/common.gradle" - configurations.all { // iceberg-core needs avro:1.12.0 resolutionStrategy.force 'org.apache.avro:avro:1.12.0'