title: How do I get IntelliJ to recognize gradle generated sources dir?
body: <p>So I have an XJC javaExec that spins like a top but IntelliJ doesn't recognize the generated output despite having marked <code>generated-src/java</code> as such. Do I need to tweak the idea plug-in or something?</p>
  
  <p>Note: The plug-in itself is loaded in subProjects from the root <code>build.gradle</code>. </p>
  
  <p>XJC Project:</p>
  
  
  
  <pre class="lang-groovy prettyprint-override"><code>description = "Generates sources and compiles them into a Jar for $project"
  
  configurations { xjc }
  dependencies {
      xjc 'org.glassfish.jaxb:jaxb-xjc:2.2.11'
      xjc 'org.glassfish.jaxb:jaxb-runtime:2.2.11'
  }
  
  task xjc (type:JavaExec) {
  
      doFirst{
          File generatedSrcDir = file("$buildDir/generated-src/java")
          if (!generatedSrcDir.exists()) {
              generatedSrcDir.mkdirs()
          }
      }
  
      main = "com.sun.tools.xjc.XJCFacade"
      classpath configurations.xjc
  
      def argsList = [
              "-mark-generated",
              "-no-header",
              "-verbose", // or -quiet or nothing for default.
              "-target", "2.1",
              "-encoding", "UTF-8",
              "-d", "$buildDir/generated-src/java",
              "-catalog","$projectDir/src/main/resources/commons-gradle.cat",
              file("$projectDir/src/main/resources/v1/") ]
  
      args argsList
      inputs.files files(file("$projectDir/src/main/resources/v1/"))
      outputs.files files(file("$buildDir/generated-src/java"),file("$buildDir/classes"))
  
  }
  
  compileJava {
      dependsOn xjc
      source "${buildDir}/generated-src"
  }
  </code></pre>
  
  <p>In the project that depends on this one I simply have:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>compile project(":path:to:schemas:the-test-schema")
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>idea {
      module {
  
          def buildDir = file("$buildDir")
          def generatedDir = file("$buildDir/generated-src")
          def listOfDirs = []
  
          buildDir.eachDir { file -&gt;
              if (file.name != buildDir.name &amp;&amp; file.name != generatedDir.name)
              listOfDirs.add(file)
          }
  
          excludeDirs = listOfDirs.toArray()
  
          generatedSourceDirs += file("$buildDir/generated-src/java")
          scopes.COMPILE.plus += [ configurations.xjc ]
      }
  }
  </code></pre>