Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JET FAQ How to I compile JET templates in a headless build"

(New page: JET includes an ANT task for compiling JET templates. It is intended for use with PDE-build, but see below for an important #Caveat Let's start with the ANT task. Here's an example: ...)
 
m (Caveat)
 
Line 76: Line 76:
 
Now here's the important Caveat. The jet.compile ANT task has an important  
 
Now here's the important Caveat. The jet.compile ANT task has an important  
 
design flaw - it assumes that PDE build is compiling plug-ins that are  
 
design flaw - it assumes that PDE build is compiling plug-ins that are  
located in a workspace. In the real world, a typical PDE build script checks out project source into a directory that is not part of a workspace. See [https://bugs.eclipse.org/bugs/show_bug.cgi?id=210447 bug 210447] for the details are available on this bug.
+
located in a workspace. In the real world, a typical PDE build script checks out project source into a directory that is not part of a workspace. See [https://bugs.eclipse.org/bugs/show_bug.cgi?id=210447 bug 210447] for the details.
  
 
The bottom line is that if you want this to work, you have to:
 
The bottom line is that if you want this to work, you have to:

Latest revision as of 14:52, 15 September 2008

JET includes an ANT task for compiling JET templates. It is intended for use with PDE-build, but see below for an important #Caveat

Let's start with the ANT task. Here's an example:

<jet.compile project="my.jet.project" destdir="jet2java" >
    <srcdir dir="." includes="templates/**/*.jet"/>
</jet.compile>

The task requires the Eclipse ANT runner (you typically are using this for PDE build). The Eclipse instance being used for the build must have JET and EMF installed (JET requires EMF). The best way to get PDE build to invoke the ant task is to use a 'custom Build Callbacks' file. Do the following:

Modify build.properties to include the following line:

customBuildCallbacks=customBuildCallbacks.xml

This tells PDE build to use customBuildCallbacks.xml (an ANT build file) for call packs. The path to the file is relative to the project.

The org.eclipse.pde.build includes template for customBuildCallbacks.xml located in the the templates/plugins directory.

There are lots of stub tasks in the template. If you're doing the 'normal' JET project, where PDE is building a JAR'd plugin, then you want to add the following to the template:

<!-- Steps to do before the compilation target                        -->
<!-- Available parameters                                             -->
<!--   source.foldern : n = 1 ... N, the source                       -->
<!--   target.folder  : where the results of the compilation          -->
<!--   @dot.classpath : name = name of the compilation target.        -->
<!--                      reference to the classpath                  -->
<!-- ================================================================ -->
<target name="pre.@dot">
  <jet.compile project="your project name" destdir="jet2java" >
    <srcdir dir="." includes="templates/**/*.jet"/>
  </jet.compile>
</target>
 
<!--  =============================================================== -->
<!-- Steps to do during the compilation target @dot, after the compile-->
<!-- but before                                                       -->
<!-- Available parameters                                             -->
<!--   source.foldern : n = 1 ... N, the source                       -->
<!--   target.folder  : where the results of the compilation          -->
<!--   @dot.classpath : name = name of the compilation target.        -->
<!--                      reference to the classpath                  -->
<!--  =============================================================== -->
<target name="post.compile.@dot">
</target>
 
<!--  =============================================================== -->
<!-- Steps to do after the compilation target                         -->
<!-- Available parameters                                             -->
<!--   jar.location - the location of the compilation                 -->
<!--   @dot.classpath : name = name of the compilation target.        -->
<!--                      reference to the classpath                  -->
<!--  =============================================================== -->
<target name="post.@dot">
</target>

You can test all of this from the workspace by changing using something other than jet2java for destdir, and then using the Export deployable plug-in wizard. After the build, you should see the generated Java classes in the destdir folder.

Caveat

Now here's the important Caveat. The jet.compile ANT task has an important design flaw - it assumes that PDE build is compiling plug-ins that are located in a workspace. In the real world, a typical PDE build script checks out project source into a directory that is not part of a workspace. See bug 210447 for the details.

The bottom line is that if you want this to work, you have to:

  1. make sure that your build somehow gets the JET projects into the workspace being used by the PDE ANT runner.
  2. make sure that any custom JET tags used by the JET projects are also projects in that workspace.

I would certainly welcome ideas/help on getting this to work. There are two possible routes:

  1. Fix it the right way, which means me making some changes to how the JET compiler, the jet.compile ant task and perhaps the projects 'manifest' information. This, unfortunately will take some time - I'm hoping to get something done for Galileo (i.e. June 2009).
  2. Figure out some hacks. I haven't delved deeply in to the mysteries of PDE build, but it seems to me that, after PDE build has checked out the projects to be built, some custom code could be added to import them into the workspace being used by PDE build. Conceptually, this is easy. Practically, I don't know how to do it.

Back to the top