gpt4 book ai didi

java - GWT 2.8 无法使自定义链接器工作

转载 作者:太空宇宙 更新时间:2023-11-04 11:25:05 26 4
gpt4 key购买 nike

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

在 module.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 archetype modular-webapp 。链接器类在客户端模块下定义,但在外部包上

<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 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;
}

}

非常感谢任何帮助!

最佳答案

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

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

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

关于java - GWT 2.8 无法使自定义链接器工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44466505/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com