Hi,
today i played around with the GWT compiler:
I wrote a servlet filter that monitors my gwt client classes and re-
compiles my app when one has changes (during the request so that i can
test a change simply by pressing reload in the browser).
The compiling is done by the following code:
ModuleDef moduleDef=ModuleDefLoader.loadFromClassPath
(logger, moduleName, true);
GWTCompiler compiler=new GWTCompiler();
compiler.setOutDir(outputFolder);
compiler.distill(logger, moduleDef);
The first run takes about 20 seconds (small test project), all other
runs about 4 seconds because the ModuleDef is reused. It works until I
really change one of my client classes. If I do a change, the
compilation fails with en exception:
java.lang.NullPointerException
at com.google.gwt.dev.javac.JdtCompiler
$CompilationUnitAdapter.getContents(JdtCompiler.java:65)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:
9236)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:
9208)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse
(Parser.java:7864)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile
(Compiler.java:587)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile
(Compiler.java:357)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:
371)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.compile
(AbstractCompiler.java:84)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.compile
(AbstractCompiler.java:180)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.access$400
(AbstractCompiler.java:70)
at com.google.gwt.dev.jdt.AbstractCompiler.compile
(AbstractCompiler.java:493)
at
com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations
(WebModeCompilerFrontEnd.java:73)
at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.<init>
(JavaToJavaScriptCompiler.java:277)
at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:353)
[...]
The reason is that the "resource" property of the changed
CompilationUnit is NULL.
ATM i workaround this by discarding the cached ModuleDef via
reflection:
Field fld=ModuleDefLoader.class.getDeclaredField
("loadedModules");
fld.setAccessible(true);
Map<String, ModuleDef> loadedModules=(Map<String,
ModuleDef>)fld.get(null);
loadedModules.remove(moduleName);
This works but then every compiler run takes 20 seconds.
Is there a better way to fix this?
What else can i do to improve the compiler speed for my on-thy-fly
builds?
Do you think this compiling-servlet-filter colud be usefull for other
users as well? (I know the the hosted mode which simplifies debugging
but for small gwt-projects with my servlet I can create self-contained
eclipse projects where any developer can simply check it out and
change something)
Regards,
Michael.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---