eclipsemaveneclipse-m2t-jet

Run JET Templates without Eclipse


I need to generate java code from jet templates using a maven project and it should be done outside eclipse environment, but so far i haven't figure out how to do this.

I'm using maven 3x and jet 1.1.x.

I've tried several approaches but none of them seems to work:

Does anyone have an idea how to do this?

Thanks a lot, Carlos


Solution

  • Because of the way JET works, it'll only actually be runnable inside an eclipse environment. However, it's actually possible to launch eclipse headlessly to run an ant build script, so you get the eclipse parts you need running, without the UI. In order to do this, you need to launch the org.eclipse.ant.core.antRunner application. There's some documentation on how to do that here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2FantRunner.htm

    Once you've launched the antRunner application, you can use the JET ant tasks to compile your templates and run your transform: http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jet.doc%2Freferences%2Fant%2FantTasks.xhtml

    There are some important caveats about headless template compilation which are relevant if you're headlessly compiling eclipse plugins, documented here: http://wiki.eclipse.org/JET_FAQ_How_to_I_compile_JET_templates_in_a_headless_build

    I'm not sure how well any of this integrated with Maven, but this seems to be the best approach from ant. If you're wanting to run a transform from Java, there's some information here: http://wiki.eclipse.org/JET_FAQ_How_do_I_run_a_JET_transformation_from_Java%3F. You will still need to be in an eclipse environment for it to work though.