Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.gwtbootstrap3.extras.cachemanifest;
   * #%L
   * GwtBootstrap3
   * %%
   * Copyright (C) 2013 GwtBootstrap3
   * %%
   * 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
  * 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.
  * #L%
 import java.util.Date;
 import java.util.Set;
Offline linker performs the task of generating a valid cache manifest file when you compile your GWT application.

Static resources that are needed (outside of the compile unit) require specific inclusion. These files would typically be index.html, css files or any resources not included within the GWT application. These files are included through the cachemanifest_static_files property added to your module.gwt.xml file. The path is relative to manifest, so include a full path if you include resources outside of the apps path.

 <extend-configuration-property name="cachemanifest_static_files" value="/index.html" />

To activate the linker, the following configuration is included in your GWT module definition (module.gwt.xml file) as follows:

 <inherits name='org.gwtbootstrap3.extras.cachemanifest.Offline'/>
 <add-linker name="offline" />

Finally, include the cache manifest file within the html page that loads your GWT application, as follows:

 <!doctype html>
  <html manifest="<modulename>/appcache.manifest">

Grant Slender
 public class Offline extends AbstractLinker {
     private static final String CACHEMANIFEST_STATIC_FILES_PROPERTY = "cachemanifest_static_files";
     public String getDescription() {
         return "Offline Linker";
     public ArtifactSet link(final TreeLogger loggerfinal LinkerContext contextfinal ArtifactSet artifactsthrows UnableToCompleteException {
         final ArtifactSet artifactset = new ArtifactSet(artifacts);
         final HashSet<Stringresources = new HashSet<String>();
         for (final EmittedArtifact emitted : artifacts.find(EmittedArtifact.class)) {
             if (skipArtifact(emitted))
        final SortedSet<ConfigurationPropertystaticFileProperties = context.getConfigurationProperties();
        for (final ConfigurationProperty configurationProperty : staticFileProperties) {
            final String name = configurationProperty.getName();
            if (.equals(name)) {
                for (final String value : configurationProperty.getValues()) {
        final String manifestString = buildManifestContents(resources);
        if (manifestString != null) {
            final EmittedArtifact manifest = emitString(loggermanifestString"appcache.manifest");
        return artifactset;
    private boolean skipArtifact(final EmittedArtifact emitted) {
        if (emitted.getVisibility().matches(.))
            return true;
        final String pathName = emitted.getPartialPath();
        if (pathName.endsWith("symbolMap"))
            return true;
        if (pathName.endsWith(".xml.gz"))
            return true;
        if (pathName.endsWith("rpc.log"))
            return true;
        if (pathName.endsWith("gwt.rpc"))
            return true;
        if (pathName.endsWith("manifest.txt"))
            return true;
        if (pathName.startsWith("rpcPolicyManifest"))
            return true;
        if (pathName.startsWith("soycReport"))
            return true;
        if (pathName.endsWith(".cssmap"))
            return true;
        return false;
    private String buildManifestContents(final Set<Stringresources) {
        if (resources == null)
            return null;
        final StringBuilder sb = new StringBuilder();
        sb.append("CACHE MANIFEST\n");
        sb.append("# Version: " + (new Date()).getTime() + "." + Math.random() + "\n");
        for (final String resourcePath : resources) {
            sb.append(resourcePath + "\n");
        return sb.toString();
New to GrepCode? Check out our FAQ X