从gradle调用ant时抛出org.gradle.process.internal.ExecException

时间:2019-05-07 14:13:07

标签: gradle groovy

我正在尝试在gradle脚本中运行特定版本的ant,但是当gradle任务尝试运行ant时,我收到异常:

Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/myuser/DEV/path/to/specific/ant/installation/apache-ant/bin/ant'' finished with non-zero exit value 1

执行蚂蚁的代码:

def executeAntTaskCmdL(String target, String property, String projectName) {
ext['target'] = target
       ant.cmd = System.getProperty("user.dir") + "/$projectsFolder" + "/" + projectName + "/path/to/antInstallation/apache-ant" + File.separator + 'bin' + File.separator + 'ant'

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        ant.cmd = ant.cmd + '.bat'
    }

    exec {
        commandLine ant.cmd, target, property
    }

}


我不确定是什么原因导致此异常?提前非常感谢

1 个答案:

答案 0 :(得分:0)

啊,我发现一个错误。 我在命令行中添加了一个构建文件。像这样:


def executeAntTaskCmdL(String target, String property, String projectName) {
ext['buildfile'] = System.getProperty("user.dir") + "/$projectsFolder" + "/" + projectName + "/path/to/buildFile" + File.separator + 'build.xml'
ext['target'] = target
       ant.cmd = System.getProperty("user.dir") + "/$projectsFolder" + "/" + projectName + "/path/to/antInstallation/apache-ant" + File.separator + 'bin' + File.separator + 'ant'

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        ant.cmd = ant.cmd + '.bat'
    }

    exec {
        commandLine ant.cmd, target, '-buildfile', buildfile, property
    }

}

添加了所有内容后,一切都像灵符一样。