0

I want to be able to define a variant specific variable.

flavor1{
variable = "thistask"
}
flavor2{
variable = "thattask"
}

Then when i execute it like

./gradlew aFlavor1

i want to be able to read variable as "thistask".

How can i accomplish this? How can i know which variant task is currently running?

guydemossyrock
  • 1,118
  • 9
  • 16
  • Gradle doesn't really work the way you expect here. It most ways it doesn't have the notion of what flavors it's going to output when it's evaluating much of the script in the build file. You'd have better luck formulating the question of exactly what you want to accomplish and looking for relevant StackOverflow questions. – Scott Barta Dec 05 '14 at 17:56

1 Answers1

0

Did you mean this:

$ cat build.gradle

task kobaLory << {

   def variable = "thistask"
   println "variable = " + variable

}

task loryKoba << {

   def variable = "thattask"
   println "variable = " + variable

}

OUTPUT

$ /cygdrive/c/gradle-1.6/bin/gradle kobaLory loryKoba

:kobaLory
variable = thistask

:loryKoba
variable = thattask

BUILD SUCCESSFUL

Total time: 4.25 secs

$

AKS
  • 16,482
  • 43
  • 166
  • 258