Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET headless bulid
JET headless bulid [message #49404] Thu, 11 September 2008 08:26 Go to next message
Eclipse User
Originally posted by: eclipse-news.rizzoweb.com

Is it possible to automate JET builds (headlessly) so that we don't have
to check in JET-generated code? Someone on our team last year claims to
have researched the topic and hit a dead end, but that was a while ago
and he is no longer with our team.
Any advice in this area is much appreciated.

Eric
Re: JET headless bulid [message #49463 is a reply to message #49404] Thu, 11 September 2008 09:22 Go to previous messageGo to next message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
Eric:

JET does include an ANT task for compiling JET templates. I'll give a quick
rundown of how the task is used in PDE build, but I'll conclude with 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 anyhow). 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.

There is a template for this file in the org.eclipse.pde.build plug-in.
Here's the path for Eclipse 3.4.0:

org.eclipse.pde.build_3.4.0.v20080604\templates\plugins\cust omBuildCallbacks.xml

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 goes here---" destdir="----
JETs Java source folder goes here.. e.g. jet2java----" >
<srcdir dir="." includes="templates/**/*.jet"/>
</jet.compile>
</target>

<!--
============================================================ ========= -->
<!-- Steps to do during the compilation target @dot, after the
mpile -->
<!-- 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 - Please read ========
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, this is often not the case. All
the details are available on this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=210447.

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, unfortuntately 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.

Paul
Re: JET headless bulid [message #49494 is a reply to message #49463] Thu, 11 September 2008 09:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse-news.rizzoweb.com

Thanks, Paul. It is good to hear that there is a path forward (even if
it is a bit of a rocky path).
Regarding the "projects in workspace" caveat:
a) I don't really understand the distinction or meaning of "it assumes
that PDE build is compiling plug-ins that are located in a workspace."
Can you explain the limitation with an example in more detail?

b) Have you tried the alternate solution suggested by David Lear in the bug:
> You could always use the EMF JET compile in customBuildCallbacks.xml.
> For example:
>
> <target name="pre.@dot">
> <emf.JETCompiler
> templateFile="./templates/library_entry_point.cjet"
> sourceDirectory="generated"/>
> </target>
>
> This works without the project being in the workspace.


Thanks again for this valuable info. I think it would make a good wiki
page, but am not sure where to insert the page (and I think you deserve
the authorship credit anyway). If you have a chance to put this info on
the wiki, please post the page name so I can bookmark it.

Eric


Paul Elder wrote:
> Eric:
>
> JET does include an ANT task for compiling JET templates. I'll give a quick
> rundown of how the task is used in PDE build, but I'll conclude with 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 anyhow). 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.
>
> There is a template for this file in the org.eclipse.pde.build plug-in.
> Here's the path for Eclipse 3.4.0:
>
> org.eclipse.pde.build_3.4.0.v20080604\templates\plugins\cust omBuildCallbacks.xml
>
> 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 goes here---" destdir="----
> JETs Java source folder goes here.. e.g. jet2java----" >
> <srcdir dir="." includes="templates/**/*.jet"/>
> </jet.compile>
> </target>
>
> <!--
> ============================================================ ========= -->
> <!-- Steps to do during the compilation target @dot, after the
> mpile -->
> <!-- 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 - Please read ========
> 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, this is often not the case. All
> the details are available on this bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=210447.
>
> 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, unfortuntately 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.
>
> Paul
>
>
Re: JET headless bulid [message #49556 is a reply to message #49494] Mon, 15 September 2008 09:38 Go to previous message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
Eric:

I've created the following FAQ entry:

http://wiki.eclipse.org/JET_FAQ_How_to_I_compile_JET_templat es_in_a_headless_build

As for what PDE build does, I'll try (from my inexpert point of view) to
explain what's going on...

First observation: PDE build is completely unrelated to the incremental
builder environment you use when working in the IDE. The incremental
builders that run are listed in the project's .project file. PDE build,
however, completely ignores .project, and only generates code to compile
Java source code. The mechanism for getting PDE build to do extra things is
customBuildCallbacks.

Second observation: The ANT based PDE build scripts typically do a check-out
from source control. These files are copied/updated to the local disk, but
the projects are not added to a workspace. This is where the jet.compile
task falls apart - it assumes that the projects are in a workspace, and in
particular, that it can get information about other required projects from
the workspace.

Paul
Previous Topic:JET Error Handling
Next Topic:[Announce] M2T Xpand 0.7.0 I200809160216 is available
Goto Forum:
  


Current Time: Fri Aug 22 08:06:07 EDT 2014

Powered by FUDForum. Page generated in 0.01637 seconds