简体   繁体   中英

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

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).

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM