]> source.dussan.org Git - vaadin-framework.git/commitdiff
Support multiple source paths in widgetset builder - not yet tested
authorHenri Sara <henri.sara@itmill.com>
Tue, 27 Oct 2009 14:15:52 +0000 (14:15 +0000)
committerHenri Sara <henri.sara@itmill.com>
Tue, 27 Oct 2009 14:15:52 +0000 (14:15 +0000)
svn changeset:9411/svn branch:6.2

src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java
src/com/vaadin/tools/WidgetsetCompiler.java

index 1c6b3968c0cc34b57b1dd48c1cb2efc9648a15bb..ff8786a6b57cb61c6f1d27aa8fbbb25e67464d45 100644 (file)
@@ -37,7 +37,7 @@ import com.vaadin.ui.ClientWidget;
  * appropriate monkey code for gwt directly in annotation processor and get rid
  * of {@link WidgetMapGenerator}. Using annotation processor might be a good
  * idea when dropping Java 1.5 support (integrated to javac in 6).
- * 
+ *
  */
 public class ClassPathExplorer {
     private final static FileFilter DIRECTORIES_ONLY = new FileFilter() {
@@ -70,11 +70,11 @@ public class ClassPathExplorer {
 
     /**
      * Finds available widgetset names.
-     * 
+     *
      * @return
      */
-    public static Collection<String> getAvailableWidgetSets() {
-        Collection<String> widgetsets = new HashSet<String>();
+    public static Map<String, URL> getAvailableWidgetSets() {
+        Map<String, URL> widgetsets = new HashMap<String, URL>();
         Set<URL> keySet = classpathLocations.keySet();
         for (URL url : keySet) {
             searchForWidgetSets(url, widgetsets);
@@ -83,7 +83,7 @@ public class ClassPathExplorer {
     }
 
     private static void searchForWidgetSets(URL location,
-            Collection<String> widgetsets) {
+            Map<String, URL> widgetsets) {
 
         File directory = new File(location.getFile());
 
@@ -98,7 +98,7 @@ public class ClassPathExplorer {
                             files[i].length() - 8);
                     classname = classpathLocations.get(location) + "."
                             + classname;
-                    widgetsets.add(classname);
+                    widgetsets.put(classname, location);
                 }
             }
         } else {
@@ -121,7 +121,7 @@ public class ClassPathExplorer {
                         for (int i = 0; i < widgetsetNames.length; i++) {
                             String widgetsetname = widgetsetNames[i].trim()
                                     .intern();
-                            widgetsets.add(widgetsetname);
+                            widgetsets.put(widgetsetname, location);
                         }
                     }
                 }
@@ -204,7 +204,7 @@ public class ClassPathExplorer {
 
     /**
      * Recursively add subdirectories and jar files to classpathlocations
-     * 
+     *
      * @param name
      * @param file
      * @param locations
@@ -351,10 +351,11 @@ public class ClassPathExplorer {
         System.out.println();
         System.out.println("Searching available widgetsets...");
 
-        Collection<String> availableWidgetSets = ClassPathExplorer
+        Map<String, URL> availableWidgetSets = ClassPathExplorer
                 .getAvailableWidgetSets();
-        for (String string : availableWidgetSets) {
-            System.out.println(string);
+        for (String string : availableWidgetSets.keySet()) {
+            System.out.println(string + " in "
+                    + availableWidgetSets.get(string));
         }
     }
 }
\ No newline at end of file
index 05e2460a27debec9f8cd6b394a8d2af9b2611b87..6ce60972699c36c15a01eed60f2e95553e914b32 100644 (file)
@@ -10,8 +10,10 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.Reader;
+import java.net.URL;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -26,16 +28,21 @@ public class WidgetSetBuilder {
             printUsage();
         } else {
             String widgetsetname = args[0];
-            String sourcepath = args[1];
-            updateWidgetSet(widgetsetname, sourcepath);
+            updateWidgetSet(widgetsetname);
 
         }
     }
 
-    public static void updateWidgetSet(final String widgetset, String sourcepath)
+    public static void updateWidgetSet(final String widgetset)
             throws IOException, FileNotFoundException {
         boolean changed = false;
-        String widgetsetfilename = sourcepath + "/"
+
+        Map<String, URL> availableWidgetSets = ClassPathExplorer
+                .getAvailableWidgetSets();
+
+        URL sourceUrl = availableWidgetSets.get(widgetset);
+
+        String widgetsetfilename = sourceUrl.getFile() + "/"
                 + widgetset.replace(".", "/") + ".gwt.xml";
         File widgetsetFile = new File(widgetsetfilename);
         if (!widgetsetFile.exists()) {
@@ -58,11 +65,8 @@ public class WidgetSetBuilder {
 
         Collection<String> oldInheritedWidgetsets = getCurrentWidgetSets(content);
 
-        Collection<String> availableWidgetSets = ClassPathExplorer
-                .getAvailableWidgetSets();
-
         // add widgetsets that do not exist
-        for (String ws : availableWidgetSets) {
+        for (String ws : availableWidgetSets.keySet()) {
             if (ws.equals(widgetset)) {
                 // do not inherit the module itself
                 continue;
@@ -73,7 +77,7 @@ public class WidgetSetBuilder {
         }
 
         for (String ws : oldInheritedWidgetsets) {
-            if (!availableWidgetSets.contains(ws)) {
+            if (!availableWidgetSets.containsKey(ws)) {
                 // widgetset not available in classpath
                 content = removeWidgetSet(ws, content);
             }
@@ -135,7 +139,7 @@ public class WidgetSetBuilder {
         o.println("\t1. Set the same classpath as you will "
                 + "have for the GWT compiler.");
         o.println("\t2. Give the widgetsetname (to be created or updated)"
-                + " as first parameter, source path as a second parameter");
+                + " as first parameter");
         o.println();
         o
                 .println("All found vaadin widgetsets will be inherited in given widgetset");
index ce7ab3762544d6bbba7a0fbc0e4f767ab5481135..4d809a470f8434df0a2c68ac61493db63bbe054a 100644 (file)
@@ -6,22 +6,22 @@ import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder;
 \r
 /**\r
  * A wrapper for the GWT 1.6 compiler that runs the compiler in a new thread.\r
- * \r
+ *\r
  * This allows circumventing a J2SE 5.0 bug (6316197) that prevents setting the\r
  * stack size for the main thread. Thus, larger widgetsets can be compiled.\r
- * \r
+ *\r
  * This class takes the same command line arguments as the\r
  * com.google.gwt.dev.GWTCompiler class. The old and deprecated compiler is used\r
  * for compatibility with GWT 1.5.\r
- * \r
+ *\r
  * A typical invocation would use e.g. the following arguments\r
- * \r
+ *\r
  * "-out WebContent/VAADIN/widgetsets com.vaadin.terminal.gwt.DefaultWidgetSet"\r
- * \r
+ *\r
  * In addition, larger memory usage settings for the VM should be used, e.g.\r
- * \r
+ *\r
  * "-Xms256M -Xmx512M -Xss8M"\r
- * \r
+ *\r
  * The source directory containing widgetset and related classes must be\r
  * included in the classpath, as well as the gwt-dev-[platform].jar and other\r
  * relevant JARs.\r
@@ -51,7 +51,7 @@ public class WidgetsetCompiler {
 \r
                         // TODO expecting this is launched via eclipse WTP\r
                         // project\r
-                        WidgetSetBuilder.updateWidgetSet(wsname, "src");\r
+                        WidgetSetBuilder.updateWidgetSet(wsname);\r
 \r
                         System.setProperty("gwt.nowarn.legacy.tools", "true");\r
                         Class<?> compilerClass = Class\r