JAXB XJC Possible to suppress comment creation in generated classes?

前端 未结 8 1234
渐次进展
渐次进展 2021-01-01 09:45

Our project uses XJC to generate Java classes from an XSD. I\'m using JAVA EE 6.

When all the XSDs we have are re-generated, the generated classes include this comm

8条回答
  •  星月不相逢
    2021-01-01 10:21

    To build on cata's answer (upvoted) the maven-replacer-plugin is the way to go. I've come up with the following that strips out the entire comment (not just the timestamp) which you can replace with your file comment (license etc.).

    
        com.google.code.maven-replacer-plugin
        maven-replacer-plugin
        
          
            prepare-package
              
                replace
                                 
            
          
          
            
            
              src/main/java/**/*.java
            
            true
            
              MULTILINE
            
            
              
                (^//.*\u000a|^\u000a)*^package
                // your new comment
    package
                       
            
          
       
    

    The one gotcha to watch out for is that the element treats the text literally. So if you want a line break in your replacement text you need to put a line break in your pom.xml file (as I've demonstrated above).

提交回复
热议问题