Reputation: 574
I'm trying to get intellij to play nice with my functional gradle build sans using various other plugins. The various plugins I've used break support with another plugin I'm required to use (it looks for generated sources in the default location among other issues). I've been working at this issue for a while and have had mild success, but always with caveats. Many of the plugins don't play nice with apt in the test directory, etc.
Enabling annotation processors and setting the output directories to /build/classes/main and /build/classes/test doesn't yield results, though this is where the gradle plugin seems to be placing the .java and .class files generated by including the dagger2-compiler.
I can get everything playing nice by creative tweaking of the generated source sets parameters in the module configurations, but this never sticks around. i.e. if you close the app you have to reconfigure the options.
Any help would be appreciated.
Upvotes: 3
Views: 832
Reputation: 61
I solved the problem with the following steps: 1) Modify compileJava task to specify target sources location
compileJava {
options.compilerArgs+= [
"-s", project.projectDir.absolutePath + '/src/main/generated'
]
}
2)Tell IntelliJ Idea that those files are sources
idea {
module {
// generatedSourceDir does not work for some reason
sourceDirs += file(project.projectDir.absolutePath + '/src/main/generated')
}
}
P.S Idea plugin shoud by applied:
apply plugin: 'idea'
Upvotes: 6