Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent XJC to generate javadoc header comments?

Tags:

xjc

I use XJC to generate some Java classes, but the generated Java code contains ugly Javadoc headers.

Example:

/**
 * <p> Java class for XXX complex type.
   ....
 */

How do I tell XJC to not generate this?

I tried -no-header option, but it doesn't work.

like image 442
user2404936 Avatar asked May 21 '13 09:05

user2404936


2 Answers

That's not a header, that's a Javadoc comment on the class itself.

-no-header removes the following style from the very top of the file

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.03.06 at 06:14:40 PM GMT 
//

To remove the comments you have to post-process the file. This question details how that can be achieved: JAXB XJC Possible to suppress comment creation in generated classes?

like image 122
tom Avatar answered Oct 16 '22 17:10

tom


Please see my detailed answer how to change prolog text (file header comment) in this answer: JAXB XJC Possible to suppress comment creation in generated classes?

In that particular case in short you may just:

  1. Create file src/main/resources/com/sun/tools/xjc/reader/xmlschema/MessageBundle_en.properties
  2. And place in it override:
# {0} - name-identifier-format-enum
ClassSelector.JavadocHeading = \
    <p>Java class for {0}.

...to customize message in Javadoc.

like image 40
Hubbitus Avatar answered Oct 16 '22 17:10

Hubbitus