Interface BaseVariant

All Known Subinterfaces:
ApkVariant, ApplicationVariant, FeatureVariant, com.android.build.gradle.internal.core.InternalBaseVariant, LibraryVariant, TestVariant, UnitTestVariant

@Deprecated public interface BaseVariant
Deprecated.
A Build variant and all its public data. This is the base class for items common to apps, test apps, and libraries
  • Method Details

    • getName

      @NonNull String getName()
      Deprecated.
      Returns the name of the variant. Guaranteed to be unique.
    • getDescription

      @NonNull String getDescription()
      Deprecated.
      Returns a description for the build variant.
    • getDirName

      @NonNull String getDirName()
      Deprecated.
      Returns a subfolder name for the variant. Guaranteed to be unique. This is usually a mix of build type and flavor(s) (if applicable). For instance this could be: "debug" "debug/myflavor" "release/Flavor1Flavor2"
    • getBaseName

      @NonNull String getBaseName()
      Deprecated.
      Returns the base name for the output of the variant. Guaranteed to be unique.
    • getFlavorName

      @NonNull String getFlavorName()
      Deprecated.
      Returns the flavor name of the variant. This is a concatenation of all the applied flavors
      Returns:
      the name of the flavors, or an empty string if there is not flavors.
    • getOutputs

      @NonNull org.gradle.api.DomainObjectCollection<BaseVariantOutput> getOutputs()
      Deprecated.
      Returns the variant outputs. There should always be at least one output.
      Returns:
      a non-null list of variants.
    • getBuildType

      @NonNull com.android.builder.model.BuildType getBuildType()
      Deprecated.
      Returns the BuildType for this build variant.
    • getMergedFlavor

      @NonNull com.android.builder.model.ProductFlavor getMergedFlavor()
      Deprecated.
      Returns a ProductFlavor that represents the merging of the default config and the flavors of this build variant.
    • getJavaCompileOptions

      @NonNull com.android.build.gradle.api.JavaCompileOptions getJavaCompileOptions()
      Deprecated.
      Returns a JavaCompileOptions that represents the java compile settings for this build variant.
    • getProductFlavors

      @NonNull List<com.android.builder.model.ProductFlavor> getProductFlavors()
      Deprecated.
      Returns the list of ProductFlavor for this build variant.

      This is always non-null but could be empty.

    • getSourceSets

      @NonNull List<com.android.builder.model.SourceProvider> getSourceSets()
      Deprecated.
      Returns a list of sorted SourceProvider in order of ascending order, meaning, the earlier items are meant to be overridden by later items.
      Returns:
      a list of source provider
    • getSourceFolders

      @NonNull List<org.gradle.api.file.ConfigurableFileTree> getSourceFolders(@NonNull SourceKind folderType)
      Deprecated.
      Returns a list of FileCollection representing the source folders.

      You can replace calls to this method by using Component.getSources(), then use the Sources.getJava() and then SourceDirectories.Flat.getAll().

      Parameters:
      folderType - the type of folder to return.
      Returns:
      a list of folder + dependency as file collections.
    • getCompileConfiguration

      @NonNull org.gradle.api.artifacts.Configuration getCompileConfiguration()
      Deprecated.
      Returns the configuration object for the compilation
    • getAnnotationProcessorConfiguration

      @NonNull org.gradle.api.artifacts.Configuration getAnnotationProcessorConfiguration()
      Deprecated.
      Returns the configuration object for the annotation processor.
    • getRuntimeConfiguration

      @NonNull org.gradle.api.artifacts.Configuration getRuntimeConfiguration()
      Deprecated.
      Returns the configuration object for the runtime
    • getApplicationId

      @NonNull String getApplicationId()
      Deprecated.
      Returns the applicationId of the variant.
    • getApplicationIdTextResource

      @NonNull @Deprecated org.gradle.api.resources.TextResource getApplicationIdTextResource()
      Deprecated.
      use ApplicationVariants#getApplicationId().
      Returns the true application Id of the variant. For feature variants, this returns the resolved application id from the application. For application variants, this is the same as getApplicationId.
    • getPreBuild

      @NonNull @Deprecated org.gradle.api.Task getPreBuild()
      Deprecated.
      Returns the pre-build anchor task
    • getPreBuildProvider

      @NonNull org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getPreBuildProvider()
      Deprecated.
      Returns the TaskProvider for the pre-build anchor task.

      Prefer this to getPreBuild() as it triggers eager configuration of the task.

    • getCheckManifest

      @NonNull @Deprecated org.gradle.api.Task getCheckManifest()
      Returns the check manifest task.
    • getCheckManifestProvider

      @NonNull org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getCheckManifestProvider()
      Deprecated.
      Returns the TaskProvider for the check manifest task.

      Prefer this to getCheckManifest() as it triggers eager configuration of the task.

    • getAidlCompile

      @Nullable @Deprecated com.android.build.gradle.tasks.AidlCompile getAidlCompile()
      Deprecated.
      Returns the AIDL compilation task.

      If aidl feature is disabled via BuildFeatures.getAidl() this will throw an exception (or return null during sync.)

    • getAidlCompileProvider

      @Nullable org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.AidlCompile> getAidlCompileProvider()
      Deprecated.
      Returns the TaskProvider for the AIDL compilation task.

      If aidl feature is disabled via BuildFeatures.getAidl() this will throw an exception (or return null during sync.)

      Prefer this to getAidlCompile() as it triggers eager configuration of the task.

    • getRenderscriptCompile

      @Nullable @Deprecated com.android.build.gradle.tasks.RenderscriptCompile getRenderscriptCompile()
      Returns the Renderscript compilation task.

      If renderscript feature is disabled via BuildFeatures.getRenderScript() this will throw an exception (or return null during sync.)

    • getRenderscriptCompileProvider

      @Nullable org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.RenderscriptCompile> getRenderscriptCompileProvider()
      Deprecated.
      Returns the TaskProvider for the Renderscript compilation task.

      Prefer this to getRenderscriptCompile() as it triggers eager configuration of the task.

      If renderscript feature is disabled via BuildFeatures.getRenderScript() this will throw an exception (or return null during sync.)

    • getMergeResources

      @Nullable @Deprecated com.android.build.gradle.tasks.MergeResources getMergeResources()
      Returns the resource merging task.
    • getMergeResourcesProvider

      @Nullable org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.MergeResources> getMergeResourcesProvider()
      Deprecated.
      Returns the TaskProvider for the resource merging task.

      Prefer this to getMergeResources() as it triggers eager configuration of the task.

    • getMergeAssets

      @Nullable @Deprecated com.android.build.gradle.tasks.MergeSourceSetFolders getMergeAssets()
      Deprecated.
      Returns the asset merging task.
    • getMergeAssetsProvider

      @Nullable org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.MergeSourceSetFolders> getMergeAssetsProvider()
      Deprecated.
      Returns the TaskProvider for the asset merging task.

      Prefer this to getMergeAssets() as it triggers eager configuration of the task.

    • getGenerateBuildConfig

      @Nullable @Deprecated com.android.build.gradle.tasks.GenerateBuildConfig getGenerateBuildConfig()
      Returns the BuildConfig generation task.
    • getGenerateBuildConfigProvider

      @Nullable org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.GenerateBuildConfig> getGenerateBuildConfigProvider()
      Deprecated.
      Returns the TaskProvider for the BuildConfig generation task.

      Prefer this to getGenerateBuildConfig() as it triggers eager configuration of the task.

    • getJavaCompile

      @NonNull @Deprecated org.gradle.api.tasks.compile.JavaCompile getJavaCompile()
      Deprecated.
      Returns the Java Compilation task
    • getJavaCompileProvider

      @NonNull org.gradle.api.tasks.TaskProvider<org.gradle.api.tasks.compile.JavaCompile> getJavaCompileProvider()
      Deprecated.
      Returns the TaskProvider for the Java Compilation task

      Prefer this to getJavaCompile() as it triggers eager configuration of the task.

    • getJavaCompiler

      @NonNull @Deprecated org.gradle.api.Task getJavaCompiler()
      Deprecated.
      Returns the Java Compiler task.
    • getCompileClasspath

      @NonNull org.gradle.api.file.FileCollection getCompileClasspath(@Nullable Object key)
      Deprecated.
      Returns the java compilation classpath.

      The provided key allows controlling how much of the classpath is returned.

      • if null, the full classpath is returned
      • Otherwise the method returns the classpath up to the generated bytecode associated with the key
      Parameters:
      key - the key
      See Also:
    • getCompileClasspathArtifacts

      @NonNull org.gradle.api.artifacts.ArtifactCollection getCompileClasspathArtifacts(@Nullable Object key)
      Deprecated.
      Returns the java compilation classpath as an ArtifactCollection

      The provided key allows controlling how much of the classpath is returned.

      • if null, the full classpath is returned
      • Otherwise the method returns the classpath up to the generated bytecode associated with the key
      Parameters:
      key - the key
      See Also:
    • getExternalNativeBuildTasks

      @NonNull @Deprecated Collection<com.android.build.gradle.tasks.ExternalNativeBuildTask> getExternalNativeBuildTasks()
      Returns the tasks for building external native projects.
    • getExternalNativeBuildProviders

      @NonNull Collection<org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.ExternalNativeBuildTask>> getExternalNativeBuildProviders()
      Deprecated.
      Returns the tasks for building external native projects.

      Prefer this to getExternalNativeBuildTasks() as it triggers eager configuration of the tasks.

    • getObfuscation

      @Nullable @Deprecated org.gradle.api.Task getObfuscation()
      Deprecated.
      This always returns null
      Returns the obfuscation task. This can be null if obfuscation is not enabled.
    • getMappingFile

      @Nullable @Deprecated File getMappingFile()
      Deprecated.
      Please use getMappingFileProvider() instead in order to avoid task configuration.
      Returns the obfuscation mapping file. This can be null if obfuscation is not enabled.
    • getMappingFileProvider

      @NonNull org.gradle.api.provider.Provider<org.gradle.api.file.FileCollection> getMappingFileProvider()
      Deprecated.
      Returns the provider of a file collection that contains an obfuscation mapping file. The file collection may be empty if obfuscation is not enabled.
    • getProcessJavaResources

      @NonNull @Deprecated org.gradle.api.tasks.AbstractCopyTask getProcessJavaResources()
      Returns the Java resource processing task.
    • getProcessJavaResourcesProvider

      @NonNull org.gradle.api.tasks.TaskProvider<org.gradle.api.tasks.AbstractCopyTask> getProcessJavaResourcesProvider()
      Deprecated.
      Returns the Java resource processing task.

      Prefer this to getProcessJavaResources() as it triggers eager configuration of the task.

    • getAssemble

      @Nullable @Deprecated org.gradle.api.Task getAssemble()
      Deprecated.
      Returns the assemble task for all this variant's output
    • getAssembleProvider

      @Nullable org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getAssembleProvider()
      Deprecated.
      Returns the TaskProvider for the assemble task.

      Prefer this to getAssemble() as it triggers eager configuration of the task.

    • addJavaSourceFoldersToModel

      void addJavaSourceFoldersToModel(@NonNull File... sourceFolders)
      Deprecated.
      Adds new Java source folders to the model. These source folders will not be used for the default build system, but will be passed along the default Java source folders to whoever queries the model.
      Parameters:
      sourceFolders - the source folders where the generated source code is.
    • addJavaSourceFoldersToModel

      void addJavaSourceFoldersToModel(@NonNull Collection<File> sourceFolders)
      Deprecated.
      Adds new Java source folders to the model. These source folders will not be used for the default build system, but will be passed along the default Java source folders to whoever queries the model.
      Parameters:
      sourceFolders - the source folders where the generated source code is.
    • registerJavaGeneratingTask

      @Deprecated void registerJavaGeneratingTask(@NonNull org.gradle.api.Task task, @NonNull File... sourceFolders)
      Adds to the variant a task that generates Java source code.

      This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

      The new source folders are also added to the model.

      N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

      Parameters:
      task - the task
      sourceFolders - the source folders where the generated source code is.
    • registerJavaGeneratingTask

      @Deprecated void registerJavaGeneratingTask(@NonNull org.gradle.api.Task task, @NonNull Collection<File> sourceFolders)
      Deprecated.
      Use #registerJavaGeneratingTask(TaskProvider, Collection<File>)
      Adds to the variant a task that generates Java source code.

      This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

      The new source folders are also added to the model.

      N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

      Parameters:
      task - the task
      sourceFolders - the source folders where the generated source code is.
    • registerJavaGeneratingTask

      void registerJavaGeneratingTask(@NonNull org.gradle.api.tasks.TaskProvider<? extends org.gradle.api.Task> taskProvider, @NonNull File... sourceFolders)
      Deprecated.
      Adds to the variant a task that generates Java source code.

      This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

      The new source folders are also added to the model.

      N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

      Parameters:
      taskProvider - the task provider
      sourceFolders - the source folders where the generated source code is.
    • registerJavaGeneratingTask

      void registerJavaGeneratingTask(@NonNull org.gradle.api.tasks.TaskProvider<? extends org.gradle.api.Task> taskProvider, @NonNull Collection<File> sourceFolders)
      Deprecated.
      Adds to the variant a task that generates Java source code.

      This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

      The new source folders are also added to the model.

      N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

      Parameters:
      taskProvider - the task provider
      sourceFolders - the source folders where the generated source code is.
    • registerExternalAptJavaOutput

      void registerExternalAptJavaOutput(@NonNull org.gradle.api.file.ConfigurableFileTree folder)
      Deprecated.
      Register the output of an external annotation processor.

      The output is passed to the javac task, but the source generation hooks does not depend on this.

      In order to properly wire up tasks, the FileTree object must include dependency information about the task that generates the content of this folders.

      Parameters:
      folder - a ConfigurableFileTree that contains a single folder and the task dependency information
    • registerGeneratedResFolders

      void registerGeneratedResFolders(@NonNull org.gradle.api.file.FileCollection folders)
      Deprecated.
      Adds to the variant new generated resource folders.

      In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of this folders.

      Parameters:
      folders - a FileCollection that contains the folders and the task dependency information
    • registerResGeneratingTask

      @Deprecated void registerResGeneratingTask(@NonNull org.gradle.api.Task task, @NonNull File... resFolders)
      Adds to the variant a task that generates Resources. This will make the generate[Variant]Resources task depend on this task and add the new Resource folders as Resource merge inputs. The Resource folders are also added to the model.
      Parameters:
      task - the task
      resFolders - the folders where the generated resources are.
    • registerResGeneratingTask

      @Deprecated void registerResGeneratingTask(@NonNull org.gradle.api.Task task, @NonNull Collection<File> resFolders)
      Adds to the variant a task that generates Resources. This will make the generate[Variant]Resources task depend on this task and add the new Resource folders as Resource merge inputs. The Resource folders are also added to the model.
      Parameters:
      task - the task
      resFolders - the folders where the generated resources are.
    • registerPreJavacGeneratedBytecode

      Object registerPreJavacGeneratedBytecode(@NonNull org.gradle.api.file.FileCollection fileCollection)
      Deprecated.
      Adds to the variant new generated Java byte-code.

      This bytecode is passed to the javac classpath. This is typically used by compilers for languages that generate bytecode ahead of javac.

      The file collection can contain either a folder of class files or jars.

      In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of these folders. This is generally setup using ConfigurableFileCollection.builtBy(Object...)

      The generated byte-code will also be added to the transform pipeline as a QualifiedContent.Scope.PROJECT stream.

      The method returns a key that can be used to query for the compilation classpath. This allows each successive call to registerPreJavacGeneratedBytecode(FileCollection) to be associated with a classpath containing everything before the added bytecode.

      Parameters:
      fileCollection - a FileCollection that contains the files and the task dependency information
      Returns:
      a key for calls to registerGeneratedBytecode(FileCollection)
    • registerGeneratedBytecode

      @Deprecated Object registerGeneratedBytecode(@NonNull org.gradle.api.file.FileCollection fileCollection)
    • registerPostJavacGeneratedBytecode

      void registerPostJavacGeneratedBytecode(@NonNull org.gradle.api.file.FileCollection fileCollection)
      Deprecated.
      Adds to the variant new generated Java byte-code.

      This bytecode is meant to be post javac, which means javac does not have it on its classpath. It's is only added to the java compilation task's classpath and will be added to the transform pipeline as a QualifiedContent.Scope.PROJECT stream.

      The file collection can contain either a folder of class files or jars.

      In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of these folders. This is generally setup using ConfigurableFileCollection.builtBy(Object...)

      Parameters:
      fileCollection - a FileCollection that contains the files and the task dependency information
    • buildConfigField

      void buildConfigField(@NonNull String type, @NonNull String name, @NonNull String value)
      Deprecated.
      Adds a variant-specific BuildConfig field.
      Parameters:
      type - the type of the field
      name - the name of the field
      value - the value of the field
    • resValue

      void resValue(@NonNull String type, @NonNull String name, @NonNull String value)
      Deprecated.
      Adds a variant-specific res value.
      Parameters:
      type - the type of the field
      name - the name of the field
      value - the value of the field
    • missingDimensionStrategy

      void missingDimensionStrategy(@NonNull String dimension, @NonNull String requestedValue)
      Deprecated.
      Set up a new matching request for a given flavor dimension and value.

      To learn more, read Select default flavors for missing dimensions.

      Parameters:
      dimension - the flavor dimension
      requestedValue - the flavor name
    • missingDimensionStrategy

      void missingDimensionStrategy(@NonNull String dimension, @NonNull String... requestedValues)
      Deprecated.
      Set up a new matching request for a given flavor dimension and value.

      To learn more, read Select default flavors for missing dimensions.

      Parameters:
      dimension - the flavor dimension
      requestedValues - the flavor name and fallbacks
    • missingDimensionStrategy

      void missingDimensionStrategy(@NonNull String dimension, @NonNull List<String> requestedValues)
      Deprecated.
      Set up a new matching request for a given flavor dimension and value.

      To learn more, read Select default flavors for missing dimensions.

      Parameters:
      dimension - the flavor dimension
      requestedValues - the flavor name and fallbacks
    • setOutputsAreSigned

      void setOutputsAreSigned(boolean isSigned)
      Deprecated.
      If true, variant outputs will be considered signed. Only set if you manually set the outputs to point to signed files built by other tasks.
    • getOutputsAreSigned

      boolean getOutputsAreSigned()
      Deprecated.
      See Also:
    • getAllRawAndroidResources

      @Incubating @NonNull org.gradle.api.file.FileCollection getAllRawAndroidResources()
      Deprecated.
      Returns file collection containing all raw Android resources, including the ones from transitive dependencies.

      This is an incubating API, and it can be changed or removed without notice.

    • register

      @Incubating void register(org.gradle.api.Task task)
      Deprecated.
      Registers a task to be executed before any main output tasks like the assemble or bundle tasks are invoked.

      The task will need to set up its dependencies on the build outputs (whether it is an intermediate output or the final one) independently of this call.