I am working with the quick start guide of Apache Beam:
https://beam.apache.org/get-started/quickstart-java
I want to create a minimal setup with gradle, and want to test it with Direct Runner.
When I run this command which mentioned in the guide:
gradle clean execute -DmainClass=main.Main --args="--inputFile=sample.txt --output=counts"
Gradle fails with those error:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'execute' not found in root project 'apache-beam-hello-world'.
So I think I am missing some settings in build.gradle,
I read the guide again and I found those code maybe related:
task("execute", JavaExec::class) {
classpath = sourceSets["main"].runtimeClasspath
mainClass.set(System.getProperty("mainClass"))
}
However, the code above is written in Kotlin,
so I have no idea what should I do now.
Here is my current build.gradle
plugins {
id "java-library"
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.apache.beam:beam-sdks-java-core:2.39.0"
implementation "org.apache.beam:beam-runners-direct-java:2.39.0"
}
tasks.named("test") {
useJUnitPlatform()
}
Update (2022-05-29T18:47:00Z):
I can just run the Main class and works fine with my Eclipse IDE.
CodePudding user response:
I found my way to rewrite the same thing from Kotlin to Groovy and it works:
task execute(type: JavaExec) {
mainClass = "main.Main"
classpath = sourceSets.main.runtimeClasspath
}
Also, we need to add the repositories like this:
repositories {
mavenCentral()
maven { url "https://packages.confluent.io/maven/" }
}