title: Exclude some folders and files from any process in gradle
body: <p>I have a small project for Android and try to add some source folders.
  Using something like this works:</p>
  
  <pre><code>sourceSets {
      main.java.srcDirs += '../../some-source-folder/'
  }
  </code></pre>
  
  <p>I also added this in my iml file:</p>
  
  <pre><code>&lt;content url="file://$MODULE_DIR$/../../some-source-folder"&gt;
    &lt;sourceFolder url="file://$MODULE_DIR$/../../some-source-folder" isTestSource="false" /&gt;
    &lt;excludeFolder url="file://$MODULE_DIR$/../../some-source-folder/sub-folder" /&gt;
  &lt;/content&gt;
  </code></pre>
  
  <p>The problem now is, that I really need to exclude some of the subfolders of my source folder 'some-source-folder'
  Using excludeFolder in my iml file means the sub folder are not displayed in my Android stdio. But they still will be compiled using gradle.</p>
  
  <p>But nothing works in my gradle file to exclude some of the subfolders with java files which shall not be compiled!</p>
  
  <pre><code>sourceSets {
      main.java.srcDirs += '../../some-source-folder/'
      main {
          java {
              exclude ('../../some-source-folder/some-subfolder', '../../some-source-folder/another-subfolder')
  
          }
      }
   }
  </code></pre>
  
  <p>does not work.</p>
  
  <pre><code>sourceSets {
      main.java.srcDirs += '../../some-source-folder/'
      exclude '../../some-source-folder/some-subfolder'
      exclude '../../some-source-folder/another-subfolder'
   }
  </code></pre>
  
  <p>does not work either.</p>
  
  <p>If I try to add something with excludes in a comple closure e.g.</p>
  
  <pre><code>compile {
       exclude '../../some-source-folder/some-subfolder'
  }
  </code></pre>
  
  <p>I get an error </p>
  
  <p><strong>Gradle sync failed: Could not find method compile() for arguments [build_....]</strong></p>
  
  <p>I get similiar errors using</p>
  
  <pre><code> excludes '...'
  </code></pre>
  
  <p>or</p>
  
  <pre><code> exclude = ['....', '....', '....']
  </code></pre>
  
  <p>will lead to the errors:</p>
  
  <p><strong>Gradle sync failed: Could not find method excludes() for arguments ...</strong></p>
  
  <p>and</p>
  
  <p><strong>Gradle sync failed: No signature of method: java.util.LinkedHashSet.getAt() is applicable for argument types: (java.util.ArrayList) values:</strong></p>
  
  <p>Is there an easy way to add any source folder to a project in Android Studio and excluding couple of sub folders or/and source files?</p>