【问题标题】:CommandLine inside a loop循环内的命令行
【发布时间】:2014-06-15 12:54:48
【问题描述】:

我正在使用一个 gradle 任务,它在文件收集循环中执行命令行:

...
collection.each { file ->
        exec {
            workingDir = file(props['WORKING_DIR']).getAbsolutePath()
            commandLine "java", "-jar", file(props['SIGN_TOOL']).getAbsoluteFile(), file
        }
    }
...

不幸的是,gradle 任务以这个错误结束:

任务“:signFiles”执行失败。

没有方法签名:java.io.File.call() 适用于参数类型:(java.lang.String) 值:可能 解决方案:wait(), any(), wait(long), each(groovy.lang.Closure), 任何(groovy.lang.Closure),列表()

我该如何解决这个问题?

感谢 MVM

【问题讨论】:

    标签: android groovy gradle android-gradle-plugin build.gradle


    【解决方案1】:

    你已经调用了你的循环变量file,然后它试图用它来调用file()...

    尝试重命名你的闭包变量:

    collection.each { aFile ->
        exec {
            workingDir = file(props['WORKING_DIR']).getAbsolutePath()
            commandLine "java", "-jar", file(props['SIGN_TOOL']).getAbsoluteFile(), aFile
        }
    }
    

    【讨论】:

    • 我应该早点问你的 :D 谢谢你,先生!
    猜你喜欢
    • 2013-06-14
    • 1970-01-01
    • 2016-11-01
    • 2023-03-20
    • 1970-01-01
    • 2012-02-21
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    相关资源
    最近更新 更多