Open jpd236 opened 9 years ago
I think you can also just add the folder to the main source set. Will experiment with when I get some time.
sourceSets.main.srcDirs += 'build/generated/proto'
for reference, I added a question to an old IDEA issue: https://youtrack.jetbrains.com/issue/IDEA-117540
probably won't get response and i'll create another issue later
As another workaround you can also do this:
ext.generatedFilesDir = "${projectDir}/proto-gen-src"
tasks["generateWireProtos"].outputDir = file(generatedFilesDir)
tasks["clean"] << {
file(generatedFilesDir).deleteDir()
}
sourceSets.main.java.srcDir generatedFilesDir
In general, I think it makes sense to provide an option to specify output directory for Wire task in easier way, and maybe make default output directory outside of "build" folder for Java projects.
Other plugins (net.ltgt.apt
is one) test for the presence of the idea
plugin and configure the IDE using that.
So this plugin does not configure IntelliJ. But if you have any other plugin that does that, it should just work.
So apply both apt
and idea
to your java module.
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'net.ltgt.apt'
apply plugin: 'com.squareup.wire'
Then add this below in your build.gradle
as well. Then it should work.
idea {
module {
sourceDirs += generateWireProtos.outputDir
}
}
Unlike the Android plugin, the Java gradle plugin doesn't seem to provide a way to configure a directory as a generated source directory so that it gets picked up by the IDE as source, and have it generated when you click "Sync Now". See https://github.com/square/wire/pull/177#issuecomment-99777359 for the original report.
There are some hacky workarounds at http://stackoverflow.com/questions/16702126/how-to-specify-intellij-exclude-directories-using-gradle but none of them are particularly appealing. Notably, the question author there says they're using a protobuf plugin (not this one, ostensibly) that has this same problem.