You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, com.graphql-java:graphql-java:2.1.0 has a dependency on org.antlr:antlr4:4.5.1 in its POM. AFAIK, org.antlr:antlr4:4.5.1 represents the JAR with the tools that you would use to generate your parser/lexer from the grammar. While you might need that to build com.graphql-java:graphql-java, you should not need that to usecom.graphql-java:graphql-java. The org.antlr:antlr4-runtime:4.5.1 artifact contains the runtime code that gets used by the code-generated parser/lexer.
As it stands, attempting to build an Android app that uses com.graphql-java:graphql-java results in a build error, due to multiple libraries defining the same Java class. However, if I do this:
I haven't used ANTLR in about a decade, so I haven't played with the antlr Gradle plugin and do not know what to do to suppress that portion of the POM.
@commonsguy Yeah that was my thinking too. That plugin was recently adopted as a fix to remove the antlr-built sources from the repo. Will have to see how to remove the main jar from the resulting POM. In the meantime, thanks for posting the workaround.
@foragerr found that antlr plugin is unnecessarily adding a runtime dependency on the antlr generator. They suggested we use pom.withXml to remove the dependency. See their comment.
Activity
GrigoryPtashko commentedon Oct 16, 2016
+1
dminkovsky commentedon Oct 16, 2016
Hi @commonsguy. Thank you for reporting this.
The ANTLR dependency is current listed as a compile-time dependency:
Yet, in the resulting POM that arrives from Maven Central, you do get both of these dependencies:
I am not sure why the current
build.gradleconfiguration results in this POM. Do you or @GrigoryPtashko know?commonsguy commentedon Oct 16, 2016
My guess is that
compile 'org.antlr:antlr4-runtime:4.5.1'is not the problem. If I had to guess, theantlrplugin is the culprit, either just from applying it or from theantlr "org.antlr:antlr4:4.5.1"line in thedependencies.I haven't used ANTLR in about a decade, so I haven't played with the
antlrGradle plugin and do not know what to do to suppress that portion of the POM.dminkovsky commentedon Oct 16, 2016
@commonsguy Yeah that was my thinking too. That plugin was recently adopted as a fix to remove the antlr-built sources from the repo. Will have to see how to remove the main jar from the resulting POM. In the meantime, thanks for posting the workaround.
JeSuisNikhil commentedon Oct 27, 2016
So it seems @dminkovsky posted this on stackoverflow
@foragerr found that antlr plugin is unnecessarily adding a runtime dependency on the antlr generator. They suggested we use pom.withXml to remove the dependency. See their comment.
There is also a discussion on the gradle forums about this bug.
So I took @foragerr's suggestion and hacked up this patch which basically removes the dependency from the generated pom after the antlr plugin has done its thing.
which is terrible but it does the job?
foragerr commentedon Oct 27, 2016
@IamCornholio You found and tied together an SO question, a gradle forum post and a github issue; I bow to your google fu!
You should post your pom customization snippet as an answer on SO.
foragerr commentedon Oct 27, 2016
I submitted a PR for gradle antlr plugin. gradle/gradle#763
dminkovsky commentedon Oct 27, 2016
Thank you @foragerr, for your help with the Gradle PR and on Stack Overflow! So cool.
Thanks @IamCornholio for the patch. Will integrate it soon.
Fix graphql-java#225: remove ANTLR compile dep from published POM
dminkovsky commentedon Oct 27, 2016
Oh, and for posterity: to build the to-be-published POM locally without publishing:
This build the POM in:
Added note regarding fix for graphql-java#225
Merge pull request #236 from dminkovsky/fix-225