1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Better variant support.

This commit is contained in:
Cedric Beust 2015-11-21 02:49:59 -08:00
parent 354668b6a3
commit e16892dbdb
10 changed files with 194 additions and 60 deletions

View file

@ -0,0 +1,43 @@
package com.beust.kobalt
import com.beust.kobalt.api.buildType
import com.beust.kobalt.api.productFlavor
import com.beust.kobalt.plugin.java.JavaProject
import org.testng.Assert
import org.testng.annotations.DataProvider
import org.testng.annotations.Test
import java.util.*
class VariantTest : KobaltTest() {
@DataProvider(name = "projectVariants")
fun projectVariants() = arrayOf(
arrayOf(emptySet<String>(), JavaProject().apply {
}),
arrayOf(hashSetOf("compileDev"), JavaProject().apply {
productFlavor("dev") {}
}),
arrayOf(hashSetOf("compileDev", "compileProd"), JavaProject().apply {
productFlavor("dev") {}
productFlavor("prod") {}
}),
arrayOf(hashSetOf("compileDevDebug"), JavaProject().apply {
productFlavor("dev") {}
buildType("debug") {}
}),
arrayOf(hashSetOf("compileDevRelease", "compileDevDebug", "compileProdDebug", "compileProdRelease"),
JavaProject().apply {
productFlavor("dev") {}
productFlavor("prod") {}
buildType("debug") {}
buildType("release") {}
})
)
@Test(dataProvider = "projectVariants", description =
"Make sure we generate the correct dynamic tasks based on the product flavor and build types.")
fun taskNamesShouldWork(expected: Set<String>, project: JavaProject) {
val variantNames = HashSet(Variant.allVariants(project).map { it.toTask("compile") })
Assert.assertEquals(variantNames, expected)
}
}