Fail Build On Metric "ANT Javac Warnings"

Answered

Building my project with ANT takes about 5 mins.

However, running the default inspections has taken 30 minutes so far and it isn't even at 10 % :o

The only reason I am running the inspections is so that I can fail the build if the number of warnings increases.

I compile the code like this:

<javac memoryMaximumSize="2G" fork="true" debug="true" destdir="${build.classes.dir}" srcdir="${src.dir}" includeantruntime="false">
<classpath refid="build.classpath"/>
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xmaxwarns"/>
<compilerarg value="50000"/>
</javac>

ANT outputs a list of warning and a summary like this:

1595 warnings

How can I use that as a metric and fail the build if the number of warnings increases?

 

3 comments
Comment actions Permalink

Hello,

You can report custom metric using service messages, see the related section in TeamCity online documentation. Also you can add this custom metric as failure condition.

0
Comment actions Permalink

I have already read the documentation and can't work out how to do it.

Can you be more explicit please.

0
Comment actions Permalink

You can report the custom metric from your Ant script using service message. They should be printed into a standard output stream of the build, e.g.:

##teamcity[buildStatisticValue key='AntJavacWarnings' value='<value>']

If everything is configured correctly, you'll be able to see the reported metric on build's Parameters > Reported statistics values page.

Then you can add this metric to main-config.xml file as described here and use this metric as build failure condition.

 

0

Please sign in to leave a comment.