开发者

Fail on warnings when building Android [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

Javac: Treat warnings as errors

I want to update the ANT script of my Android project to fail on warnings, but can't seem to find how I would do 开发者_运维知识库that(I can't find the javac element to update). I assume this is possible?

Just to be clear, I don't want to do this in Eclipse because I would like for our build system to fail whenever someone introduces a new warning.


To see how to do this in ant, see: Javac: Treat warnings as errors. From that link:

<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath">
    <compilerarg value="-Werror"/>
</javac>

Android hides the javac task from you. If you create a new android project using the current SDK, the build.xml file will have a description on how to edit specific targets:

     The rules file is imported from
        <SDK>/tools/ant/
     Depending on the project type it can be either:
     - main_rules.xml
     - lib_rules.xml
     - test_rules.xml

     To customize existing targets, there are two options:
     - Customize only one target:
         - copy/paste the target into this file, *before* the
           <setup> task.
         - customize it to your needs.
     - Customize the whole script.
         - copy/paste the content of the rules files (minus the top node)
           into this file, *after* the <setup> task
         - disable the import of the rules by changing the setup task
           below to <setup import="false" />.
         - customize to your needs.

You need to open the main_rules.xml file (or lib_rules if you are building a library), copy the <target name="compile"> section, and paste it into your build script before the <setup \> tag. Add the compiler arg to fail on errors above and you should be good to go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜