用Maven进行GWT中的注释处理

时间:2011-08-05 21:21:49

标签: android gwt maven requestfactory

我正在尝试让我的Android应用程序使用与我的gwt应用程序相同的requestfactories与服务器进行通信。我使用maven来构建android应用程序和gwt应用程序。 在android上进行请求工厂调用时,我得到了异常:

08-05 23:04:33.501: ERROR/AndroidRuntime(22839): java.lang.RuntimeException: No token manifest found.  Did the RequestFactory annotation processor run? Check classpath for META-INF/requestFactory/typeTokens file and ensure that your proxy types are compiled with the requestfactory-apt.jar on javac's classpath.
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.google.web.bindery.requestfactory.vm.impl.TypeTokenResolver.loadFromClasspath(TypeTokenResolver.java:104)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.google.web.bindery.requestfactory.vm.InProcessRequestFactory.<init>(InProcessRequestFactory.java:82)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.google.web.bindery.requestfactory.vm.RequestFactorySource.create(RequestFactorySource.java:43)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.myproject.core.android.helper.Util.getRequestFactory(Util.java:97)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.myproject.core.android.Login$1.onClick(Login.java:54)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.view.View.performClick(View.java:2501)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.view.View$PerformClick.run(View.java:9107)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.os.Handler.handleCallback(Handler.java:587)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.os.Looper.loop(Looper.java:130)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at android.app.ActivityThread.main(ActivityThread.java:3835)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at java.lang.reflect.Method.invokeNative(Native Method)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at java.lang.reflect.Method.invoke(Method.java:507)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-05 23:04:33.501: ERROR/AndroidRuntime(22839):     at dalvik.system.NativeStart.main(Native Method)

我使用java 1.6进行构建。我的gwt版本是2.4(rc1)。我尝试使用maven-processor-plugin并导入requestfactory-apt。但不知何故,maven处理器插件似乎找不到处理器。不确定配置应该如何。

我有:

    <plugin>
      <groupId>org.bsc.maven</groupId>
      <artifactId>maven-processor-plugin</artifactId>
      <version>2.0.4-SNAPSHOT</version>
       <executions>
        <execution>
           <id>process</id>
          <goals>
            <goal>process</goal>
          </goals>
          <phase>generate-sources</phase> 
          <<configuration>
            <processors>
               <processor>com.google.gwt.requestfactory-apt</processor>
            </processors> 
          </configuration>  
        </execution>
      </executions>
   </plugin>

注释文件夹在我的目标文件夹中创建,但它是空的。有谁知道问题可能是什么?您需要哪些其他信息?

更新 我将版本更改为2.0.3-SNAPSHOT。现在我明白了:

[INFO] Source directory: E:\Eclipse\Eclipse3.7\android\target\META-INF\requestFactory added
[INFO] javac option: -cp
[INFO] javac option: C:\profiles\....
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.google.web.bindery.requestfactory.apt.RfApt
[INFO] javac option: -d
[INFO] javac option: E:\Eclipse\Eclipse3.7\android\target\classes
[INFO] javac option: -s
[INFO] javac option: E:\Eclipse\Eclipse3.7\android\target\META-INF\requestFactory

但此文件夹中没有文件。当我添加:

<compilerArguments>
             -Averbose=true</compilerArguments>   
          </configuration> 

到我的pom。我收到错误消息:

diagnostic warning: The following options were not recognized by any processor: '[verbose]'

现在我再次陷入困境: - /

2 个答案:

答案 0 :(得分:0)

处理器类的名称为com.google.web.bindery.requestfactory.apt.RfApt,但应自动发现,而无需显式的<configuration>部分。

此外,示例代码中有<<configuration>,是否存在复制粘贴错误?

答案 1 :(得分:0)

这可能对你有帮助, RequestFactoryInterfaceValidation

尝试使用RequestFactory ValidationTool