If I’m using an if block to sometimes apply a plug...
# gradle
s
If I’m using an if block to sometimes apply a plugin, how do I resolve the plugin dsl so I can build, even when the plugin isn’t applied? i.e.
Copy code
plugins {
  if (Build.isCi) {
    id("com.google.firebase.appdistribution") //TODO not working
  }
}
Copy code
productFlavors {
    flavorDimensions("releaseType")
    create("internal") {
      // ...

      if (isCi) {
        firebaseAppDistribution { // <--- This doesn't resolve because the plugin is in an if block.
        }
      }
    }
l
@spierce7 Use the optional parameter
apply
and pass it
false
I mean, pass it
isCi
in your case.
s
@louiscad what optional parameter?
l
@spierce7 Solution to what you're looking for:
Copy code
plugins {
    id("com.google.firebase.appdistribution") apply Build.isCi
}
s
oh. that’s not very discoverable
I’m still seeing it as unresolved.
if I remove the
apply
then it seems to resolve
l
The IDE or Gradle is seeing it as unresolved?
s
Copy code
Unresolved reference: firebaseAppDistribution
Copy code
id("com.google.firebase.firebase-perf") apply Build.isCi
  id("com.google.firebase.appdistribution") apply Build.isCi
IDE
let met try gradle
gradle finds it unresolved also
l
Then, it seems like you'll need to apply it in all cases
s
that’s annoying. Almost seems like Kotlin isn’t a suitable langage for a build system