Skip to content

Remove antlr4 Dependency? #225

Closed
Closed

Description

@commonsguy

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 use com.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:

    compile('com.graphql-java:graphql-java:2.1.0') {
        exclude module: 'antlr4'
    }

then everything is fine.

Are you really sure that your POM is supposed to list a dependency for org.antlr:antlr4:4.5.1?

Thanks!

Activity

  1. GrigoryPtashko commented on Oct 16, 2016

    @GrigoryPtashko

    +1

  2. dminkovsky commented on Oct 16, 2016

    @dminkovsky
    Contributor

    Hi @commonsguy. Thank you for reporting this.

    The ANTLR dependency is current listed as a compile-time dependency:

    compile 'org.antlr:antlr4-runtime:4.5.1'
    

    Yet, in the resulting POM that arrives from Maven Central, you do get both of these dependencies:

        <dependency>
          <groupId>org.antlr</groupId>
          <artifactId>antlr4-runtime</artifactId>
          <version>4.5.1</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.antlr</groupId>
          <artifactId>antlr4</artifactId>
          <version>4.5.1</version>
          <scope>runtime</scope>
        </dependency>
    

    I am not sure why the current build.gradle configuration results in this POM. Do you or @GrigoryPtashko know?

  3. commonsguy commented on Oct 16, 2016

    @commonsguy
    Author

    My guess is that compile 'org.antlr:antlr4-runtime:4.5.1' is not the problem. If I had to guess, the antlr plugin is the culprit, either just from applying it or from the antlr "org.antlr:antlr4:4.5.1" line in the dependencies.

    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.

  4. dminkovsky commented on Oct 16, 2016

    @dminkovsky
    Contributor

    @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.

  5. JeSuisNikhil commented on Oct 27, 2016

    @JeSuisNikhil
    Contributor

    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?

  6. foragerr commented on Oct 27, 2016

    @foragerr

    @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.

  7. foragerr commented on Oct 27, 2016

    @foragerr

    I submitted a PR for gradle antlr plugin. gradle/gradle#763

  8. dminkovsky commented on Oct 27, 2016

    @dminkovsky
    Contributor

    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.

  9. added a commit that references this issue on Oct 27, 2016
    1ac98bf
  10. dminkovsky commented on Oct 27, 2016

    @dminkovsky
    Contributor

    Oh, and for posterity: to build the to-be-published POM locally without publishing:

    ./gradlew generatePomFileForGraphqlJavaPublication`
    

    This build the POM in:

    build/publications/graphqlJava/pom-default.xml
    
  11. added a commit that references this issue on Oct 27, 2016
    b406b06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions