yuqi1129 commented on code in PR #14237:
URL: https://github.com/apache/gravitino/pull/14237#discussion_r4399048081


##########
core/build.gradle.kts:
##########
@@ -227,11 +239,52 @@ tasks.test {
 }
 
 tasks.withType<JavaCompile>().configureEach {
+  options.errorprone.excludedPaths.set(".*/generated-src/antlr/.*")
   if (name.contains("jcstress", ignoreCase = true)) {
-    options.errorprone.excludedPaths.set(".*/generated/.*")
+    
options.errorprone.excludedPaths.set(".*/(generated|generated-src/antlr)/.*")
   }
 }
 
+// The generator is build tooling; only antlr4-runtime belongs on the server 
classpath.
+configurations.matching { it.name in setOf("api", "implementation") 
}.configureEach {
+  setExtendsFrom(extendsFrom.filterNot { it.name == "antlr" })
+}
+
+tasks.generateGrammarSource {
+  arguments = arguments + listOf("-visitor", "-no-listener", "-package", 
"org.apache.gravitino.policy.sql.antlr")
+}
+
+tasks.named<Jar>("sourcesJar") {
+  dependsOn(tasks.generateGrammarSource)
+}
+
+val shadedCoreJar = tasks.named<ShadowJar>("shadowJar") {
+  configurations = listOf(shadedAntlr)
+  archiveClassifier.set("")
+  relocate("org.antlr.v4.runtime", 
"org.apache.gravitino.shaded.org.antlr.v4.runtime")

Review Comment:
   [Important] The shaded core jar now ships ANTLR in the Lance REST standalone 
package, but `LICENSE.lance` does not declare it.
   
   `lance-rest-server` depends on `project(":core") { exclude("*") }`, which 
drops only transitive dependencies, so the core jar itself is still packaged. I 
ran `:lance:lance-rest-server:copyLibsToStandalonePackage` on this head: 
`distribution/gravitino-lance-rest-server/libs/` contains 
`gravitino-core-2.0.0-SNAPSHOT.jar` with 224 relocated 
`org/apache/gravitino/shaded/org/antlr` entries. That package's LICENSE (copied 
from `LICENSE.lance`) lists only ASM, bigint and JSR305 under BSD.
   
   Could you add `ANTLR4` to the BSD section of `LICENSE.lance`, as 
`LICENSE.bin` and `LICENSE.iceberg` already do? `licenses/antlr4.txt` already 
exists and is copied into the package. The other modules that depend on core 
(`filesystem-hadoop3`, `k8s-job-executor`, `maintenance/jobs`) use it only as 
compileOnly or in tests, so they are not affected.



##########
core/build.gradle.kts:
##########
@@ -22,12 +23,21 @@ plugins {
   `maven-publish`
   id("java")
   id("idea")
+  antlr
   alias(libs.plugins.jcstress)
   alias(libs.plugins.jmh)
   alias(libs.plugins.aspectj.post.compile.weaving)
+  alias(libs.plugins.shadow)
+}
+
+val shadedAntlr by configurations.creating {
+  isCanBeConsumed = false
 }
 
 dependencies {
+  antlr(libs.antlr.tool)
+  shadedAntlr(libs.antlr.runtime)
+  compileOnly(libs.antlr.runtime)

Review Comment:
   [Question] With the runtime now `compileOnly` and the relocated classes 
existing only in the shadow jar, does running the server from source in an IDE 
still work? IntelliJ module dependencies use core's unrelocated class output, 
which references `org.antlr.v4.runtime`, and nothing on that runtime classpath 
provides it any more. Creating or updating a policy there would hit 
`NoClassDefFoundError`. Gradle builds, tests and the distribution are fine. I 
have not checked this in an IDE; if it does break, a short note in the PR or 
the developer docs would help.



-- 
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]

Reply via email to