What is the correct way to configure an Android project with submodules for use with the sonarqube gradle plugin? Google has not been my friend, but I may have missed something basic. (I search for sonarqube issues related to the android build directories and submodules. No useful results.)
At a very high level, I am working with an Android project with the following structure.
git_repository
|----- android_project
|--- app
|--- SDK
|- api
The git_repository contains the README.md and other top level files including the android_project. The android_project contains the the app, as well as a git submodule in SDK. This git submodules contains the api code that app needs to run.
The problem is that when I try to run sonarqube, it seems to be looking for files/directories that do not exist. I do not have this problem with a simpler minimal project. I plan to set up a minimal project that uses submodules on Monday, but I want to get this question out the door before I leave for the weekend.
$ ./gradlew clean sonarqube
* snip *
:sonarqube
Invalid value for sonar.java.test.libraries
:sonarqube FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sonarqube'.
> No files nor directories matching '/Users/my_username/git_repository/android_project/app/build/intermediates/dependency-cache/debug'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log output.
BUILD FAILED
Total time: 9.897 secs
$
This gradle task is fail on a MacOS/Android Studio command line setup, but the ultimate goal is to have a configuration that works with Jenkins. My settings.gradle and build.gradle files follow. Clearly I am doing something wrong.
git_repository/android_project/settings.gradle complete listing
include ':app', ':api'
project(':api').projectDir = new File('SDK/api')
git_repository/android_project/build.gradle complete listing
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'org.sonarqube'
allprojects {
repositories {
jcenter()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
}
//subprojects {
// sonarqube {
// properties {
// // property "sonar.sources", "src"
// }
// }
//}
//sonarqube {
// properties {
//// property "sonar.exclusions", "file:**/SDK/**"
// }
//}
subprojects {
sonarqube {
properties {
property "sonar.sourceEncoding","UTF-8"
property "sonar.sources","src/main/java"
property "sonar.java.binaries", "./build/"
property "sonar.tests","src/androidTest"
// property "sonar.exclusions","build,build/**,**/*.png"
property "sonar.import_unknown_files", true
property "sonar.android.lint.report", "./build/outputs/lint-results.xml"
}
}
}
project(":api") {
sonarqube {
skipProject = true
}
}