diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index 25efa002a36f..97986dea834d 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -674,8 +674,6 @@ class BeamModulePlugin implements Plugin { activemq_junit : "org.apache.activemq.tooling:activemq-junit:$activemq_version", activemq_kahadb_store : "org.apache.activemq:activemq-kahadb-store:$activemq_version", activemq_mqtt : "org.apache.activemq:activemq-mqtt:$activemq_version", - antlr : "org.antlr:antlr4:4.7", - antlr_runtime : "org.antlr:antlr4-runtime:4.7", args4j : "args4j:args4j:2.33", auto_value_annotations : "com.google.auto.value:auto-value-annotations:$autovalue_version", // TODO: https://github.com/apache/beam/issues/34993 after stopping supporting Java 8 diff --git a/sdks/java/core/build.gradle b/sdks/java/core/build.gradle index 57e47cef6502..6f22e1b771a9 100644 --- a/sdks/java/core/build.gradle +++ b/sdks/java/core/build.gradle @@ -17,6 +17,9 @@ */ plugins { id 'org.apache.beam.module' } + +def antlr_version = "4.7" + applyJavaNature( automaticModuleName: 'org.apache.beam.sdk', classesTriggerCheckerBugs: [ @@ -29,7 +32,8 @@ applyJavaNature( dependencies { include(dependency(library.java.commons_compress)) include(dependency(library.java.commons_lang3)) - include(dependency(library.java.antlr_runtime)) + // Shade and repackage antlr runtime into Java core jar + include(dependency("org.antlr:antlr4-runtime:$antlr_version")) } relocate "com.google.thirdparty", getJavaRelocatedPath("com.google.thirdparty") relocate "org.apache.commons.compress", getJavaRelocatedPath("org.apache.commons.compress") @@ -70,10 +74,11 @@ test { } dependencies { - antlr library.java.antlr // antlr is used to generate code from sdks/java/core/src/main/antlr/ - permitUnusedDeclared library.java.antlr - permitUsedUndeclared library.java.antlr_runtime + antlr "org.antlr:antlr4:$antlr_version" + permitUnusedDeclared "org.antlr:antlr4:$antlr_version" + // alrady shaded and repackaged + permitUsedUndeclared "org.antlr:antlr4-runtime:$antlr_version" // Required to load constants from the model, e.g. max timestamp for global window shadow project(path: ":model:pipeline", configuration: "shadow") shadow project(path: ":model:fn-execution", configuration: "shadow")