简体   繁体   中英

How to rename a generated class during a maven build?

For a project I'm working on, I send queries to StackExchange and transform the JSON result into POJOs using jsonschema2pojo maven plugin . The problem is quite simple : that plugin always name the wrapper class Data and its contained data Item , when I would like wrapper to be named *Wrapper and the contained class Answer for a call to the answers endpoint (as an example).

Well, anyway, how could I rename the Data class to AnswerWrapper and the Item class to Answer ? I know the folder they're in, the package used to define, and so on. The only missing thing is a tool/plugin/java application to perform that operation. I was directed to JRefactory , but the downloaded JAR doesn't look like it can provide the operation I want (and its lack of doc makes it unusable).

So, is there any more modern/efficient solution ? (or at least some I could integrate in my maven build) ?

Maybe not the easiest solution but one that would fit nicely with your requirements would be to actually add functionality to the maven plugin to support customizing the names of the generated classes. It would of course include building your own version and maybe submitting a patch to get it included in the mainline.

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