Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify IntelliJ Exclude Directories using Gradle?

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

like image 804
Mike Rylander Avatar asked May 22 '13 21:05

Mike Rylander


People also ask

How do I exclude tasks in Gradle?

To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.

What is Gradle wrapper in IntelliJ?

Projects generated using IntelliJ IDEA's Gradle wizard will usually have a gradle-wrapper. properties file which contains the details of the version of Gradle to use for this project. Ideally we want this to use the latest version of Gradle, where possible, so that we get the most up to date support and features.


Video Answer


1 Answers

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").

like image 184
Peter Niederwieser Avatar answered Sep 20 '22 17:09

Peter Niederwieser