21

I'm aware of the built in code generation and refactoring one can do with the "Source" and "Refactor" menu items in Eclipse.

I also use the Commonclipse plugin to easily make use of the Apache Commons classes that build hashCode, toString, equals methods.

What other plugins or tools should I be aware of for generating Java source easily under the Eclipse IDE?

Chinnery
  • 10,179
  • 2
  • 23
  • 25

12 Answers12

12

Telosys ( https://www.telosys.org/ ) is a simple and efficient tool for Java code generation.

This code generator is available as an Eclipse Plugin (https://marketplace.eclipse.org/content/telosys-tools) and also as a Command Line Interface (https://doc.telosys.org/telosys-cli).

The model defining all the entities can be created from scratch or from an existing database.

The templates are based on Velocity (https://velocity.apache.org/) and can be downloaded from GitHub. All the templates are customizable and new templates can be created from scratch if necessary. Existing templates can generate code forJPA, Spring MVC, Database documentation, REST API, etc.

rlopez
  • 655
  • 7
  • 15
  • 2
    Indeed, Telosys is probably the most effcient Eclipse plugin for Java code generation. – lgu Jun 26 '18 at 16:55
  • 1
    The main advantage for Telosys is that it's entirely customizable, so you can adapt the templates to generate what you want. Here's a good presentation of Telosys to understand how it works https://modeling-languages.com/telosys-tools-the-concept-of-lightweight-model-for-code-generation/ – JackPat99 Aug 13 '20 at 08:31
4

Eclipse Xtend is a very powerful code generator that, among other things, supports closures and data classes - automatic getters/setters/hashCode/equals.

Andrejs
  • 26,885
  • 12
  • 107
  • 96
4

You can look at http://fast-code.sourceforge.net/ for spring based applications. You can create FooService and FooServiceImpl and the configurations just by typing foo. It has nice way to create unit tests as well. One can see all the templates here : http://fast-code.sourceforge.net/templates-config.xml

fastcodejava
  • 39,895
  • 28
  • 133
  • 186
4

Project Lombok enables you to effectively code in shorthand. For example, you can declare a class, add a lombok annotation, and it will automatically generate getters, setters, equals, hashCode, toString, and constructors.

AWhitford
  • 3,708
  • 3
  • 28
  • 38
2

If your are interested in going a bit further with code generation and getting into model driven software development you should have a look at openArchitectureWare.

If you work through the Getting Started tutorial you should get up to speed pretty quickly.

Brian Matthews
  • 8,506
  • 7
  • 46
  • 68
2

Here are three java code generators that you may find interesting :

  • picocog : A tiny code generation library (< 8 KB) written in Java, useful for any purpose, but ideal for JSR-269. There are tutorials available at dev.to and dzone.com.

  • The JmrTeam generator : Jet Model Robotization available for Eclipse (coming soon for IDEA), useful for managing and generating code in any kind of project(Maven, Gradle, Java, Python, Php etc.), any kind of framework(springboot/spring/springMVC, React/ Vue/Angular, hibernate, mybatis, struts, JPA etc.).

  • javapoet : A Java API for generating .java source files.

  • jhipster :An open Source application platform for creating Spring Boot + Angular/React/Vue projects. The generator source code is available here

iceberg53
  • 330
  • 1
  • 7
1

It really depends on what you want to do? J2EE, web services, Swing ...

I do a lot of web service development and rely heavily on:

For Axis2 development:

There's a good tutorial on Axis2 plugins called Developing Web Services Using Apache Axis2 Eclipse Plugins - Part 1

rbrayb
  • 46,440
  • 34
  • 114
  • 174
1

I don't think that this is really what you're asking about, but for model driven development, I think Borland's Together is still the best eclipse based tool out there.

serg10
  • 31,923
  • 16
  • 73
  • 94
1

I just released my personal Java code generator: JCG. You can find it at

https://github.com/makkax/JavaCodeGenerator

It's a generator written in Java where you directly code all Java types, fields, methods & annotations without the need of templates.

With JCG you can easily generate any number of Java types with complex interdependencies.

Makkax
  • 71
  • 1
  • 3
0

I don't know if you're a big UML fan but IBM Rational suite is extremly powerful.

I used it to move from UML to generated mock objects but that's only a slight part of what it can do

Eric
  • 19,525
  • 19
  • 84
  • 147
0

If you want to generate code independent of technology, Zontroy is a good choice. So you don't need to think about whether your project is a JavaEE project or not. You can generate any file in any technology from your database.

Fastcoder
  • 11
  • 1
0

jsoncafe.com online code generator for the model class for JAVA, Android Gson, Swift Class, Swift Codable, c# etc.

Meghs Dhameliya
  • 2,406
  • 24
  • 29