In IDEA 2019 I have created a Gradle project and added the following lines to the build.gradle
file:
plugins {
id 'java'
}
sourceSets {
main {
java {
srcDir "../src"
include "com/example/abc/**"
exclude "com/example/abc/tst/**"
}
}
}
When compiling the project, the compiler apparently does what I expect: starting from the ../src
folder, it compiles only the abc
package and subpackages except the tst
subpackage.
However, in the IDEA sources tree on the left-hand side, the whole content of src
is displayed. It makes it harder to navigate in the project and to understand what is compiled and what is not.
Obviously, IDEA is parsing the .gradle file because it correctly understands the ..\src
location of my sources. But for some reason it doesn't respect the include
and exclude
statements. What should I do to make IDEA display exactly the same content which is being compiled?
I know I can hide a folder using the "Mark directory as excluded" context menu. But this is a bad solution because it forces me to make the same thing twice in different places and discredits the concept of having everything in the .gradle file.