From: Henri Sara Date: Tue, 27 Oct 2009 14:15:52 +0000 (+0000) Subject: Support multiple source paths in widgetset builder - not yet tested X-Git-Tag: 6.7.0.beta1~2372 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c0f0421d75d09e72724bfb9d412fb48e5ddf3e4e;p=vaadin-framework.git Support multiple source paths in widgetset builder - not yet tested svn changeset:9411/svn branch:6.2 --- diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index 1c6b3968c0..ff8786a6b5 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -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 getAvailableWidgetSets() { - Collection widgetsets = new HashSet(); + public static Map getAvailableWidgetSets() { + Map widgetsets = new HashMap(); Set keySet = classpathLocations.keySet(); for (URL url : keySet) { searchForWidgetSets(url, widgetsets); @@ -83,7 +83,7 @@ public class ClassPathExplorer { } private static void searchForWidgetSets(URL location, - Collection widgetsets) { + Map 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 availableWidgetSets = ClassPathExplorer + Map 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 diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java b/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java index 05e2460a27..6ce6097269 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java @@ -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 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 oldInheritedWidgetsets = getCurrentWidgetSets(content); - Collection 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"); diff --git a/src/com/vaadin/tools/WidgetsetCompiler.java b/src/com/vaadin/tools/WidgetsetCompiler.java index ce7ab37625..4d809a470f 100644 --- a/src/com/vaadin/tools/WidgetsetCompiler.java +++ b/src/com/vaadin/tools/WidgetsetCompiler.java @@ -6,22 +6,22 @@ import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder; /** * A wrapper for the GWT 1.6 compiler that runs the compiler in a new thread. - * + * * This allows circumventing a J2SE 5.0 bug (6316197) that prevents setting the * stack size for the main thread. Thus, larger widgetsets can be compiled. - * + * * This class takes the same command line arguments as the * com.google.gwt.dev.GWTCompiler class. The old and deprecated compiler is used * for compatibility with GWT 1.5. - * + * * A typical invocation would use e.g. the following arguments - * + * * "-out WebContent/VAADIN/widgetsets com.vaadin.terminal.gwt.DefaultWidgetSet" - * + * * In addition, larger memory usage settings for the VM should be used, e.g. - * + * * "-Xms256M -Xmx512M -Xss8M" - * + * * The source directory containing widgetset and related classes must be * included in the classpath, as well as the gwt-dev-[platform].jar and other * relevant JARs. @@ -51,7 +51,7 @@ public class WidgetsetCompiler { // TODO expecting this is launched via eclipse WTP // project - WidgetSetBuilder.updateWidgetSet(wsname, "src"); + WidgetSetBuilder.updateWidgetSet(wsname); System.setProperty("gwt.nowarn.legacy.tools", "true"); Class compilerClass = Class