Kotlin files in a module of the Android Studio project are ignored during scanning

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Enterprise edition 9.5 ,android studio 2021.2

  • what are you trying to achieve
    All java and kotlin files in all moudles can be scanned success and report in sonarqube project.

  • what have you tried so far to achieve this
    I tried using the sonary.inclusions parameter to include ignored files, but this didn’t work .

The project has two modules, app and Kotlinlib.In Kotlinlib moudle,the kotlin files in the src\main\java path are scanned and the kotlin files in the src\main\kotlin path are ignored .The project structure is as follows:

The project’s build.gradle file, sonarqube parameters are as follows :

sonarqube {
    properties {
        property "sonar.sourceEncoding","UTF-8"
        property "sonar.projectKey","android"
        property "sonar.projectName","android"
       property "sonar.sources","src"
        property "sonar.projectVersion","7.0"
        property "sonar.binaries","build/"
    }
}

project(":kotlinlib") {
   sonarqube {
       properties {
        property "sonar.inclusions","src/main/kotlin"
    }
  }
}

The results of the analysis are shown in sonarqube as follows:

1 Like

Customer’s issue was resolved by explicitly defining source paths in his build.gradle file.

project(":kotlinlib") {
  sonarqube {
     properties {
          property "sonar.exclusions","src/main/rs"
     property "sonar.sources","E:\\source\\Android\\projects\\helloworld\\kotlinlib\\src\\main\\AndroidManifest.xml,E:\\source\\Android\\projects\\helloworld\\kotlinlib\\src\\main\\java,E:\\source\\Android\\projects\\helloworld\\kotlinlib\\src\\main\\kotlin,E:\\source\\Android\\projects\\helloworld\\kotlinlib\\src\\main\\rs"
   }
  }
}
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.