If I understand things correctly, it doesnt really matter Stephen.

Maven plugins (at least the 2.2.1 API; I will take a look at upgrading the
jaxb2-maven-plugin WRT the required maven version, but for this release we
still support JDK 1.6/Maven 2.2.1) use the Maven Log framework, whereas
XJC/SchemaGen uses System.out/System.err and JUL.
I could - of course - fork the JVM but I would still have to wrap one of
the logging frameworks to the other one.


While the wrapping itself is trivial, I believe that several other tools
like Cobertura, Checkstyle, AspectJ etc. where the Maven plugins basically
only collect the argments, and invoke the main method of the tools, would
likely benefit from a common lifecycle pattern.
(i.e. manipulating ClassPath, Logger Frameworks, and some property
extrapolation from the original JVM).
Is there a common Maven API for Plugins-That-Execute-Other-Tools (argument
builder, ClassLoader manipulator, Logger wrapper, Path calculator, Property
extrapolators, and so on) that I missed?
Also - how does forking the JVM affect overall performance compared to not
forking it?


2015-02-02 17:58 GMT+01:00 Stephen Connolly <stephen.alan.conno...@gmail.com
>:

> Should you really be using the JVM of maven to run these tools?
>
> I would argue no. You should be forking the toolchains specified JVM and
> using that forked JVM to do the work. If you do it that way you can
> completely control what logging those forked JVMs uses and route it to the
> Maven logger of choice
>
> On 2 February 2015 at 15:07, Lennart Jörelid <lennart.jore...@gmail.com>
> wrote:
>
>> Hello all,
>>
>> I'm in the final phase of revamping the Jaxb2-Maven-Plugin, and have
>> encountered a (presumably) common problem. The plugin delegates most of its
>> work to the JDK-distributed tools XJC and SchemaGen. These two tools use
>> JUL for logging; and their respective outputs should be emitted onto the
>> Maven Log for debugging and clarity.
>>
>> Writing a small Handler which delegates the JUL LogRecords to the active
>> Maven Log is trivial - but I wonder if I need to reset the JUL root logger
>> after the tool has been run, or if that is done automagically by Maven.
>>
>> Basically - will the next downstream plugin which needs to wrap a tool
>> using JUL be affected by my fiddlings according to the snippet below?
>>
>> // Redirect the JUL Logging statements to the Maven Log.
>> final Logger rootLogger = Logger.getLogger("");
>> rootLogger.setLevel(Level.FINER);
>> for(Handler current : rootLogger.getHandlers()) {
>>     rootLogger.removeHandler(current);
>> }
>> rootLogger.addHandler(new MavenLogHandler(getLog(), "XJC", 
>> getEncoding(false)));
>>
>> // Fire XJC
>> if (XJC_COMPLETED_OK != Driver.run(xjcArguments, new 
>> XjcLogAdapter(getLog()))) { ... display error message ... }
>>
>> The approach works as expected - the boldfaced logging statements below
>> are harvested from the XJC tool being put to work by the jabx2-maven-plugin:
>>
>> [DEBUG] Created episode directory
>> [/Users/lj/Development/Projects/Codehaus/github_jaxb2_plugin/target/it/xjc-include-xsds-in-artifact/target/generated-sources/jaxb/META-INF]:
>> true
>> [DEBUG] Using explicitly configured encoding [UTF-8]
>>
>>
>>
>>
>>
>> *[DEBUG] [XJC]: feb 02, 2015 3:51:53 EM
>> com.sun.xml.bind.v2.util.XmlFactory createSchemaFactoryFIN: SchemaFactory
>> instance:
>> com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory@5b6813df[DEBUG]
>> [XJC]: feb 02, 2015 3:51:53 EM com.sun.xml.bind.v2.util.XmlFactory
>> allowExternalAccessFIN: Property
>> "http://javax.xml.XMLConstants/property/accessExternalSchema
>> <http://javax.xml.XMLConstants/property/accessExternalSchema>" is supported
>> and has been successfully set by used JAXP implementation.*
>>
>> --
>>
>> --
>> +==============================+
>> | Bästa hälsningar,
>> | [sw. "Best regards"]
>> |
>> | Lennart Jörelid
>> | EAI Architect & Integrator
>> |
>> | jGuru Europe AB
>> | Mölnlycke - Kista
>> |
>> | Email: l...@jguru.se
>> | URL:   www.jguru.se
>> | Phone
>> | (skype):    jgurueurope
>> | (intl):     +46 708 507 603
>> | (domestic): 0708 - 507 603
>> +==============================+
>>
>>
>


-- 

--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: l...@jguru.se
| URL:   www.jguru.se
| Phone
| (skype):    jgurueurope
| (intl):     +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+

Reply via email to