本文介绍了javac的错误"错误:找到警告和-Werror指定"禁用" -Werror"蚂蚁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个Android项目,当它决定把警告作为错误运行的javac 程序时,我的Ant构建脚本有时会失败。严重的是,它不仅会有时,这是一个不同的问题,我可能会问。

this is an android project and my ant build script sometimes fails when it decides to treat warnings as errors when running the javac program. Seriously, it only does this sometimes, which is a different question I may ask.

这将打印错误和突然取消生成

It will print errors and abruptly cancel the build

[javac] 1 error

[javac] 9 warnings

像我一样更深我看到了错误,是

as I did deeper I see the "error" is

error: warnings found and -Werror specified

这是没有什么我明确设置。现在,这可能是在build.xml文件中深埋的参数,或者在一个特定的条件这个特殊子库的build.xml文件我目前不知道

which is not anything I explicitly set. Now this may be an argument buried deep in the build.xml file, or maybe in this particular sub library's build.xml file in one particular condition I don't currently know about

这是导致此,有时在Android的Facebook SDK。但是有蚂蚁的build.xml文件中没有Werror的说法,但我想禁用它或者解决它

It is the android facebook sdk that causes this, sometimes. But there is no Werror argument within the ant build.xml files but I want to disable it or work around it

这是一个构建服务器,在那里我有其他状况,停止建设。蚂蚁不一致和javac的问题真的没有一个地方。

This is for a build server, where I have other conditions to stop a build. Inconsistent ant and javac issues don't really have a place.

但关于它的任何见解是AP preciated。

but any insight about it is appreciated.

推荐答案

文件工具/ ANT / build.xml文件包含以下内容:

The file "tools/ant/build.xml" under my Android SDK directory contains the following:

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

也许使用失败构建由于警告Android SDK中的错误一样被对待包括-Werror的编译器ARGS? (如果没有,递归的grep在违规Android SDK中的实例能找到的罪魁祸首目录compilerargs)。

Perhaps the Android SDK used by the build that fails due to warnings being treated like errors includes "-Werror" in the compiler args? (If not, a recursive grep for "compilerargs" in the directory of the offending Android SDK instance could find the culprit.)

更新:

在另一方面,这是在我的Andr​​oid SDK,物业本身不是强制性的 - 它只是碰巧在这里使用的:

On the other hand, that's in my Android SDK, the property is not in itself mandatory -- it just happens to be used here:

<!-- 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的将是更好的选择。元素

The element that has to be there is the "compilerarg" one on the next-to-last line, so a grep for "compilerarg" instead of "compilerargs" would be the better choice.

这篇关于javac的错误&QUOT;错误:找到警告和-Werror指定&QUOT;禁用&QUOT; -Werror&QUOT;蚂蚁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:08