Abacn commented on code in PR #36255:
URL: https://github.com/apache/beam/pull/36255#discussion_r2376310241
##########
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.<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() : []
+}
+
+configurations.all {
Review Comment:
We can send this fix now and add/refactor exec tasks in a separate PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]