You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WidgetsetCompiler.java 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.tools;
  5. import java.lang.reflect.Method;
  6. import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder;
  7. /**
  8. * A wrapper for the GWT 1.6 compiler that runs the compiler in a new thread.
  9. *
  10. * This allows circumventing a J2SE 5.0 bug (6316197) that prevents setting the
  11. * stack size for the main thread. Thus, larger widgetsets can be compiled.
  12. *
  13. * This class takes the same command line arguments as the
  14. * com.google.gwt.dev.GWTCompiler class. The old and deprecated compiler is used
  15. * for compatibility with GWT 1.5.
  16. *
  17. * A typical invocation would use e.g. the following arguments
  18. *
  19. * "-out WebContent/VAADIN/widgetsets com.vaadin.terminal.gwt.DefaultWidgetSet"
  20. *
  21. * In addition, larger memory usage settings for the VM should be used, e.g.
  22. *
  23. * "-Xms256M -Xmx512M -Xss8M"
  24. *
  25. * The source directory containing widgetset and related classes must be
  26. * included in the classpath, as well as the gwt-dev-[platform].jar and other
  27. * relevant JARs.
  28. */
  29. public class WidgetsetCompiler {
  30. /**
  31. * @param args
  32. * same arguments as for com.google.gwt.dev.Compiler
  33. */
  34. public static void main(final String[] args) {
  35. try {
  36. // run the compiler in a different thread to enable using the
  37. // user-set stack size
  38. // on Windows, the default stack size is too small for the main
  39. // thread and cannot be changed in JRE 1.5 (see
  40. // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197)
  41. Runnable runCompiler = new Runnable() {
  42. public void run() {
  43. try {
  44. // GWTCompiler.main(args);
  45. // avoid warnings
  46. String wsname = args[args.length - 1];
  47. // TODO expecting this is launched via eclipse WTP
  48. // project
  49. System.out
  50. .println("Updating GWT module description file...");
  51. WidgetSetBuilder.updateWidgetSet(wsname);
  52. System.out.println("Done.");
  53. System.out.println("Starting GWT compiler");
  54. System.setProperty("gwt.nowarn.legacy.tools", "true");
  55. Class<?> compilerClass = Class
  56. .forName("com.google.gwt.dev.GWTCompiler");
  57. Method method = compilerClass.getDeclaredMethod("main",
  58. String[].class);
  59. method.invoke(null, new Object[] { args });
  60. } catch (Throwable thr) {
  61. thr.printStackTrace();
  62. }
  63. }
  64. };
  65. Thread runThread = new Thread(runCompiler);
  66. runThread.start();
  67. runThread.join();
  68. System.out.println("Widgetset compilation finished");
  69. } catch (Throwable thr) {
  70. thr.printStackTrace();
  71. }
  72. }
  73. }