Fix generated code reference for intellij projects.
diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle
index 4d402e8..cfcdb51 100644
--- a/benchmarks/build.gradle
+++ b/benchmarks/build.gradle
@@ -74,16 +74,11 @@
     fileMode = 0755
 }
 
-// Allow intellij projects to refer to generated-sources
+// Let intellij projects refer to generated code
 idea {
     module {
-        // The whole build dir is excluded by default, but we need build/generated-sources,
-        // which contains the generated proto classes.
-        excludeDirs = [file('.gradle')]
-        if (buildDir.exists()) {
-            excludeDirs += files(buildDir.listFiles())
-            excludeDirs -= file("$buildDir/generated-sources")
-        }
+        sourceDirs += file("${projectDir}/src/generated/main/java");
+        sourceDirs += file("${projectDir}/src/generated/main/grpc");
     }
 }
 
diff --git a/examples/build.gradle b/examples/build.gradle
index 0f3ea5b..ce0743a 100644
--- a/examples/build.gradle
+++ b/examples/build.gradle
@@ -59,15 +59,10 @@
     fileMode = 0755
 }
 
-// Allow intellij projects to refer to generated-sources
+// Let intellij projects refer to generated code
 idea {
     module {
-        // The whole build dir is excluded by default, but we need build/generated-sources,
-        // which contains the generated proto classes.
-        excludeDirs = [file('.gradle')]
-        if (buildDir.exists()) {
-            excludeDirs += files(buildDir.listFiles())
-            excludeDirs -= file("$buildDir/generated-sources")
-        }
+        sourceDirs += file("${projectDir}/src/generated/main/java");
+        sourceDirs += file("${projectDir}/src/generated/main/grpc");
     }
 }
diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle
index 316a57e..6c60c38 100644
--- a/interop-testing/build.gradle
+++ b/interop-testing/build.gradle
@@ -63,15 +63,10 @@
 
 configureProtoCompilation()
 
-// Allow intellij projects to refer to generated-sources
+// Let intellij projects refer to generated code
 idea {
     module {
-        // The whole build dir is excluded by default, but we need build/generated-sources,
-        // which contains the generated proto classes.
-        excludeDirs = [file('.gradle')]
-        if (buildDir.exists()) {
-          excludeDirs += files(buildDir.listFiles())
-          excludeDirs -= file("$buildDir/generated-sources")
-        }
+        sourceDirs += file("${projectDir}/src/generated/main/java");
+        sourceDirs += file("${projectDir}/src/generated/main/grpc");
     }
 }