javac error "error: warnings found and -Werror specified" disable "-Werror" in ant

4.8k Views Asked by At

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

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

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

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.

but any insight about it is appreciated.

1

There are 1 best solutions below

10
On

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

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

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.)

UPDATE:

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>

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.