【问题标题】:Passing parameters to gradle build script将参数传递给 gradle 构建脚本
【发布时间】:2019-10-03 21:06:59
【问题描述】:

我正在尝试在控制台中执行这样的命令:

./gradlew cucumber -Pthreads=80 -Ptags=@ALL_API_TESTS

在 build.gradle 中:

cucumber {
    threads = "$threads"
    glue = 'classpath:com.sixtleasing.cucumber.steps'
    plugin = ['pretty']
    tags = "$tags"
    featurePath = 'src/main/resources/feature'
    main = 'cucumber.api.cli.Main'
}

但它不起作用:(我该如何解决它?

【问题讨论】:

  • “它不起作用”是什么意思:任何错误/堆栈跟踪?
  • 只执行一个线程。如果我向 gradle.build 添加 80 个线程,它可以工作
  • 它应该像你写的那样工作。你能用threads = project.findProperty("threads") 试试吗?
  • 你也可以直接试试project.threads

标签: java gradle groovy closures build.gradle


【解决方案1】:

您的原始表达式将线程设置为String 值,当它显然是一个数字时,因此您需要使用类似:

int threadsNum = "$threads".toInteger()
cucumber {
    threads = threadsNum
    glue = 'classpath:com.sixtleasing.cucumber.steps'
    plugin = ['pretty']
    tags = "$tags"
    featurePath = 'src/main/resources/feature'
    main = 'cucumber.api.cli.Main'
}

希望这会有所帮助。

【讨论】:

  • Grade 不接受它:( 我得到了 FAILURE: Build failed with an exception。异常在 "$threads".toInteger() 行中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-15
  • 2019-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多