代码为3的ant exec任务错误 [英] ant exec task error with code=3

查看:66
本文介绍了代码为3的ant exec任务错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从ant目标调用bash脚本.这是我的目标:

Im trying to invoke a bash scrip from an ant target. This is my target :

<target name="report" depends="test">
    <!-- Step 3: Create coverage report -->
    <exec executable="./checkStyle.sh"
            failonerror="true"
            osfamily="unix"/>
    <jacoco:report>

        <!-- This task needs the collected execution data and ... -->
        <executiondata>
            <file file="${result.exec.file}" />
        </executiondata>

        <!-- the class files and optional source files ... -->
        <structure name="JaCoCo Ant Example">
            <classfiles>
                <fileset dir="${result.classes.dir}" />
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="${src.dir}" />
            </sourcefiles>
        </structure>

        <!-- to produce reports in different formats. -->
        <html destdir="${result.report.dir}" />
        <csv destfile="${result.report.dir}/report.csv" />
        <xml destfile="${result.report.dir}/report.xml" />
    </jacoco:report>
</target>

我的bash脚本是:

#!/bin/bash
DEST_FOLDER='./target/checkstyle'
CLASSES_FILE='classes.txt'
REPORT_FILE='report.xml'
mkdir -p "$DEST_FOLDER"

rm -f "$DEST_FOLDER/$CLASSES_FILE"
rm -f "$DEST_FOLDER/$REPORT_FILE"

find ./project -name "*.java" >> "$DEST_FOLDER/$CLASSES_FILE"
while read p; do 
    java -jar ./utilJars/checkstyle-6.5-all.jar -c ./sun_checks.xml -f xml $p >> "$DEST_FOLDER/$REPORT_FILE"
done < $DEST_FOLDER/$CLASSES_FILE

键入./checkStyle时,一切正常,但是当我尝试蚂蚁报告"时,会出现以下错误:

When typing ./checkStyle everything works fine, but when I try "ant report" the following error is raised:

BUILD FAILED
/home/luci/workspace/operations/build.xml:60: exec returned: 3

Total time: 4 seconds

我已经在Google上搜索了,该代码似乎被拒绝拒绝",但我不知道该如何解决这个问题.

I`ve searched on google and that code seems to be "permision denied", but i dont know how i could solve this problem.

推荐答案

通常对于Ant(和Java),您不能直接执行shell脚本.您需要执行解释器/shell并将脚本作为参数.

Generally with Ant (and Java), you cannot directly execute shell scripts. You need to execute the interpreter/shell and give the script as an argument.

例如:

    <exec executable="/bin/bash" failonerror="true" osfamily="unix">
        <arg value="-c"/>
        <arg value="./checkStyle.sh"/>
    </exec>

这篇关于代码为3的ant exec任务错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆