在 gradle 命令中添加变量

Add variable in gradle command

我必须遵循 gradle 代码:

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

    execution 'ANDROID_TEST_ORCHESTRATOR'
}

我正在使用 Android 测试编排器,但我 UI 测试花费了很多时间 运行。所以我希望能够在命令行中请求 orchestrator,例如:

./gradlew androidConnectedCheck --orchestrator

所以我可以控制何时使用 orchestator。 是否可以用 gradle 做到这一点?

编辑:

我对在我的代码中使用 gradle 变量不感兴趣(在 Java 或 Kotlin 中)我想使用我的命令行相应地创建条件测试配置

./gradlew androidConnectedCheck -Porchestrator

而在 gradle 中,您可以:

def orchestrator = project.hasProperty('orchestrator')
如果作为参数传递,

orchestrator 将为真。这使用内置于 gradle 命令行中的 project-prop