Search code examples
javaxsdjaxbxjc

I want to add a single line comment in each JAXB generated file that have been generated using the org.codehaus.mojo jaxb2-maven-plugin plugin


I'm generating JAXB classes from an XSD using XJC org.codehaus.mojo jaxb2-maven-plugin 2.2

I want to add a single line comment at the top of each generated file, what is the easiest way to achieve this ?


Solution

  • com.google.code.maven-replacer-plugin replacer 1.5.2 prepare-package replace

                    <basedir>${project.build.sourceDirectory}/com/deltarail/nexus/cis/map/jaxb/generated</basedir>
    
                    <includes>                       
                        <include>*.java</include>                            
                    </includes>      
    
                    <replacements>
                        <replacement>
                            <token>// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11</token>
                            <value>// CSOFF: a.*</value>                          
                        </replacement>
    
    
                    <replacement>
                            <token>public class</token>
                            <value>@SuppressWarnings("PMD")
    public class</value>                          
                        </replacement>
    
    
                    </replacements>
                    <regex>false</regex>
                </configuration>
            </plugin>