title: error: cannot find symbol in gradle compileTestJava
body: <p>I am getting lots of <code>error: cannot find symbol</code> errors when the compileTestJava task runs in my Gradle project.</p>
  
  <p>My code is in <code>src/main/java</code> and my tests are in <code>src/test/java</code> and the test classes cannot resolve any classes in <code>src/main/java</code></p>
  
  <p>e.g.:</p>
  
  <pre><code>C:\q\src\test\java\q\MainTest.java:14: error: cannot find symbol
              Main.main(new String[0]);
              ^
    symbol:   variable Main
    location: class MainTest
  </code></pre>
  
  <p>But <code>q\src\main\java\q\Main.java</code> exists, compiles and is a public class in the same package.</p>
  
  <p>build.gradle:</p>
  
  <pre><code>plugins {
      id 'java'
  }
  
  repositories {
      jcenter()
  }
  
  dependencies {
      implementation 'com.google.guava:guava:29.0-jre'
  
      testImplementation 'junit:junit:4.13'
  }
  </code></pre>
  
  <p>I have been working around this by adding the following to build.gradle:</p>
  
  <pre><code>sourceSets {
         test {
                 java.srcDirs = ['src/main/', 'src/test/']
         }
  }
  </code></pre>
  
  <p>And that works, but it causes errors in IntelliJ.</p>