0

I'm generating some source files via ANTLR. I want to use those files while writing my own source code.

When I use the generateGrammarSource task the code is perfectly generated but goes to the build\generated-src directory. When I import classes from that directory, both my build task and the make project compiles successfully. But IntelliSense is generating a metric ton of errors and warnings (mostly indicating that the imports are non-existent - Cannot resolve Symbol, even though they really are there).

Is this a problem with IntelliJ, what can I do to appease IntelliSense, so I can continue my work in peace?

Opal
  • 81,889
  • 28
  • 189
  • 210
matteeyah
  • 855
  • 11
  • 24

1 Answers1

0

Basically you should have the following setup:

def generatedDir = 'src/main/gen'
sourceSets {
    main {
        java {
            srcDirs += [generatedDir]
        }
    }
}

task generateGrammarSource // need to generate the file under src/main/gen

compileTask.dependsOn(generateGrammarSource) // don't know the exact name of the compile task

clean << {
   project.file(generatedDir).deleteDir()
}

You'll also need to add the generated sources to IntelliJ, google for it.

Opal
  • 81,889
  • 28
  • 189
  • 210
  • It's all setup correctly by the `antlr` plugin. But there's a bug. It includes `/build/generated-sources/` but excludes `/build/` which in turn excludes everything in it regardless if it's included or not. – matteeyah Jan 16 '16 at 16:11