views:

262

answers:

3

Is there a Maven Plugin that will automatically generate setters and getters with the corresponding JavaDocs?

I am aware that Eclipse/Netbeans will do this when you tell it to; however, it would be nice for the source to simply contain the skeleton and have Maven or another tool generate the repetitive stuff.

I would want to modify the source code so that a source jar can be compiled and used when debugging.

Thanks, Walter

+1  A: 

You could try Modello, it allows you to specify a model and let the java be generated during the build by the modello-maven-plugin.

Rich Seller
A: 

This is builtin. Press Ctrl-Return and then choose "Setter" "Getter" or "Setter and Getter"

Olivier Gérardin
+3  A: 

This isn't necessarily something that you want maven to do for you. It will make working with the code in the IDE harder, as the IDE won't necessarily know about the generated code.

That said, project lombok aims to do this properly through the use of an @Data annotation. It looks like it works well, but I haven't tried it. Do note that it's only got Eclipse support at present, no IDEA or NetBeans.

Dominic Mitchell
Lombok does offer a de-lombok option to generate java code without any reference to Lombok, to make working with other IDE's and some frameworks easier.
Tim
Lombok supports NetBeansm, and reportedly also JDeveloper. IDEA support is currently still missing.
Roel Spilker