So, GXP supports runtime compilation "out of the box" that you might
want to just use. If you are using ant you turn this on by adding
dynamic="true" to your <gxpc> rule. Let's say we were working with
HelloWorld.gxp. We still generate a HelloWorld.java (which javac
turns into a class file) but when in dynamic mode this file doesn't
know to output the results of the template (spit out <b>Hello World</
b> or whatever). Instead if knows how to compile HelloWorld.gxp
(knows where the souce file is, what arguments were originally passed
to the compiler, etc). So when you call HelloWorld#write() it goes
off and does a runtime GXP compile cycle AND a runtime java compile
cycles (using javax.tools.JavaCompiler). You can see the code that
does this in java/src/com/google/gxp/base/dynamic/
StubGxpTemplate.java. It (obviously) checks to see if the source has
changed so it doesn't have to compile every time, just when the source
has changed.
I'm not entirely clear on your design requirements, but putting GXP in
this mode may get you all that you need. If it does not, taking a
look at StubGxpTemplate should give you some ideas about how to invoke
the compiler at runtime.
Note, however, that I will (as soon as Laurence reviews the code) be
checking in some code to make invoking the compiler a bit more
standardized. Right now ant, the command line interface, and
StubGxpTemplate all do it a little differently. My change will make
it so that they all use GxpcConfiguration. So whenever you want to
invoke the compiler you'll just need to build up a GxpcConfiguration
and pass that to an appropriate place and things will just work.
Hopefully this has been a somewhat helpful note. Definitely ask more
questions if you have them!
-harryh