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

com.autonomousapps.model.declaration.SourceSetKind.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.autonomousapps.model.declaration

import com.autonomousapps.internal.utils.lowercase
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = false)
enum class SourceSetKind(
  val taskNameSuffix: String,
  private val compileClasspathFormatString: String,
  private val runtimeClasspathFormatString: String
) {
  // TODO V2: these format strings are Android-specific. This enum might be useful for JVM, too
  MAIN("Main", "%sCompileClasspath", "%sRuntimeClasspath"),
  TEST("Test", "%sUnitTestCompileClasspath", "%sUnitTestRuntimeClasspath"),
  ANDROID_TEST("androidTest", "%sAndroidTestCompileClasspath", "%sAndroidTestRuntimeClasspath"),
  CUSTOM_JVM("CUSTOM", "%sCompileClasspath", "%sRuntimeClasspath"),
  ;

  fun compileClasspathConfigurationName(variantName: String) = String.format(compileClasspathFormatString, variantName)
  fun runtimeClasspathConfigurationName(variantName: String) = String.format(runtimeClasspathFormatString, variantName)

  /**
   * Returns the primary/standard/"base" [variant][Variant] for this source set. E.g., for [MAIN], the primary variant
   * is ("main", MAIN) and corresponds to the source set `src/main`. Similarly for [TEST], the primary variant is
   * ("test", TEST) and corresponds to the source set `src/test`. In contrast, in the Android ecosystem, there are
   * variants like ("debug", MAIN), ("release", TEST), etc., and which correspond to the source sets `src/main` and
   * `src/test` (+ `src/release`, because "unit tests" in the Android world are the combination of TEST source and the
   * variant-specific MAIN source).
   */
  fun asBaseVariant(customVariantName: String?) = Variant(customVariantName ?: name.lowercase(), this)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy