All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.autonomousapps.internal.analyzer.AndroidVariant.kt Maven / Gradle / Ivy

There is a newer version: 2.6.1
Show newest version
// Copyright (c) 2024. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
package com.autonomousapps.internal.analyzer

import com.android.build.api.variant.HasAndroidTest
import com.android.build.api.variant.Variant
import org.gradle.api.Project
import org.gradle.api.provider.Provider

internal interface AndroidVariant {
  val flavorName: String
  val variantName: String
  val buildType: String
  val testInstrumentationRunner: Provider
}

internal class DefaultAndroidVariant(
  override val flavorName: String,
  override val variantName: String,
  override val buildType: String,
  override val testInstrumentationRunner: Provider,
) : AndroidVariant {
  constructor(project: Project, variant: Variant) : this(
    flavorName = variant.flavorName.orEmpty(),
    variantName = variant.name,
    buildType = variant.buildType.orEmpty(),
    testInstrumentationRunner = getTestInstrumentationRunner(project, variant),
  )

  private companion object {
    fun getTestInstrumentationRunner(project: Project, variant: Variant): Provider {
      return if (variant is HasAndroidTest) {
        variant.androidTest?.instrumentationRunner ?: project.provider { null }
      } else {
        project.provider { null }
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy