0

I'm trying to create POJOs using jsonSchema.
I've found a project called jsonschema2pojo which seems suitable except for a couple of issues.
I'm willing to fork the project and add some customizations (such as custom annotations and perhaps methods).
The project uses com.sun.codemodel to build the classes.
Since the generated code will go into production, I need to add a copyright statement in the beginning of the file.
I haven't found any solution for it in both jsonschema2pojo or codemodel. Do you guys have any solution?

Slava
  • 160
  • 2
  • 11
  • Do you want the comment on the very first line of the file or a javadoc for the class? – John Ericksen Dec 06 '16 at 20:21
  • The very first line. Like in this [example](https://docs.oracle.com/javase/tutorial/getStarted/application/examples/HelloWorldApp.java), I want a comment for the copyrights, outside the class javadoc – Slava Dec 07 '16 at 09:40
  • 1
    If you're generating your POJOs using the jsonschema2pojo Maven plugin, you can add [license-maven-plugin](http://code.mycila.com/license-maven-plugin/) to the same project. – approxiblue Dec 17 '16 at 04:39
  • thank you, it would actually help with this specific case. however, i was looking for a more general solution. – Slava Dec 18 '16 at 15:06

1 Answers1

1

Potentially the easiest way to implement this would be to just print the license header every source file (assuming everything written out is Java of course). This can be accomplished by writing the header to the writer here before anything else is written out by JCodeModel. This would require a fork of the library to replace your custom implementation of FileCodeWriterWithEncoding here.

John Ericksen
  • 10,995
  • 4
  • 45
  • 75