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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  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. * @deprecated with Java 6, can use com.google.gwt.dev.Compiler directly (also
  32. * in Eclipse plug-in etc.)
  33. */
  34. @Deprecated
  35. public class WidgetsetCompiler {
  36. /**
  37. * @param args
  38. * same arguments as for com.google.gwt.dev.Compiler
  39. */
  40. public static void main(final String[] args) {
  41. try {
  42. // run the compiler in a different thread to enable using the
  43. // user-set stack size
  44. // on Windows, the default stack size is too small for the main
  45. // thread and cannot be changed in JRE 1.5 (see
  46. // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197)
  47. Runnable runCompiler = new Runnable() {
  48. @Override
  49. public void run() {
  50. try {
  51. // GWTCompiler.main(args);
  52. // avoid warnings
  53. String wsname = args[args.length - 1];
  54. // TODO expecting this is launched via eclipse WTP
  55. // project
  56. System.out
  57. .println("Updating GWT module description file...");
  58. WidgetSetBuilder.updateWidgetSet(wsname);
  59. System.out.println("Done.");
  60. System.out.println("Starting GWT compiler");
  61. System.setProperty("gwt.nowarn.legacy.tools", "true");
  62. Class<?> compilerClass = Class
  63. .forName("com.google.gwt.dev.GWTCompiler");
  64. Method method = compilerClass.getDeclaredMethod("main",
  65. String[].class);
  66. method.invoke(null, new Object[] { args });
  67. } catch (Throwable thr) {
  68. getLogger().log(Level.SEVERE,
  69. "Widgetset compilation failed", thr);
  70. }
  71. }
  72. };
  73. Thread runThread = new Thread(runCompiler);
  74. runThread.start();
  75. runThread.join();
  76. System.out.println("Widgetset compilation finished");
  77. } catch (Throwable thr) {
  78. getLogger().log(Level.SEVERE, "Widgetset compilation failed", thr);
  79. }
  80. }
  81. private static final Logger getLogger() {
  82. return Logger.getLogger(WidgetsetCompiler.class.getName());
  83. }
  84. }