Ant: compile as many classes as possible in case of compilation errors

In case of compilation errors, the ant javac task will not compile all classes that can be compiled. It seems that the javac task (or the compiler itself) just stops as soon as the first error occurs.

The failonerror property failonerror not affect this behavior. I do not set the compile attribute (hence, the Oracle JDK compiler is used).

Is it possible to compile as many classes as possible in case of compilation errors?
(it is advisable not to rely on any particular compiler)

One use case is during development:
Imagine that you are implementing some new features, but you are not done yet, and the compilation of errors remains. At the same time, you need to fix some other error, and so that nothing is broken, you want to run standard test packages that are called by the ant task in the project workspace of your development environment. The ant task tries to compile all the classes / test classes, but the failure is due to compiling errors in the class you are just developing.

It would be very useful to tell ant / javac not to compile compilation errors in order to be able to run as many test cases as possible.

+4
source share
1 answer

This has nothing to do with ant , it javac , which will stop on error and never give you any class file. The failonerror property simply says that the assembly should continue or stop if the compilation sends an error back.

Starting with version 1.3: http://docs.oracle.com/javase/1.3/docs/tooldocs/tools-changes.html

"When the new compiler 1.3 detects an error in the source file during compilation, it continues to analyze the remaining source files and tries to identify any additional errors that they may contain. Code generation is completely suppressed for the rest, however, compilation and no class files will be generated even for compilation units that are error free . "

You might want to use some other compilers like jikes. But really, who would like partially compiled classes to start?

+3
source

Source: https://habr.com/ru/post/1412366/


All Articles