开发者

Why javac task does not creates classes

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 inp开发者_如何学Gout 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.


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 !


Use Eclipse Java Compiler (EJC) instead of standard Oracle javac. One of ECJ advantages over javac is that it is permissible of errors, it tries to compile as much as possible and keeps already generated class files. With javac it is everything or nothing.

EJC was developed for use in IDE, for highly interactive work where partial compilation is a must, but it can also be used as CLI or Maven plugin. Plexus guys provide EJC as a handy Maven dependency.

For example configuration of ECJ in Maven, a partial compilation, check my answer to this question: Maven: partial compilation before code generation


I've had same problem. And that is soluion I've found on the Web

This depends on the compiler that you are actually using. If you're using javac 1.3, this is what Sun does by design. (see http://java.sun.com/j2se/1.3/docs/tooldocs/tools-changes.html for more information, specifically the last paragraph of the first bullet.) Try using an older compiler or using the jikes compiler from IBM. Both javac 1.2.2 and jikes 1.13 will produce output for classes that do compile, even if another file in the fileset doesn't. Jay

Best regards, Michael

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜