【发布时间】:2013-12-24 07:53:37
【问题描述】:
我正在将一些用于 iOS 和 OSX 的 Ant 构建转换为 Gradle。已创建以下内容:
class XcodeBuildTask extends DefaultTask {
@TaskAction
def build() {
def moduleName = 'Typhoon' as String
def commandLine = """
#!/bin/sh
xcodebuild -workspace ${moduleName}.xcworkspace test -scheme Typhoon-iOS -configuration Debug | xcpretty -c -t junit
"""
def xcodeBuildOutput = new ByteArrayOutputStream();
def consoleInput = new ByteArrayInputStream()
exec {
executable 'bash'
standardInput = new ByteArrayInputStream(commandLine.getBytes());
standardOutput = xcodeBuildOutput
}
}
}
它应该创建一个 bash 脚本并将其传递给 exec 任务。但是,运行它我得到错误:
任务 ':xcodebuild' 执行失败。
没有方法签名:静态 org.gradle.api.Project.exec() 适用于参数类型:(XcodeBuildTask$_build_closure1) 值:[XcodeBuildTask$_build_closure1@7bbe7fb2] 可能的解决方案:every()、grep()、each(groovy.lang.Closure)、grep(java.lang.Object)、use([Ljava.lang.Object;)、every(groovy.lang.Closure)
这可能很简单,但我做错了什么?如何从我的自定义类中调用 exec 任务?
【问题讨论】: