views:

301

answers:

3

Hello!

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?
I didn't find a lot by searching the web.

A: 

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

Slink84
Thank you, I was thinking about JSP myself. But I think JSP would be not such a good replacement for JET. Generated code must be processed and compiled during the build process. I think a webserver (even Jetty) would be too slow for each and every clean+build. The question here would be: Is there a standalone JSP processor? ;)
ivan_ivanovich_ivanoff
Umm, I don't think that I understand what you want to do then :] Web pages have to be generated only once - their content is static? Or what? Maybe you could use caching? http://docs.sun.com/app/docs/doc/820-7695/6niugesng?a=view Can you describe your problem and requirements more thoroughly?
Slink84
Sounds like he's writing a builder for use in NetBeans, generating some code as part of a build process. (JET is usually used for code generation in eclipse (but has some other eclipse dependencies).)
Scott Stanchfield
A: 

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

A couple you might want to look at:

Scott Stanchfield
A: 

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.

ivan_ivanovich_ivanoff