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.3KB

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