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 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2011 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tools;
  17. import java.lang.reflect.Method;
  18. import java.util.logging.Level;
  19. import java.util.logging.Logger;
  20. import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder;
  21. /**
  22. * A wrapper for the GWT 1.6 compiler that runs the compiler in a new thread.
  23. *
  24. * This allows circumventing a J2SE 5.0 bug (6316197) that prevents setting the
  25. * stack size for the main thread. Thus, larger widgetsets can be compiled.
  26. *
  27. * This class takes the same command line arguments as the
  28. * com.google.gwt.dev.GWTCompiler class. The old and deprecated compiler is used
  29. * for compatibility with GWT 1.5.
  30. *
  31. * A typical invocation would use e.g. the following arguments
  32. *
  33. * "-out WebContent/VAADIN/widgetsets com.vaadin.terminal.gwt.DefaultWidgetSet"
  34. *
  35. * In addition, larger memory usage settings for the VM should be used, e.g.
  36. *
  37. * "-Xms256M -Xmx512M -Xss8M"
  38. *
  39. * The source directory containing widgetset and related classes must be
  40. * included in the classpath, as well as the gwt-dev-[platform].jar and other
  41. * relevant JARs.
  42. *
  43. * @deprecated with Java 6, can use com.google.gwt.dev.Compiler directly (also
  44. * in Eclipse plug-in etc.)
  45. */
  46. @Deprecated
  47. public class WidgetsetCompiler {
  48. /**
  49. * @param args
  50. * same arguments as for com.google.gwt.dev.Compiler
  51. */
  52. public static void main(final String[] args) {
  53. try {
  54. // run the compiler in a different thread to enable using the
  55. // user-set stack size
  56. // on Windows, the default stack size is too small for the main
  57. // thread and cannot be changed in JRE 1.5 (see
  58. // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197)
  59. Runnable runCompiler = new Runnable() {
  60. @Override
  61. public void run() {
  62. try {
  63. // GWTCompiler.main(args);
  64. // avoid warnings
  65. String wsname = args[args.length - 1];
  66. // TODO expecting this is launched via eclipse WTP
  67. // project
  68. System.out
  69. .println("Updating GWT module description file...");
  70. WidgetSetBuilder.updateWidgetSet(wsname);
  71. System.out.println("Done.");
  72. System.out.println("Starting GWT compiler");
  73. System.setProperty("gwt.nowarn.legacy.tools", "true");
  74. Class<?> compilerClass = Class
  75. .forName("com.google.gwt.dev.GWTCompiler");
  76. Method method = compilerClass.getDeclaredMethod("main",
  77. String[].class);
  78. method.invoke(null, new Object[] { args });
  79. } catch (Throwable thr) {
  80. getLogger().log(Level.SEVERE,
  81. "Widgetset compilation failed", thr);
  82. }
  83. }
  84. };
  85. Thread runThread = new Thread(runCompiler);
  86. runThread.start();
  87. runThread.join();
  88. System.out.println("Widgetset compilation finished");
  89. } catch (Throwable thr) {
  90. getLogger().log(Level.SEVERE, "Widgetset compilation failed", thr);
  91. }
  92. }
  93. private static final Logger getLogger() {
  94. return Logger.getLogger(WidgetsetCompiler.class.getName());
  95. }
  96. }