title: Gradle Build - Execution failed for task ':sonarqube' can't be indexed twice
body: <p>I am getting an error &quot;File can't be indexed twice&quot; in gradle build for sonar. Do i have to add any inclusion/exclusion property for sonar? Any help greatly appreciated.</p>
  <p>If I take out &quot;src/main/java&quot; in test under sourceSets, I am getting compilation error for junit test cases.</p>
  <p>This is how my build.gradle file content look,</p>
  <pre><code>group = 'groupid'
  apply plugin: 'gradleFortify'
  apply plugin: 'org.sonarqube'
  apply plugin: 'eclipse'
  apply plugin: 'groovy'
  apply plugin: 'java'
  apply plugin: 'jacoco'
  apply plugin: 'groovy'
  //apply plugin: &quot;java-library-distribution&quot;
  //apply plugin: 'distribution'
  
  version=version
  sourceCompatibility = 1.8
  
  
  repositories {
          maven {
          url &quot;artifactory&quot;
              credentials {
              }
          }
          sonarqube {
              properties {
                  property 'sonar.sourceEncoding', 'UTF-8'
                  property &quot;sonar.exclusions&quot;, [&quot;**/*Test.java&quot;]
              }
          }
  }
  
  buildscript {
      repositories {
          maven {
          url &quot;artifactory&quot;
              credentials {
              }
          }
      dependencies {
          classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7' 
          classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0'
          
      }
  }
  
  sourceSets {
      main {
          java {
              srcDirs = ['src/main/java']
          }
      }
      test {
          java.srcDirs = ['src/test/java','src/main/java']
      }
  }
  
  dependencies{
  
  
  }
   task preclean(type: Delete) {
       delete 'build'
   } 
   task jcompile(type: JavaCompile) {
       dependsOn preclean
       source = fileTree(dir: 'src/main/java', include: '**/*.java')
       destinationDir = file('build/classes')
       sourceCompatibility = '1.8'
       targetCompatibility = '1.8'
       classpath = configurations.runtime
   }
   
  
   task copyResources( type: Copy ) { 
   }
  
   task copyClasses( type: Copy ) {
   }
   
   
   jar {
      dependsOn jcompile
      archiveName = 'prj1.jar'
      manifest {
          attributes('Implementation-Title': project.name,
                     'Implementation-Version': project.version)
      }
       into('lib') {
           println &quot;includeInJar: &quot; + configurations.runtime.collect { File file -&gt; file }
           from configurations.runtime
       }
   }
  // jar.finalizedBy(jarTask) { }
   
   
  sonarqube {
      properties {
          property &quot;sonar.projectName&quot;, &quot;prj-${version}&quot;
          property &quot;sonar.projectKey&quot;, &quot;prj-${version}&quot;
      }
  }
  
  test {
      useJUnitPlatform()
      finalizedBy jacocoTestReport
  }
  jacocoTestReport {
      afterEvaluate {
          classDirectories = files(classDirectories.files.collect {
              fileTree(dir: it, includes: ['com/**'])
          })
      }
  }
  </code></pre>