title: Generate java source code under my project's source code package
body: <p>I have my annotation processor:</p>
  
  <pre><code>public class MyAnnotationProcessor extends AbstractProcessor {
      ...
  
      @Override
      public boolean process(Set&lt;? extends TypeElement&gt; annotations, RoundEnvironment roundEnv) {
          // Here I deal with the annotated element
           ...
  
          // use JavaPoet to generate Java source file
          TypeSpec generatedClazz = generate_code();
          JavaFile javaFile = JavaFile.builder("com.my.foo", generatedClazz).build();
          javaFile.writeTo(filer);
      }
  
  }
  </code></pre>
  
  <p>After processing annotated element in above <code>process</code> callback, I use <a href="https://github.com/square/javapoet" rel="nofollow noreferrer">JavaPoet</a> to generate java source code &amp; create the Java file for the code. When build my project, everything works except that the generated java source code file by default goes to <code>build/generated/sources/myApp/com/my/foo</code>. How can I make the generated Java file to be located in my project's source code location <code>src/main/java/com/my/foo</code> ?</p>
  
  <p>My gradle build:</p>
  
  <pre><code>plugins {
      id 'java'
  }
  
  group 'com.my.app'
  version '1.0-SNAPSHOT'
  
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
  
      testImplementation 'junit:junit:4.12'
  
      implementation 'com.squareup:javapoet:1.11.1'
      implementation 'com.google.guava:guava:28.1-jre'
  }
  </code></pre>