ivan_ivanovich_ivanoff
ivan_ivanovich_ivanoff

Reputation: 19463

Is there something like JET (Java Emitter Templates) but without Eclipse-dependencies?

I wanted to use JET (Java Emitter Templates) in my Netbeans projects, but had to find out that JET heavily depends on Eclipse libraries.

Is there something similar to JET, but as a standalone project?
Something which is open source and well maintained?

Futhermore, is "code generation" the common term for such tools?

Upvotes: 2

Views: 3086

Answers (5)

lgu
lgu

Reputation: 2460

Indeed JET is very tied with Eclipse.

If you want to generate code without Eclipse you should use another solution.

You can choose another template engine like Velocity (https://velocity.apache.org/) or FreeMarker (https://freemarker.apache.org/).

Or you can choose a code generator working by itself independently of any IDE.

For example "Telosys Command Line Interface" : http://www.telosys.org/

Upvotes: 1

Daniel Sperry
Daniel Sperry

Reputation: 4491

If you are using Maven, you can use JET templates with the maven-jet-plugin.

This seems to be the source code. And here the documentation.

It is not actively maintained but works pretty well and follows the JET spec. I've used it with templates and skeletons.

It's self contained, doesn't depend on Eclipse, and doesn't introduce any transitive dependencies to your project.

Upvotes: 1

ivan_ivanovich_ivanoff
ivan_ivanovich_ivanoff

Reputation: 19463

I ended up using ERB (Ruby's template engine).

Works great in Netbeans!

I define custom ant task which generates source files by calling ERB (whose results are placed inside a non-versioned special directory).

The ant task is overriding Netbeans' "-pre-compile" task.

Upvotes: 0

Scott Stanchfield
Scott Stanchfield

Reputation: 30652

Look for "template engine" for these types of tools.

A couple you might want to look at:

Upvotes: 0

Kirill Strizhak
Kirill Strizhak

Reputation: 2687

From what I know, JET is something like JSP, no?

Java Emitter Templates are very similar to Java Server Pages (JSPs). Both JETs and JSPs use the same syntax, and are compiled to Java behind the scenes. Both are used to separate the responsibility for rendering pages from the model and controller. Both accept objects passed into them as an input argument, both allow inserting string values within code ("expressions"), and allow direct use of Java code to perform loops, declare variable, or perform logical flows ("scriptlets"). Both are good ways of representing the structure of a generated object (web page, Java class, or file) while supporting customization of the details. JETs differ from JSPs in a few key ways. In a JET, the structure of the markup may be changed to support generating code in different languages. Typically the input to a JET will be a configuration file and not user input (though there is nothing forbidding this). And also typically, JET processing will take place only once for a given workflow. These are not technical limitations, and you may find uses for JETs which are quite different...
ibm.com

Here are a few links to get you started on JSP, if that sounds like what you need:
sun.com
netbeans.org

Upvotes: 0

Related Questions