如何使用Gradle指定IntelliJ排除目录? [英] How to specify IntelliJ Exclude Directories using Gradle?
问题描述
使用IntelliJ打开build.gradle
文件,在从Gradle导入项目"窗口中,排除的根"预先填充了.gradle
和build
目录.
Using IntelliJ to open a build.gradle
file, in the "Import Project from Gradle" window, the "Excluded Roots" are pre-populated with the .gradle
and build
directories.
如何指定build.gradle
文件中应排除(或不排除)哪些目录?
How do I specify what directories should be excluded (or not excluded) in the build.gradle
file?
特别是我正在使用协议缓冲区插件,将生成的源放置在build
目录,则我的源类看不到生成的类.
Specifically I am using a protocol buffer plugin that places generated sources in the /build/generated-sources/
directory. If the build
directory is excluded then my source class do not see the generated classes.
详细信息: IntelliJ 12.1.3,Gradle 1.4
Details: IntelliJ 12.1.3, Gradle 1.4
推荐答案
As shown in the Gradle Build Language Reference, you can configure the idea.module.excludeDirs
property, which is of type List<File>
. Apparently IDEA doesn't support including subdirectories of excluded directories, so you'll have to exclude all siblings of build/generated-sources
. For example:
idea {
module {
excludeDirs = [file(".gradle")]
["classes", "docs", "dependency-cache", "libs", "reports", "resources", "test-results", "tmp"].each {
excludeDirs << file("$buildDir/$it")
}
}
}
如果受Protocol Buffer插件支持,则将生成的源放置在build
之外的地方,并使该地方对于clean
任务(例如clean.delete "generated-sources"
)来说可能更容易.
If supported by the Protocol Buffer plugin, it may be easier to put the generated sources into a place outside build
, and make that place known to the clean
task (e.g. clean.delete "generated-sources"
).
这篇关于如何使用Gradle指定IntelliJ排除目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!