mardi 3 mars 2020

If / then task execution in build.gradle?

I am trying to kick off automated mobile functional / end user tests in Gradle, so that gradle local runs tests on the local machine, and gradle perfecto reaches calls an API to run tests on a remote service provider out on the internet.

I'm having a hard time however making the non-selected task not run. In other words, I run gradle local and it still tries to run the perfecto configuration tasks.

The closest I can get so far is a custom build task class below. The point is that perfectoWork should not print "LocalWorkTask".

Any suggestions ? Am I headed in the right direction ? Thanks.

class LocalWorkTask extends DefaultTask {
  @TaskAction
  def printLocal() { println "LocalWorkTask" }
}

task perfectoWork {
  doLast { println "perfecto" }
}

task local(type: LocalWorkTask)

Aucun commentaire:

Enregistrer un commentaire