tags:

views:

45

answers:

1

I have an ant task that contains javac task inside. It reports about error in one of the classes, but the build doesn't fail, because it has failonerror="false". I suppose to see class files in the end of build, but I don't see it. Can anybody tell me why?

Properties used:

checkout.path=work/workingcopy
classpath.path=work/build/classes
log.file=work/log.txt

Ant code:

<record name="${log.file}" action="start"/>     
<javac destdir="${classpath.path}" srcdir="${checkout.path}/src"
        debug="true" failonerror="false">
    <classpath>
        <path refid="webinf.lib"/>
        <path refid="tomcat.lib"/>
    </classpath>
</javac>
<record name="${log.file}" action="stop"/>

Log file:

[javac] Compiling 169 source files to C:\work\build\classes
[javac] C:\work\workingcopy\src\com\mycompany\exception\handlerException\CustomExceptionHandler.java:25: cannot find symbol
[javac] symbol  : class RequestContextImpl
[javac] location: package org.primefaces.context
[javac] import org.primefaces.context.RequestContextImpl;
[javac]                              ^
[javac] C:\work\workingcopy\src\com\mycompany\exception\handlerException\CustomExceptionHandler.java:103: cannot find symbol
[javac] symbol  : class RequestContextImpl
[javac] location: class com.mycompany.exception.handlerException.CustomExceptionHandler
[javac]             new RequestContextImpl(ec);
[javac]                 ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
[javac] Compile failed; see the compiler error output for details.
+2  A: 

The failonerror option is for Ant not for javac. So if failonerror=false then Ant will continue your task even javac returns an error.

From the docs:

failonerror Indicates whether compilation errors will fail the build; defaults to true.

The build is Ant's build process not javac's !

PeterMmm
Thank you, but I still don't know how to cause the compiler, to compile java files. The log shows that there are 169 source files and there are errors only in one. Why there are no class files for other 168?
Igor Grinfeld
javac won´t create any .class file while there are errors. It makes no sense to have partial compiled classes, your program won`t run !
PeterMmm
Anyway, seems org.primefaces.context.RequestContextImpl is not on your classpath.
PeterMmm
You are right, but it is OK. My task is to create script that makes daily builds. If there are errors, it should check in list of critical files. If this class is critical it fails, else uses old version of the class. I thought that javac compiles sources without errors, even if there are an error in other sources, but you tell me that it is wrong. Is any option to override this behaivour exists?
Igor Grinfeld
AFAIK there is no option in Sun's javac. There are other Java compiler (jikes,etc) that maybe allow this (i doubt). Anyway you can take the error output of compilation to identify sources with errors and handle them in any specific manner.
PeterMmm
You manage daily builds and wants to use old classes when new ones fails. Sounds a little bit scary to me ...
PeterMmm
It sounded strange to me too, when I've first hear about it. The explanation was, that we have a huge project, so QA section should be able to test part A, even if B still doesn't work. BTW, I still think that there is some way to compile only files without errors, because Eclipse does it.
Igor Grinfeld