Reputation: 15635
We use a company-wide gradle configuration which is applied to all our gradle projects.
Projects using this config might apply different types of plugins (specificially the plugins java
or android
& android-library
). In order to get the sonarRunner
plugin to automatically check the android projects, additional properties have to be applied which are not available for java projects.
Now to the question: How can additional sonarRunner (or other) properties be applied only to projects applying a specific (in this case "android" or "android-library") plugin?
What I have tried so far, but does not work as the AndroidPlugin
property is not know in the preparation phase:
plugins.withType(AndroidPlugin) {
sonarRunner {
sonarProperties {
property "sonar.profile", "Android"
...
}
}
}
Upvotes: 1
Views: 370
Reputation: 123910
Sounds like the code is missing an import for the AndroidPlugin
class. Alternatively, plugins.withId("android")
can be used for current gradle versions or afterEvaluate { if (plugins.hasPlugin("android")) { ... } }
for gradle 1.12 and earlier.
Upvotes: 2