javac错误“错误:发现警告并且-Werror指定”在ant中禁用“-Werror”

时间:2013-09-06 15:46:01

标签: android ant adb javac build-server

这是一个android项目,当我决定在运行javac程序时将警告视为错误时,我的ant构建脚本有时会失败。说真的,它有时只会这样做,这是我可能会问的另一个问题。

它将打印错误并突然取消构建

[javac] 1 error

[javac] 9 warnings

当我做得更深时,我看到“错误”是

error: warnings found and -Werror specified

这不是我明确设定的任何内容。现在这可能是深埋在bu​​ild.xml文件中的一个参数,或者可能是在这个特定子库的build.xml文件中,我目前不知道的一个特定条件

有时,这是android facebook sdk引起​​的。但是ant build.xml文件中没有Werror参数,但我想禁用它或解决它

这是一个构建服务器,我有其他条件来停止构建。不一致的蚂蚁和javac问题实际上并不存在。

但是对此有任何见解表示赞赏。

1 个答案:

答案 0 :(得分:2)

我的Android SDK目录下的“tools / ant / build.xml”文件包含以下内容:

<property name="java.compilerargs" value="" />

由于警告被视为错误而导致构建失败的Android SDK可能包含编译器args中的“-Werror”? (如果没有,在违规的Android SDK实例目录中的“compilerargs”的递归grep可能会找到罪魁祸首。)

更新:

另一方面,那是在我的Android SDK中,该属性本身并不是强制性的 - 它恰好在这里使用:

<!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
    <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
        <!-- merge the project's own classpath and the tested project's classpath -->
        <path id="project.javac.classpath">
            <path refid="project.all.jars.path" />
            <path refid="tested.project.classpath" />
            <path path="${java.compiler.classpath}" />
        </path>
        <javac encoding="${java.encoding}"
                source="${java.source}" target="${java.target}"
                debug="true" extdirs="" includeantruntime="false"
                destdir="${out.classes.absolute.dir}"
                bootclasspathref="project.target.class.path"
                verbose="${verbose}"
                classpathref="project.javac.classpath"
                fork="${need.javac.fork}">
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <compilerarg line="${java.compilerargs}" />
        </javac>

必须存在的元素是倒数第二行的“compilerarg”元素,因此对于“compilerarg”而不是“compilerargs”的grep将是更好的选择。