Leandro Borges Ferreira
Leandro Borges Ferreira

Reputation: 12792

Add variable in gradle command

I have to following gradle code:

testOptions {
    unitTests.returnDefaultValues = true
    unitTests.all {
        // All the usual Gradle options.
        jvmArgs '-XX:MaxPermSize=1024m'
    }

    execution 'ANDROID_TEST_ORCHESTRATOR'
}

And I am using Android test orchestrator, but I makes my UI tests take a lot of time to run. So I would like to be able to request for orchestrator in the command line like:

./gradlew androidConnectedCheck --orchestrator

So I can controll when to use orchestator. Is it possible to do that with gradle?

Edit:

I am not interested in using a gradle variable in my code (in Java or Kotlin) I would like to create a conditional test configuration accordingly with my command line

Upvotes: 2

Views: 457

Answers (1)

Jon
Jon

Reputation: 1763

./gradlew androidConnectedCheck -Porchestrator

And in gradle, you can do:

def orchestrator = project.hasProperty('orchestrator')

orchestrator will be true if it was passed as an arg. This uses the project-prop built into gradle command line.

Upvotes: 1

Related Questions