2017-06-09 1 views
1

J'ai un éditeur de liens personnalisé pour générer un fichier manifeste qui fonctionnait très bien jusqu'à GWT 2.7. Quand je suis passé à GWT 2.8, j'ai remarqué qu'il a cessé de générer le fichier myapp.manifest.GWT 2.8 ne peut pas faire fonctionner l'éditeur de liens personnalisé

Sur module.gwt.xml J'ai

<?xml version="1.0" encoding="UTF-8"?> 
<module> 
    <inherits name="com.google.gwt.user.User" /> 
    <inherits name="com.google.gwt.core.Core" /> 

    <source path="client" /> 
    <source path="shared" /> 
    <source path="constants" /> 

    <entry-point class="br.com.universo.client.AppStart" /> 

    <extend-property name="locale" values="pt" /> 
    <extend-property name="locale" values="en" /> 
    <set-property-fallback name="locale" value="en" /> 

    <define-linker class="br.com.universo.AppManifest" 
     name="manifest" /> 
    <add-linker name="manifest" /> 


</module> 

Ceci est le journal de compilation sur 2,7

[INFO] --- gwt-maven-plugin:2.7.0:compile (default) @ universo-bootstrap --- 
    [INFO] auto discovered modules [br.com.universo.core.appCore, br.com.universo.app] 
    [INFO] br.com.universo.core.appCore has no EntryPoint - compilation skipped 
    [INFO] Compiling module br.com.universo.app 
    [INFO] Ignored 7 units with compilation errors in first pass. 
    [INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors. 
    [INFO] Compiling 6 permutations 
    [INFO]  Compiling permutation 0... 
    [INFO]  Process output 
    [INFO]   Compiling 
    [INFO]    Compiling permutation 1... 
    [INFO]  Compiling permutation 2... 
    [INFO]   Compiling 
    [INFO]    Compiling permutation 3... 
    [INFO]  Compiling permutation 4... 
    [INFO]  Compiling permutation 5... 
    [INFO] Compile of permutations succeeded 
    [INFO] Compilation succeeded -- 165.867s 
    [INFO] MyApp OffLine Linker started 
    [INFO] MyApp OffLine Linker ended 
    [INFO] Linking into /universo/universo-bootstrap/target/universo-bootstrap-1.0-SNAPSHOT/app 
    [INFO] Link succeeded 
    [INFO] Linking succeeded -- 1.239s 

Sur GWT 2.8 J'utilise tbroyer gwt maven archetype modular-webapp. La classe de liaison a été défini dans le module client, mais sur un emballage extérieur

<source path="client" /> 

et journal de compilation je ne vois pas les lignes:

[INFO] MyApp OffLine Linker started 
[INFO] MyApp OffLine Linker ended 

que je suppose indique qu'il est pas appelé ?

[INFO] --- gwt-maven-plugin:1.0-rc-7:compile (default-compile) @ universo-client --- 
[INFO] Compiling module br.com.universo.app 
[INFO] Compiling 9 permutations 
[INFO]  Compiling permutation 0... 
[INFO]  [WARN] Namespace option is not compatible with CodeSplitter, turning it off. 
[INFO]  Compiling permutation 1... 
[INFO]  Compiling permutation 2... 
[INFO]  Compiling permutation 3... 
[INFO]  Compiling permutation 4... 
[INFO]  Compiling permutation 5... 
[INFO]  Compiling permutation 6... 
[INFO]  Compiling permutation 7... 
[INFO]  Compiling permutation 8... 
[INFO] Compile of permutations succeeded 
[INFO] Compilation succeeded -- 104.171s 
[INFO] Linking into /universo/universo-client/target/universo-client-1.0-SNAPSHOT/app 
[INFO] Link succeeded 
[INFO] Linking succeeded -- 1.818s 

La classe Linker AppManifest.java

package br.com.universo; 

import java.util.Date; 

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.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.Shardable; 

@Shardable 
@LinkerOrder(Order.POST) 
public class AppManifest extends AbstractLinker { 

    static final String[] cache = new String[] { 
     "# Css" 
     , "/css/base.css" 
     , "/css/feedback.css" 
     , "/css/layout.css" 
     , "/css/prettyPhoto.css" 
     , "/css/shortcodes.css" 
     , "/css/slideshow.css" 
     , "/css/style.css" 
    }; 

    static final String[] network = new String[] { 
     "*" 
    }; 


    @Override 
    public String getDescription() { 
     return "MyApp OffLine Linker"; 
    } 

    @Override 
     public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException { 
     System.out.println("MyApp OffLine Linker started"); 
     ArtifactSet artifactset = new ArtifactSet(artifacts); 

     StringBuilder builder= new StringBuilder("CACHE MANIFEST\n"); 
     builder.append("# Cache Version " + new Date() + "\n\n"); 
     builder.append("CACHE:\n"); 

     for (String line : cache) { 
      builder.append(line + "\n");    
     } 
     builder.append("\n\n"); 

     for(EmittedArtifact emitted: artifacts.find(EmittedArtifact.class)) 
     { 
      if(emitted.getPartialPath().endsWith(".symbolMap"))continue; 
      if(emitted.getPartialPath().endsWith(".txt"))continue; 
      builder.append(emitted.getPartialPath()).append("\n"); 
     } 
     builder.append("\n\n"); 

     builder.append("NETWORK:\n"); 
     for (String line : network) { 
      builder.append(line + "\n");    
     } 
     builder.append("\n\n"); 

     builder.append("FALLBACK:\n"); 

     EmittedArtifact manifest = emitString(logger, builder.toString(), "myapp.manifest"); 
     artifactset.add(manifest); 
     System.out.println("MyApp OffLine Linker ended"); 
     return artifactset; 
     } 

} 

Toute aide est bien appréciée!

+0

Quelles sont les options que vous avez définies dans votre fichier pom.xml pour gwt-maven-plugin, et le fichier pom.xml a-t-il changé du tout sauf pour changer de version? Je n'ai pas connu d'autres linkers se brisant comme ça ... –

+0

Colin, on dirait que l'API a changé et je n'ai pas fait attention, pas sûr. Mais je l'ai fait fonctionner en surchargeant les deux signatures pour le lien de méthode, le lien ArtifactSet (TreeLogger logger, Contexte LinkerContext, artefacts ArtifactSet, boolean onePermutation), que je n'avais pas sur la version précédente et le lien ArtifactSet (TreeLogger logger, Contexte LinkerContext, artefacts ArtifactSet) –

Répondre

0

J'ai finalement eu le travail en changeant mon AppManifast.java. J'ai remarqué sur la documentation actuelle que lorsque vous utilisez l'annotation @Shardable vous devez remplacer l'autre signature de la méthode de liaison, alors j'ai ajouté les lignes suivantes à la classe:

@Override 
public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation) throws UnableToCompleteException { 
    return link(logger, context, artifacts); 
} 

Il m'a fallu une éternité pour trouver ...