GWT 2.8 无法使自定义链接器正常工作



我有一个自定义链接器来生成一个清单文件,该文件曾经在GWT 2.7之前可以正常工作。 当我更改为GWT 2.8时,我注意到它停止生成文件myapp.manifest。

在模块.gwt上.xml我有

<?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>

这是 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

在GWT 2.8上,我正在使用tbroyer gwt maven原型模块化网络应用程序。 链接器类在客户端模块下定义,但在外部的包上

<source path="client" />

在编译日志上,我没有看到以下行:

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

我想这表明它没有被调用?

[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

链接器类 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 MANIFESTn");
builder.append("# Cache Version " + new Date() + "nn");
builder.append("CACHE:n");
for (String line : cache) {
builder.append(line + "n");            
}
builder.append("nn");
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("nn");
builder.append("NETWORK:n");
for (String line : network) {
builder.append(line + "n");            
}
builder.append("nn");
builder.append("FALLBACK:n");
EmittedArtifact manifest = emitString(logger, builder.toString(), "myapp.manifest");
artifactset.add(manifest);
System.out.println("MyApp OffLine Linker ended");
return artifactset;
}
}

任何帮助都非常感谢!

我终于让它改变了我的AppManifast.java。 我在当前文档中注意到,使用@Shardable注释时,您必须覆盖其他链接方法签名,因此我在类中添加了以下行:

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

我花了很长时间才发现...

最新更新