Class AndroidConfig

java.lang.Object
org.sonarqube.gradle.AndroidConfig

public class AndroidConfig extends Object
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 Type
    Method
    Description
    void
    Populate the properties of an Android variant with Android specific values.
    org.gradle.api.file.FileCollection
    Get the source directories for the selected Android variant.
    org.gradle.api.file.FileCollection
    Get the source directories for the selected Android variant's tests.
    org.gradle.api.file.FileCollection
    Get the main libraries file collection for the variant selected for the analysis with Sonar.
    List<org.gradle.api.Task>
    Get the Android tasks on which Sonar tasks need to depend for the variant selected for the analysis with Sonar.
    org.gradle.api.file.FileCollection
    Get the test libraries file collection for the variant selected for the analysis with Sonar.
    com.android.build.api.variant.Variant
    Get the variant selected for the analysis with Sonar.
    of(org.gradle.api.Project project)
     
    static boolean
    Check if a Gradle project uses the Android Gradle plugin with a version greater or equal to 9.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • of

      public static AndroidConfig of(org.gradle.api.Project project)
    • 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 the ANDROID_GRADLE_PLUGIN_VERSION constant, 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

      public 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.
    • configureProperties

      public void configureProperties(Map<String,Object> properties)
      Populate the properties of an Android variant with Android specific values.