How to tell wsdl2java not insert current timestamp into generated files?
Asked Answered
E

2

9

I use wsdl2java to generate DTO Java classes. It adds current timestamp into the comments section of every file generated.

How to disable those timestamps?

Because I'd like to minify changes between two wsdl2java launches (the generated java sources are under RCS).

P.S. Java 7; wsdl2java comes from org.apache.cxf:cxf-codegen-plugin:2.6.16 although version 3 is also considered.

Eulogia answered 3/3, 2016 at 8:58 Comment(2)
A small hint that could help you : wsdl2java is using a velocity template svn.apache.org/repos/asf/cxf/trunk/tools/wsdlto/frontend/jaxws/…Aeroneurosis
Even though it does not answer your question: Why do you version your generated files? Why isn't it enough to version the source WSDL file? That combined with a build configuration file would probably solve your issue, too.Feltie
U
3

Use option -suppress-generated-date of underlying Apache CXF in wsdl2java configuration.

Fragment of a build.gradle file as an example:

wsdl2java {
      ...
      wsdlsToGenerate = [
              [
                      ...
                      "-suppress-generated-date",
                      ...
              ]
      ]
      ...
}

This option will change these comments in generated classes

/**
 * This class was generated by Apache CXF 3.2.7
 * 2018-11-23T10:12:12.986+02:00
 * Generated source version: 3.2.7
 *
 */

to these:

/**
 * This class was generated by Apache CXF 3.2.7
 * Generated source version: 3.2.7
 *
 */

More details: http://cxf.apache.org/docs/wsdl-to-java.html

Use answered 26/11, 2018 at 15:23 Comment(2)
Why passing "-xjc"? That's not stated in the documentation as requirement for passing "-suppress-generated-date".Diarmuid
@whaefelinger that was a piece from existing configuration and is not related to timestamp generation.Use
S
0

however, other with CXF 3.5.2 dates as @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2022-09-24T16:22:10.990+02:00") @Generated(value = "com.sun.tools.xjc.Driver", comments = "JAXB RI v2.3.5", date = "2022-09-24T16:22:10+02:00") still remain in code. yes, the file heading comments are away but intention was not to have code cluttered with unwanted changes. the changes are tracked by git normally. generated dates in code may help with very very old code, but generally they are not desirable. it would be even better to have one comment with date in Service than 20 very same comments spread around in code. no one follows 20 dates spread around generated code. if no one reads that information, that information has no value and should be avoided. The changes in WS contract are commonly followed in WSDL file, there is no need to have dates generated in code. it might be partially useful, if the generated dates would track real changes, that means, it would ONLY update the date where the contents really changed. it is a bad idea to clutter all places with very same date.

Selection answered 24/9, 2022 at 14:25 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Barbarbarbara

© 2022 - 2024 — McMap. All rights reserved.