Search code examples
intellij-ideagradleantlr4dagger-2generated-code

duplicate dagger2 in generated-src/antlr in Intellij with gradle antlr plugin


I have a working gradle 3.1 dagger2 antlr4 project with antlr plugin. I have a specific generated sources directory configured in the gradle idea plugin and in the Intellij Annotation Processing option. If I build it in Intellij 2016.2.4, the dagger2 generated sources are duplicated in the build/generated-src/antlr/main directory as well as my configured src/main/generated directory. Why on Earth would non-Antlr code be put into that directory?


Solution

  • It's been awhile but I think I resolved this by making sure antlr source was in main/antlr/com.foo.bar.parsers like package structure and then setting the package again in the build.gradle:

    generateGrammarSource {
        arguments += [
            "-package", "com.foo.bar.parsers"
        ]
        outputDirectory = file("$projectDir/gen") // same as Intellij ANTLR plugin
    }