Reputation: 20129
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.
How do I specify what directories should be excluded (or not excluded) in the build.gradle
file?
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.
Details: IntelliJ 12.1.3, Gradle 1.4
Upvotes: 36
Views: 12933
Reputation: 1
for exclude folder in module i'm use
idea {
module.apply {
val file = file("$projectDir/node_modules")
val exclude = HashSet<File>(excludeDirs)
exclude.add(file)
excludeDirs = exclude
}
}
Upvotes: 0
Reputation: 2024
If you are using the Gradle Kotlin DSL, use the following snippet:
idea {
module {
excludeDirs.add(file("..."))
}
}
Upvotes: 1
Reputation: 787
Another solution. Works with Idea 13.
idea.module {
excludeDirs -= file(buildDir) //1
buildDir.listFiles({d,f->f != 'generated-sources'} as FilenameFilter).each {excludeDirs += it}} //2
buildDir
from excludeDirs
.buildDir
child (except generating-source
).Upvotes: 12
Reputation: 123910
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")
}
}
}
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"
).
Upvotes: 35