Skip to content
Merged
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
35 changes: 2 additions & 33 deletions examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -174,39 +176,6 @@ task preCommit() {
}
}

/*
* A convenient task to run individual example directly on Beam repo.
*
* Usage:
* ./gradlew :examples:java:execute -PmainClass=org.apache.beam.examples.<ClassName>`\
* -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \
* <pipeline options>"
*/
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() : []
}

// Run this task to validate the Java environment setup for contributors
task wordCount(type:JavaExec) {
description "Run the Java word count example"
Expand Down
50 changes: 50 additions & 0 deletions examples/java/common.gradle
Original file line number Diff line number Diff line change
@@ -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.<ClassName>`\
* -Pexec.args="runner=[DataflowRunner|DirectRunner|FlinkRunner|SparkRunner|PrismRunner] \
* <pipeline options>"
*/
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() : []
}
7 changes: 7 additions & 0 deletions examples/java/iceberg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -87,3 +89,8 @@ dependencies {
runtimeOnly project(path: project.getProperty("runnerDependency"))
}
}

configurations.all {
// iceberg-core needs avro:1.12.0
resolutionStrategy.force 'org.apache.avro:avro:1.12.0'
}
Loading