Modifies the IFrame linker so that any deferred-loaded JavaScript files needed by runAsync are placed into subdirectories of the main output directory. Review by: bobv git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@4265 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java index d13c0218..db5fddd 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
@@ -28,6 +28,7 @@ import com.google.gwt.dev.util.Util; import com.google.gwt.util.tools.Utility; +import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -55,6 +56,11 @@ protected static final String FRAGMENT_EXTENSION = ".cache.js"; /** + * A subdirectory to hold all the generated fragments. + */ + protected static final String FRAGMENT_SUBDIR = "deferredjs"; + + /** * Determines whether or not the URL is relative. * * @param src the test url @@ -111,7 +117,8 @@ throws UnableToCompleteException { String[] js = result.getJavaScript(); byte[][] bytes = new byte[js.length][]; - bytes[0] = generatePrimaryFragment(logger, context, js[0], result.getStrongName()); + bytes[0] = generatePrimaryFragment(logger, context, js[0], + result.getStrongName()); for (int i = 1; i < js.length; i++) { bytes[i] = Util.getBytes(js[i]); } @@ -120,8 +127,8 @@ toReturn.add(emitBytes(logger, bytes[0], result.getStrongName() + getCompilationExtension(logger, context))); for (int i = 1; i < js.length; i++) { - toReturn.add(emitBytes(logger, bytes[i], result.getStrongName() + "-" + i - + FRAGMENT_EXTENSION)); + toReturn.add(emitBytes(logger, bytes[i], FRAGMENT_SUBDIR + File.separator + + result.getStrongName() + File.separator + i + FRAGMENT_EXTENSION)); } compilationStrongNames.put(result, result.getStrongName()); @@ -336,7 +343,8 @@ } protected abstract String getModulePrefix(TreeLogger logger, - LinkerContext context, String strongName) throws UnableToCompleteException; + LinkerContext context, String strongName) + throws UnableToCompleteException; protected abstract String getModuleSuffix(TreeLogger logger, LinkerContext context) throws UnableToCompleteException; @@ -345,7 +353,8 @@ LinkerContext context) throws UnableToCompleteException; private byte[] generatePrimaryFragment(TreeLogger logger, - LinkerContext context, String js, String strongName) throws UnableToCompleteException { + LinkerContext context, String js, String strongName) + throws UnableToCompleteException { StringBuffer b = new StringBuffer(); b.append(getModulePrefix(logger, context, strongName)); b.append(js);
diff --git a/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java b/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java index c165152..9f50c76 100644 --- a/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java +++ b/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java
@@ -87,7 +87,7 @@ out.indentIn(); out.print(" var script = document.createElement('script');"); out.newlineOpt(); - out.print(" script.src = '" + strongName + "-' + frag + '" + FRAGMENT_EXTENSION + "';"); + out.print(" script.src = '" + FRAGMENT_SUBDIR + "/" + strongName + "/' + frag + '" + FRAGMENT_EXTENSION + "';"); out.print(" document.getElementsByTagName('head').item(0).appendChild(script);"); out.indentOut(); out.newlineOpt();