Reputation: 1973
I need to compile a GWT project from Java App. So i created a Compiler instance with CompilerOptions which sets output directories etc.
My code is like this:
Compiler compiler=new Compiler(new CompilerOptions() {......
....
}
ModuleDef def=new ModuleDef("sampleweb");
def.clear();
def.addSourcePackage("D:\\projects\\sampleweb\\src\\com\\sample\\web", new String[]{"client"}, new String[]{}, new String[]{}, true, false);
def.addGwtXmlFile(new File("D:\\projects\\sampleweb\\src\\com\\sampleweb\\web\\Sampleweb.gwt.xml"));
TreeLogger logger=new SwingTreeLogger(new SwingLoggerPanel(Type.ALL, new File("x.txt")));
compiler.run(logger,def);
When the compiler.run
is called, a NullPointerException as shown is thrown
Exception in thread "main" java.lang.NullPointerException
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:373)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:246)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
at com.google.gwt.dev.Compiler.run(Compiler.java:232)
at com.asklepian.TestApp.Starter.main(Starter.java:400)
How should I configure compiler?
Upvotes: 1
Views: 555
Reputation: 36
I would create just the Java source code and the XML module code, and than execute a Java process who calls the GWT compiler. The GWT compiler is located at com.google.gwt.dev.Compiler, and you can execute it in Windows from the DOS command shell with the java command. The only parameter the compiler needs is the GWT module Location (the location of the module xml file).
Upvotes: 0