Closed gschueler closed 7 years ago
As it happens we switched to Intellij at work so I got a my hands on the pro version. I will look into it.
Its not just for IntelliJ - its more for Android Studio, so android Studio (IntelliSense) knows where to look for Sources. (see apt-plugin net.ltgt.apt)
You can edit your module settings (right click on module or File->Project strucuture->Modules) to enable the path under build/gen/buildconfig/src/main to be a source folder. (Run gradle build once if the folder doesn't already exist.)
I have found a gradle solution because the solution @p-schneider is transient with gradle sync (gradle sync overrides the settings in "Project Structure".
The solution is to add another gradle plugin ("idea") and say that there is an additional sourceDir:
idea.module.sourceDirs += file('build/gen/buildconfig/src/main')
I am looking into this, @rootandy 's solution is working indeed and I could make it part of the plugin, but it feels odd. It's compiles classes, more a dependency (it's listed in the Gradle tab of IntelliJ Studio), it should be treated that way. :-/
What's also odd: The buildconfig plugin adds the files to the compileClasspath of a sourceset (main by default), but it's listed as runtime dependency.
Okay, I found another way after some fiddling around.
configurations.create('someUniqueName').dependencies.add (dependencies.create (files ('build/gen/buildconfig/classes/main')))
idea.module.scopes.PROVIDED.plus += [ configurations.someUniqueName ]
I will try to automate tha in the plugin and test it. That should fix it. Hope Netbeans wtill works. Eclipse is another story.
Thanks for the fast reply. As I mentioned in my first Post my you can get eyes on the net.ltgt.apt-plugin (the pure Java alternative for Android apt) and See how that works. Maybe this can help because that plugin works like a Charme and makes dagger in pure Java easy.
@rootandy Thx for the suggestion. BTW, I just tested the changes with Eclipse and Netbeans and both seem to resolve the dependency fine, too. Eclipse needs a refresh after build, and Netbeans (with Gradle-plugin) works out of the box.
1.1.8 is released and contains the fixes.
IDEA doesn't seem to know where to look for the generated code, so it incorrectly marks a class dependent on the BuildConfig class as having an error.
I tried putting a placeholder class in my src/main/java, but it seems that is used at build time instead of the generated file.
Is it possible to somehow put a placeholder class in src/main/java but have the generated source override it at compile time?