Two projects: the product (project-A) and the auto benchmark project for A (project-B).
In B's build file, we need to call A's build file to run the build and bundle-with-app-server process like this:
<ant antfile="${build-file-A}" inheritall="false" target="all" />
And, in project B, we have a lot of Ant tasks that output messages using java.util.logging (The JDK Logging Framework).
The problem is, after that line, all the jdk logger outputs disappear.
With debugging, I find that, during the initialzation of project A's build file, a staticly defined thing in project A will run LogManager.readConfiguration(InputStream)
, which loads a config file that only contains the logger configuration of a single class.
And during readConfiguration
, LogManager.reset()
will be called; during reset
, each handler of each logger will be removed. As <ant>
will load the target build file to the same process of the caller, all the handlers will be removed.
So, except the configurated one, every other class that use jdk logger can't output messages due to lack of output handler.
My question is:
Is there any way to solve this problem, other than:
- use
<exec>
to run project A's build file; - write a task to run
readConfiguration()
to restore the default JDK logging settings from the default configuration file after the<ant>
call. - Use ant's own logging framework (Task.log(), etc).
Please note that I can't modify project A to prevent the problem.
readConfiguration(InputStream)
, which formats and outputs the logging message. – Offprint<ant>
task loads the build file into the same JVM, as another project. And,readConfiguration
affects all the existing JDK loggers inside that JVM. The best way I can think of is to run the other build file in a seperate JVM, but<exec>
task may cause problem when there are multiple installs of JDK and Ant in the OS. – Offprint