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

4 Answers4

5

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 unless it has a plugin that understands Lombok's notation. IntelliJ has such a plugin available.

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. It supports a number of environments and IDEs through plugins, including Maven, Eclipse, IntelliJ and Netbeans. There are a few caveats with Netbeans currently, see the project documentation.

Community
  • 1
  • 1
Dominic Mitchell
  • 11,861
  • 4
  • 29
  • 30
  • 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 Jan 25 '10 at 15:02
  • Lombok supports NetBeansm, and reportedly also JDeveloper. IDEA support is currently still missing. – Roel Spilker Feb 20 '10 at 15:32
  • The [lombok-maven-plugin](http://awhitford.github.com/lombok.maven/lombok-maven-plugin/) may be of interest. As long as the IDE supports Maven, you should be good with it. – AWhitford Sep 15 '11 at 07:43
  • I am using photon eclipse jee and org.projectlombok is present in the pom.xml with a version of 1.6.6, still the getter and setter methods give a problem....How do I get over this? – Eswar Aug 30 '18 at 06:33
1

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
  • 83,208
  • 23
  • 172
  • 177
1

I know you asked for a Maven plugin but there is annotation based project that takes care of many boilerplate code issues in Java:

http://projectlombok.org

Jarosław Jaryszew
  • 1,414
  • 1
  • 12
  • 13
0

There is a use case that doesn't work with Eclipse and the mouse. Sometimes you need accessors in generated Java files, say, from an IDL specification. One example would be if the classes are further processed by an ORM framework.

Now, how can this easily be done with Maven? Of course, it's possible to script it or use the replacer plugin; but is there any off-the-shelf solution?

fubra
  • 79
  • 1
  • 3