Revision: 10255
Author: rj...@google.com
Date: Wed Jun 1 09:26:16 2011
Log: Move the SimpleAppCacheLinker out to sample land, it's not quite
ready.
Review at http://gwt-code-reviews.appspot.com/1447813
Review by: rchan...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10255
Added:
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core/Core.gwt.xml
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core/linker
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core/linker/SimpleAppCacheLinker.java
/trunk/samples/mobilewebapp/src/test
/trunk/samples/mobilewebapp/src/test/java
/trunk/samples/mobilewebapp/src/test/java/com
/trunk/samples/mobilewebapp/src/test/java/com/google
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt/sample
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt/sample/core
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt/sample/core/linker
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt/sample/core/linker/SimpleAppCacheLinkerTest.java
Deleted:
/trunk/dev/core/src/com/google/gwt/core/linker/SimpleAppCacheLinker.java
/trunk/dev/core/test/com/google/gwt/core/linker/SimpleAppCacheLinkerTest.java
Modified:
/trunk/samples/mobilewebapp/README-MAVEN.txt
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/MobileWebApp.gwt.xml
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/linker/AppCacheLinker.java
/trunk/user/test/com/google/gwt/core/ext/LinkerSuite.java
=======================================
--- /dev/null
+++
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core/Core.gwt.xml
Wed Jun 1 09:26:16 2011
@@ -0,0 +1,22 @@
+<!--
-->
+<!-- Copyright 2011 Google
Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License");
you -->
+<!-- may not use this file except in compliance with the License. You
may -->
+<!-- may obtain a copy of the License
at -->
+<!--
-->
+<!--
http://www.apache.org/licenses/LICENSE-2.0 -->
+<!--
-->
+<!-- Unless required by applicable law or agreed to in writing,
software -->
+<!-- distributed under the License is distributed on an "AS IS"
BASIS, -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or -->
+<!-- implied. License for the specific language governing permissions
and -->
+<!-- limitations under the
License. -->
+
+<!-- Types and resources required to support primitive system
operation. -->
+<!--
-->
+<!-- Types from this module are visible to and imported into user
code. -->
+<!-- Every module should directly or indirectly inherit this
module. -->
+<!--
-->
+<module>
+ <inherits name="com.google.gwt.core.Core" />
+</module>
=======================================
--- /dev/null
+++
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/core/linker/SimpleAppCacheLinker.java
Wed Jun 1 09:26:16 2011
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.sample.core.linker;
+
+import com.google.gwt.core.ext.LinkerContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.linker.AbstractLinker;
+import com.google.gwt.core.ext.linker.Artifact;
+import com.google.gwt.core.ext.linker.ArtifactSet;
+import com.google.gwt.core.ext.linker.EmittedArtifact;
+import com.google.gwt.core.ext.linker.LinkerOrder;
+import com.google.gwt.core.ext.linker.LinkerOrder.Order;
+import com.google.gwt.core.ext.linker.impl.SelectionInformation;
+
+import java.util.Arrays;
+import java.util.Date;
+
+/**
+ * Linker for public path resources in the Application Cache.
+ * <p>
+ * <strong>Warning</strong>This linker sends all permutations to clients,
+ * making it inappropriate for most production use.</strong>
+ * <p>
+ * To use:
+ * <ol>
+ * <li>Add {@code manifest="YOURMODULENAME/appcache.nocache.manifest"} to
the
+ * {@code <html>} tag in your base html file. E.g.,
+ * {@code <html manifest="mymodule/appcache.nocache.manifest">}</li>
+ * <li>Add a mime-mapping to your web.xml file:
+ * <p>
+ * <pre>{@code <mime-mapping>
+ * <extension>manifest</extension>
+ * <mime-type>text/cache-manifest</mime-type>
+ * </mime-mapping>
+ * }</pre>
+ * </li>
+ * </ol>
+ * <p>
+ * On every compile, this linker will regenerate the
appcache.nocache.manifest
+ * file with files from the public path of your module.
+ * <p>
+ * To obtain a manifest that contains other files in addition to those
+ * generated by this linker, create a class that inherits from this one
+ * and overrides {@code otherCachedFiles()}, and use it as a linker
instead:
+ * <p>
+ * <pre><blockquote>
+ * {@code @Shardable}
+ * public class MyAppCacheLinker extends AbstractAppCacheLinker {
+ * {@code @Override}
+ * protected String[] otherCachedFiles() {
+ * return new String[] {"/MyApp.html","/MyApp.css"};
+ * }
+ * }
+ * </blockquote></pre>
+ */
+@LinkerOrder(Order.POST)
+public class SimpleAppCacheLinker extends AbstractLinker {
+
+ private static final String MANIFEST = "appcache.nocache.manifest";
+
+ @Override
+ public String getDescription() {
+ return "AppCacheLinker";
+ }
+
+ @Override
+ public ArtifactSet link(TreeLogger logger, LinkerContext context,
ArtifactSet artifacts,
+ boolean onePermutation)
+ throws UnableToCompleteException {
+
+ ArtifactSet toReturn = new ArtifactSet(artifacts);
+
+ if (onePermutation) {
+ return toReturn;
+ }
+
+ if (toReturn.find(SelectionInformation.class).isEmpty()) {
+ logger.log(TreeLogger.INFO, "DevMode warning: Clobbering " +
MANIFEST + " to allow debugging. "
+ + "Recompile before deploying your app!");
+ artifacts = null;
+ }
+
+ // Create the general cache-manifest resource for the landing page:
+ toReturn.add(emitLandingPageCacheManifest(context, logger, artifacts));
+ return toReturn;
+ }
+
+ /**
+ * Override this method to force the linker to also include more files
+ * in the manifest.
+ */
+ protected String[] otherCachedFiles() {
+ return null;
+ }
+
+ /**
+ * Creates the cache-manifest resource specific for the landing page.
+ *
+ * @param context the linker environment
+ * @param logger the tree logger to record to
+ * @param artifacts {@code null} to generate an empty cache manifest
+ */
+ private Artifact<?> emitLandingPageCacheManifest(LinkerContext context,
TreeLogger logger,
+ ArtifactSet artifacts)
+ throws UnableToCompleteException {
+ StringBuilder publicSourcesSb = new StringBuilder();
+ StringBuilder staticResoucesSb = new StringBuilder();
+
+ if (artifacts != null) {
+ // Iterate over all emitted artifacts, and collect all cacheable
artifacts
+ for (@SuppressWarnings("rawtypes") Artifact artifact : artifacts) {
+ if (artifact instanceof EmittedArtifact) {
+ EmittedArtifact ea = (EmittedArtifact) artifact;
+ String pathName = ea.getPartialPath();
+ if (pathName.endsWith("symbolMap")
+ || pathName.endsWith(".xml.gz")
+ || pathName.endsWith("rpc.log")
+ || pathName.endsWith("gwt.rpc")
+ || pathName.endsWith("manifest.txt")
+ || pathName.startsWith("rpcPolicyManifest")) {
+ // skip these resources
+ } else {
+ publicSourcesSb.append(pathName + "\n");
+ }
+ }
+ }
+
+ String[] cacheExtraFiles = getCacheExtraFiles();
+ for (int i = 0; i < cacheExtraFiles.length; i++) {
+ staticResoucesSb.append(cacheExtraFiles[i]);
+ staticResoucesSb.append("\n");
+ }
+ }
+
+ // build cache list
+ StringBuilder sb = new StringBuilder();
+ sb.append("CACHE MANIFEST\n");
+ sb.append("# Unique id #" + (new Date()).getTime() + "." +
Math.random() + "\n");
+ // we have to generate this unique id because the resources can change
but
+ // the hashed cache.html files can remain the same.
+ sb.append("# Note: must change this every time for cache to
invalidate\n");
+ sb.append("\n");
+ sb.append("CACHE:\n");
+ sb.append("# Static app files\n");
+ sb.append(staticResoucesSb.toString());
+ sb.append("\n# Generated app files\n");
+ sb.append(publicSourcesSb.toString());
+ sb.append("\n\n");
+ sb.append("# All other resources require the user to be online.\n");
+ sb.append("NETWORK:\n");
+ sb.append("*\n");
+
+ logger.log(TreeLogger.INFO, "Be sure your landing page's <html> tag
declares a manifest:"
+ + " <html manifest=" + context.getModuleFunctionName() + "/" +
MANIFEST + "\">");
+
+ // Create the manifest as a new artifact and return it:
+ return emitString(logger, sb.toString(), MANIFEST);
+ }
+
+ /**
+ * Obtains the extra files to include in the manifest. Ensures the
returned
+ * array is not null.
+ */
+ private String[] getCacheExtraFiles() {
+ String[] cacheExtraFiles = otherCachedFiles();
+ return cacheExtraFiles == null ?
+ new String[0] : Arrays.copyOf(cacheExtraFiles,
cacheExtraFiles.length);
+ }
+}
=======================================
--- /dev/null
+++
/trunk/samples/mobilewebapp/src/test/java/com/google/gwt/sample/core/linker/SimpleAppCacheLinkerTest.java
Wed Jun 1 09:26:16 2011
@@ -0,0 +1,179 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+package com.google.gwt.sample.core.linker;
+
+import com.google.gwt.core.ext.LinkerContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.linker.ArtifactSet;
+import com.google.gwt.core.ext.linker.ConfigurationProperty;
+import com.google.gwt.core.ext.linker.SelectionProperty;
+import com.google.gwt.core.ext.linker.SyntheticArtifact;
+import com.google.gwt.core.ext.linker.impl.SelectionInformation;
+import com.google.gwt.sample.core.linker.SimpleAppCacheLinker;
+
+import junit.framework.TestCase;
+
+import java.io.InputStream;
+import java.util.Scanner;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Tests {@link SimpleAppCacheLinker}
+ */
+public class SimpleAppCacheLinkerTest extends TestCase {
+ private ArtifactSet artifacts;
+ private TreeLogger logger;
+
+ @Override
+ public void setUp() {
+ artifacts = new ArtifactSet();
+ artifacts.add(new SelectionInformation("foo", 0, new TreeMap<String,
String>()));
+ logger = TreeLogger.NULL;
+ }
+
+ public void testAddCachableArtifacts() throws UnableToCompleteException {
+ SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
+
+ // Some cacheable artifact
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.bar", new byte[0]));
+
+ ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
+
+ assertEquals(3, result.size());
+ assertHasOneManifest(result);
+ assertTrue(getManifestContents(result).contains("foo.bar"));
+ }
+
+ public void testNoNonCachableArtifacts() throws
UnableToCompleteException {
+ SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
+
+ // Some non-cacheable artifacts
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.symbolMap", new
byte[0]));
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.xml.gz", new byte[0]));
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.rpc.log", new byte[0]));
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.gwt.rpc", new byte[0]));
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "rpcPolicyManifest.bar", new
byte[0]));
+
+ ArtifactSet result = linker.link(TreeLogger.NULL, new
MockLinkerContext(), artifacts, false);
+
+ assertEquals(7, result.size());
+ assertHasOneManifest(result);
+ assertFalse(getManifestContents(result).contains("symbolMap"));
+ assertFalse(getManifestContents(result).contains("xml.gz"));
+ assertFalse(getManifestContents(result).contains("rpc.log"));
+ assertFalse(getManifestContents(result).contains("gwt.rpc"));
+ assertFalse(getManifestContents(result).contains("rpcPolicyManifest"));
+ }
+
+ public void testAddStaticFiles() throws UnableToCompleteException {
+ SimpleAppCacheLinker linker = new OneStaticFileAppCacheLinker();
+
+ ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
+
+ assertEquals(2, result.size());
+ assertHasOneManifest(result);
+ assertTrue(getManifestContents(result).contains("aStaticFile"));
+ }
+
+ public void testEmptyManifestDevMode() throws UnableToCompleteException {
+ // No SelectionInformation artifact
+ artifacts = new ArtifactSet();
+
+ SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
+
+ // Some cacheable artifact
+ artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.bar", new byte[0]));
+
+ ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
+
+ assertHasOneManifest(result);
+ assertFalse(getManifestContents(result).contains("foo.bar"));
+ }
+
+ public void testManifestOnlyOnLastPass() throws
UnableToCompleteException {
+ SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
+
+ ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, true);
+
+ assertEquals(artifacts, result);
+
+ result = linker.link(logger, new MockLinkerContext(), artifacts,
false);
+
+ assertEquals(2, result.size());
+ assertHasOneManifest(result);
+ }
+
+ private void assertHasOneManifest(ArtifactSet artifacts) {
+ int manifestCount = 0;
+ for (SyntheticArtifact artifact :
artifacts.find(SyntheticArtifact.class)) {
+ if ("appcache.nocache.manifest".equals(artifact.getPartialPath())) {
+ assertEquals("appcache.nocache.manifest",
artifact.getPartialPath());
+ manifestCount++;
+ }
+ }
+ assertEquals(1, manifestCount);
+ }
+
+ private SyntheticArtifact getManifest(ArtifactSet artifacts) {
+ for (SyntheticArtifact artifact :
artifacts.find(SyntheticArtifact.class)) {
+ if ("appcache.nocache.manifest".equals(artifact.getPartialPath())) {
+ assertEquals("appcache.nocache.manifest",
artifact.getPartialPath());
+ return artifact;
+ }
+ }
+ fail("Manifest not found");
+ return null;
+ }
+
+ private String getManifestContents(ArtifactSet artifacts) throws
UnableToCompleteException {
+ return getArtifactContents(getManifest(artifacts));
+ }
+
+ private String getArtifactContents(SyntheticArtifact artifact) throws
UnableToCompleteException {
+ InputStream is = artifact.getContents(logger);
+ String contents = new Scanner(is).useDelimiter("\\A").next();
+ return contents;
+ }
+
+ public static class OneStaticFileAppCacheLinker extends
SimpleAppCacheLinker {
+
+ @Override
+ protected String[] otherCachedFiles() {
+ return new String[] {"aStaticFile"};
+ }
+ }
+
+ private static class MockLinkerContext implements LinkerContext {
+
+ public SortedSet<ConfigurationProperty> getConfigurationProperties() {
+ return new TreeSet<ConfigurationProperty>();
+ }
+
+ public String getModuleFunctionName() {
+ return null;
+ }
+
+ public long getModuleLastModified() {
+ return 0;
+ }
+
+ public String getModuleName() {
+ return null;
+ }
+
+ public SortedSet<SelectionProperty> getProperties() {
+ return new TreeSet<SelectionProperty>();
+ }
+
+ public boolean isOutputCompact() {
+ return true;
+ }
+
+ public String optimizeJavaScript(TreeLogger logger, String jsProgram) {
+ return jsProgram;
+ }
+ }
+}
=======================================
---
/trunk/dev/core/src/com/google/gwt/core/linker/SimpleAppCacheLinker.java
Thu May 12 14:09:51 2011
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.core.linker;
-
-import com.google.gwt.core.ext.LinkerContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.AbstractLinker;
-import com.google.gwt.core.ext.linker.Artifact;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.EmittedArtifact;
-import com.google.gwt.core.ext.linker.LinkerOrder;
-import com.google.gwt.core.ext.linker.LinkerOrder.Order;
-import com.google.gwt.core.ext.linker.impl.SelectionInformation;
-
-import java.util.Arrays;
-import java.util.Date;
-
-/**
- * AppCacheLinker - linker for public path resources in the Application
Cache.
- * <p>
- * To use:
- * <ol>
- * <li>Add {@code manifest="YOURMODULENAME/appcache.nocache.manifest"} to
the
- * {@code <html>} tag in your base html file. E.g.,
- * {@code <html manifest="mymodule/appcache.nocache.manifest">}</li>
- * <li>Add a mime-mapping to your web.xml file:
- * <p>
- * <pre>{@code <mime-mapping>
- * <extension>manifest</extension>
- * <mime-type>text/cache-manifest</mime-type>
- * </mime-mapping>
- * }</pre>
- * </li>
- * </ol>
- * <p>
- * On every compile, this linker will regenerate the
appcache.nocache.manifest
- * file with files from the public path of your module.
- * <p>
- * To obtain a manifest that contains other files in addition to those
- * generated by this linker, create a class that inherits from this one
- * and overrides {@code otherCachedFiles()}, and use it as a linker
instead:
- * <p>
- * <pre><blockquote>
- * {@code @Shardable}
- * public class MyAppCacheLinker extends AbstractAppCacheLinker {
- * {@code @Override}
- * protected String[] otherCachedFiles() {
- * return new String[] {"/MyApp.html","/MyApp.css"};
- * }
- * }
- * </blockquote></pre>
- */
-@LinkerOrder(Order.POST)
-public class SimpleAppCacheLinker extends AbstractLinker {
-
- private static final String MANIFEST = "appcache.nocache.manifest";
-
- @Override
- public String getDescription() {
- return "AppCacheLinker";
- }
-
- @Override
- public ArtifactSet link(TreeLogger logger, LinkerContext context,
ArtifactSet artifacts,
- boolean onePermutation)
- throws UnableToCompleteException {
-
- ArtifactSet toReturn = new ArtifactSet(artifacts);
-
- if (onePermutation) {
- return toReturn;
- }
-
- if (toReturn.find(SelectionInformation.class).isEmpty()) {
- logger.log(TreeLogger.INFO, "DevMode warning: Clobbering " +
MANIFEST + " to allow debugging. "
- + "Recompile before deploying your app!");
- artifacts = null;
- }
-
- // Create the general cache-manifest resource for the landing page:
- toReturn.add(emitLandingPageCacheManifest(context, logger, artifacts));
- return toReturn;
- }
-
- /**
- * Override this method to force the linker to also include more files
- * in the manifest.
- */
- protected String[] otherCachedFiles() {
- return null;
- }
-
- /**
- * Creates the cache-manifest resource specific for the landing page.
- *
- * @param context the linker environment
- * @param logger the tree logger to record to
- * @param artifacts {@code null} to generate an empty cache manifest
- */
- private Artifact<?> emitLandingPageCacheManifest(LinkerContext context,
TreeLogger logger,
- ArtifactSet artifacts)
- throws UnableToCompleteException {
- StringBuilder publicSourcesSb = new StringBuilder();
- StringBuilder staticResoucesSb = new StringBuilder();
-
- if (artifacts != null) {
- // Iterate over all emitted artifacts, and collect all cacheable
artifacts
- for (@SuppressWarnings("rawtypes") Artifact artifact : artifacts) {
- if (artifact instanceof EmittedArtifact) {
- EmittedArtifact ea = (EmittedArtifact) artifact;
- String pathName = ea.getPartialPath();
- if (pathName.endsWith("symbolMap")
- || pathName.endsWith(".xml.gz")
- || pathName.endsWith("rpc.log")
- || pathName.endsWith("gwt.rpc")
- || pathName.endsWith("manifest.txt")
- || pathName.startsWith("rpcPolicyManifest")) {
- // skip these resources
- } else {
- publicSourcesSb.append(pathName + "\n");
- }
- }
- }
-
- String[] cacheExtraFiles = getCacheExtraFiles();
- for (int i = 0; i < cacheExtraFiles.length; i++) {
- staticResoucesSb.append(cacheExtraFiles[i]);
- staticResoucesSb.append("\n");
- }
- }
-
- // build cache list
- StringBuilder sb = new StringBuilder();
- sb.append("CACHE MANIFEST\n");
- sb.append("# Unique id #" + (new Date()).getTime() + "." +
Math.random() + "\n");
- // we have to generate this unique id because the resources can change
but
- // the hashed cache.html files can remain the same.
- sb.append("# Note: must change this every time for cache to
invalidate\n");
- sb.append("\n");
- sb.append("CACHE:\n");
- sb.append("# Static app files\n");
- sb.append(staticResoucesSb.toString());
- sb.append("\n# Generated app files\n");
- sb.append(publicSourcesSb.toString());
- sb.append("\n\n");
- sb.append("# All other resources require the user to be online.\n");
- sb.append("NETWORK:\n");
- sb.append("*\n");
-
- logger.log(TreeLogger.INFO, "Be sure your landing page's <html> tag
declares a manifest:"
- + " <html manifest=" + context.getModuleFunctionName() + "/" +
MANIFEST + "\">");
-
- // Create the manifest as a new artifact and return it:
- return emitString(logger, sb.toString(), MANIFEST);
- }
-
- /**
- * Obtains the extra files to include in the manifest. Ensures the
returned
- * array is not null.
- */
- private String[] getCacheExtraFiles() {
- String[] cacheExtraFiles = otherCachedFiles();
- return cacheExtraFiles == null ?
- new String[0] : Arrays.copyOf(cacheExtraFiles,
cacheExtraFiles.length);
- }
-}
=======================================
---
/trunk/dev/core/test/com/google/gwt/core/linker/SimpleAppCacheLinkerTest.java
Wed May 4 09:12:17 2011
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-package com.google.gwt.core.linker;
-
-import com.google.gwt.core.ext.LinkerContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.ConfigurationProperty;
-import com.google.gwt.core.ext.linker.SelectionProperty;
-import com.google.gwt.core.ext.linker.SyntheticArtifact;
-import com.google.gwt.core.ext.linker.impl.SelectionInformation;
-
-import junit.framework.TestCase;
-
-import java.io.InputStream;
-import java.util.Scanner;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * Tests {@link SimpleAppCacheLinker}
- */
-public class SimpleAppCacheLinkerTest extends TestCase {
- private ArtifactSet artifacts;
- private TreeLogger logger;
-
- @Override
- public void setUp() {
- artifacts = new ArtifactSet();
- artifacts.add(new SelectionInformation("foo", 0, new TreeMap<String,
String>()));
- logger = TreeLogger.NULL;
- }
-
- public void testAddCachableArtifacts() throws UnableToCompleteException {
- SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
-
- // Some cacheable artifact
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.bar", new byte[0]));
-
- ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
-
- assertEquals(3, result.size());
- assertHasOneManifest(result);
- assertTrue(getManifestContents(result).contains("foo.bar"));
- }
-
- public void testNoNonCachableArtifacts() throws
UnableToCompleteException {
- SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
-
- // Some non-cacheable artifacts
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.symbolMap", new
byte[0]));
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.xml.gz", new byte[0]));
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.rpc.log", new byte[0]));
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.gwt.rpc", new byte[0]));
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "rpcPolicyManifest.bar", new
byte[0]));
-
- ArtifactSet result = linker.link(TreeLogger.NULL, new
MockLinkerContext(), artifacts, false);
-
- assertEquals(7, result.size());
- assertHasOneManifest(result);
- assertFalse(getManifestContents(result).contains("symbolMap"));
- assertFalse(getManifestContents(result).contains("xml.gz"));
- assertFalse(getManifestContents(result).contains("rpc.log"));
- assertFalse(getManifestContents(result).contains("gwt.rpc"));
- assertFalse(getManifestContents(result).contains("rpcPolicyManifest"));
- }
-
- public void testAddStaticFiles() throws UnableToCompleteException {
- SimpleAppCacheLinker linker = new OneStaticFileAppCacheLinker();
-
- ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
-
- assertEquals(2, result.size());
- assertHasOneManifest(result);
- assertTrue(getManifestContents(result).contains("aStaticFile"));
- }
-
- public void testEmptyManifestDevMode() throws UnableToCompleteException {
- // No SelectionInformation artifact
- artifacts = new ArtifactSet();
-
- SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
-
- // Some cacheable artifact
- artifacts.add(new
SyntheticArtifact(SimpleAppCacheLinker.class, "foo.bar", new byte[0]));
-
- ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, false);
-
- assertHasOneManifest(result);
- assertFalse(getManifestContents(result).contains("foo.bar"));
- }
-
- public void testManifestOnlyOnLastPass() throws
UnableToCompleteException {
- SimpleAppCacheLinker linker = new SimpleAppCacheLinker();
-
- ArtifactSet result = linker.link(logger, new MockLinkerContext(),
artifacts, true);
-
- assertEquals(artifacts, result);
-
- result = linker.link(logger, new MockLinkerContext(), artifacts,
false);
-
- assertEquals(2, result.size());
- assertHasOneManifest(result);
- }
-
- private void assertHasOneManifest(ArtifactSet artifacts) {
- int manifestCount = 0;
- for (SyntheticArtifact artifact :
artifacts.find(SyntheticArtifact.class)) {
- if ("appcache.nocache.manifest".equals(artifact.getPartialPath())) {
- assertEquals("appcache.nocache.manifest",
artifact.getPartialPath());
- manifestCount++;
- }
- }
- assertEquals(1, manifestCount);
- }
-
- private SyntheticArtifact getManifest(ArtifactSet artifacts) {
- for (SyntheticArtifact artifact :
artifacts.find(SyntheticArtifact.class)) {
- if ("appcache.nocache.manifest".equals(artifact.getPartialPath())) {
- assertEquals("appcache.nocache.manifest",
artifact.getPartialPath());
- return artifact;
- }
- }
- fail("Manifest not found");
- return null;
- }
-
- private String getManifestContents(ArtifactSet artifacts) throws
UnableToCompleteException {
- return getArtifactContents(getManifest(artifacts));
- }
-
- private String getArtifactContents(SyntheticArtifact artifact) throws
UnableToCompleteException {
- InputStream is = artifact.getContents(logger);
- String contents = new Scanner(is).useDelimiter("\\A").next();
- return contents;
- }
-
- public static class OneStaticFileAppCacheLinker extends
SimpleAppCacheLinker {
-
- @Override
- protected String[] otherCachedFiles() {
- return new String[] {"aStaticFile"};
- }
- }
-
- private static class MockLinkerContext implements LinkerContext {
-
- public SortedSet<ConfigurationProperty> getConfigurationProperties() {
- return new TreeSet<ConfigurationProperty>();
- }
-
- public String getModuleFunctionName() {
- return null;
- }
-
- public long getModuleLastModified() {
- return 0;
- }
-
- public String getModuleName() {
- return null;
- }
-
- public SortedSet<SelectionProperty> getProperties() {
- return new TreeSet<SelectionProperty>();
- }
-
- public boolean isOutputCompact() {
- return true;
- }
-
- public String optimizeJavaScript(TreeLogger logger, String jsProgram) {
- return jsProgram;
- }
- }
-}
=======================================
--- /trunk/samples/mobilewebapp/README-MAVEN.txt Wed Jun 1 07:45:02 2011
+++ /trunk/samples/mobilewebapp/README-MAVEN.txt Wed Jun 1 09:26:16 2011
@@ -45,6 +45,9 @@
Select Java Build Path and click the Projects tab
Click Add..., select gwt-user, and click OK
+
+GWT developers can also use tools/scripts/maven_script.sh to push their
+own GWT jars into their local maven repo.
-- Option B: Build from the command line with Maven --
=======================================
---
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/MobileWebApp.gwt.xml
Wed Jun 1 07:45:02 2011
+++
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/MobileWebApp.gwt.xml
Wed Jun 1 09:26:16 2011
@@ -8,7 +8,9 @@
<inherits name='com.google.gwt.editor.Editor'/>
<inherits name='com.google.gwt.sample.mobilewebapp.FormFactor'/>
<inherits name='com.google.web.bindery.requestfactory.RequestFactory'/>
+
<inherits name='com.google.gwt.sample.gaerequest.GaeRequest'/>
+ <inherits name='com.google.gwt.sample.core.Core'/>
<!-- Specify the app entry point class. -->
<entry-point
class='com.google.gwt.sample.mobilewebapp.client.MobileWebApp'/>
=======================================
---
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/linker/AppCacheLinker.java
Wed Jun 1 07:45:02 2011
+++
/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/linker/AppCacheLinker.java
Wed Jun 1 09:26:16 2011
@@ -16,12 +16,15 @@
package com.google.gwt.sample.mobilewebapp.linker;
import com.google.gwt.core.ext.linker.Shardable;
-import com.google.gwt.core.linker.SimpleAppCacheLinker;
+import com.google.gwt.sample.core.linker.SimpleAppCacheLinker;
/**
- * A custom linker that generates an app cache manifest with the
- * files generated by the GWT compiler and the static files used
- * by this application.
+ * A custom linker that generates an app cache manifest with the files
generated
+ * by the GWT compiler and the static files used by this application.
+ * <p>
+ * Before using this approach with production code be sure that you
understand
+ * the limitations of {@link SimpleAppCacheLinker}, namely that it sends
all
+ * permutations to the client.
*
* @see SimpleAppCacheLinker
*/
=======================================
--- /trunk/user/test/com/google/gwt/core/ext/LinkerSuite.java Wed May 4
09:12:17 2011
+++ /trunk/user/test/com/google/gwt/core/ext/LinkerSuite.java Wed Jun 1
09:26:16 2011
@@ -20,7 +20,6 @@
import com.google.gwt.core.ext.test.CrossSiteIframeLinkerTest;
import com.google.gwt.core.ext.test.IFrameLinkerTest;
import com.google.gwt.core.ext.test.XSLinkerTest;
-import com.google.gwt.core.linker.SimpleAppCacheLinkerTest;
import com.google.gwt.junit.tools.GWTTestSuite;
import junit.framework.Test;
@@ -41,7 +40,6 @@
suite.addTestSuite(SelectionScriptJavaScriptTest.class);
suite.addTestSuite(SelectionScriptLinkerUnitTest.class);
suite.addTestSuite(XSLinkerTest.class);
- suite.addTestSuite(SimpleAppCacheLinkerTest.class);
/*
* Note: Single-script linking is disabled by default, because it only
works
* when the test is run for a single permutation.
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors