Package org.sonarqube.gradle
Class AndroidConfig
java.lang.Object
org.sonarqube.gradle.AndroidConfig
This class provides methods to compute Android specific properties for projects using the Android Gradle plugin (AGP) with versions greater than 9.
For AGP versions before 9, see the
LegacyAndroidConfig.
This class should only be accessed when running on an Android application, as it uses the runtime provided AGP library and will crash if it is not present.-
Method Summary
Modifier and TypeMethodDescriptionvoidconfigureProperties(Map<String, Object> properties) Populate the properties of an Android variant with Android specific values.org.gradle.api.file.FileCollectionGet the source directories for the selected Android variant.org.gradle.api.file.FileCollectionGet the source directories for the selected Android variant's tests.org.gradle.api.file.FileCollectionGet the main libraries file collection for the variant selected for the analysis with Sonar.List<org.gradle.api.Task>getTasks()Get the Android tasks on which Sonar tasks need to depend for the variant selected for the analysis with Sonar.org.gradle.api.file.FileCollectionGet the test libraries file collection for the variant selected for the analysis with Sonar.com.android.build.api.variant.VariantGet the variant selected for the analysis with Sonar.static AndroidConfigof(org.gradle.api.Project project) static booleanCheck if a Gradle project uses the Android Gradle plugin with a version greater or equal to 9.
-
Method Details
-
of
-
usesAndroidGradlePlugin9OrGreater
public static boolean usesAndroidGradlePlugin9OrGreater()Check if a Gradle project uses the Android Gradle plugin with a version greater or equal to 9. To compute this, the method uses theANDROID_GRADLE_PLUGIN_VERSIONconstant, which is defined by the plugin used at runtime for a project. -
getVariant
public com.android.build.api.variant.Variant getVariant()Get the variant selected for the analysis with Sonar. -
getMainLibraries
public org.gradle.api.file.FileCollection getMainLibraries()Get the main libraries file collection for the variant selected for the analysis with Sonar. -
getTestLibraries
public org.gradle.api.file.FileCollection getTestLibraries()Get the test libraries file collection for the variant selected for the analysis with Sonar. -
getAndroidSources
public org.gradle.api.file.FileCollection getAndroidSources()Get the source directories for the selected Android variant. -
getAndroidTests
public org.gradle.api.file.FileCollection getAndroidTests()Get the source directories for the selected Android variant's tests. -
getTasks
Get the Android tasks on which Sonar tasks need to depend for the variant selected for the analysis with Sonar. -
configureProperties
Populate the properties of an Android variant with Android specific values.
-