Eclipse 启用注释处理导致错误
Eclipse Enabling Annotation Processing leads to Errors
我有 Eclipse Luna 和一个标准的 GWT Web 应用程序项目。我尝试启用注释处理,使 Dagger2 正常工作。这是我的项目特定配置:
点击应用后,Eclipse 显示以下错误:
如何解决这个错误?
编辑: 我创建了一个演示项目来演示问题:https://github.com/confile/GWT-Dagger2-Demo
我查看了dagger2 编译器的pom.xml 并添加了进一步的依赖项,但仍然没有任何进展。这是我所做的:
编辑:我尝试将 dagger2 编译器 jar 与来自 here 的依赖项一起使用:
当我进行 GWT 编译时,出现以下错误:
Compiling module test.GWTT
Tracing compile failure path for type 'test.client.test2.Dagger_MyWidgetGinjector'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/Dagger_MyWidgetGinjector.java'
[ERROR] Line 9: No source code is available for type javax.inject.Provider<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'test.client.test2.MyWidgetClientModule$$ProvideSomeServiceFactory'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/MyWidgetClientModule$$ProvideSomeServiceFactory.java'
[ERROR] Line 7: No source code is available for type dagger.Factory<T>; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
我的 Java 构建路径中有以下库:
编辑Gradle:我也试过在eclipse中用gradle激活注解处理。这是我的 gradle build.gradle 文件:
apply plugin: 'apt'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'gwt'
apply plugin: 'jetty'
sourceCompatibility = 1.7
version = '1.0'
eclipse {
classpath {
downloadSources=true
downloadJavadoc=true
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.jimdo.gradle:gradle-apt-plugin:0.5-SNAPSHOT'
}
}
repositories {
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT:jar-with-dependencies'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava-gwt:18.0'
compile 'javax.inject:javax.inject:1'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
}
gwt {
gwtVersion='2.7.0'
logLevel = 'INFO'
minHeapSize = "512M";
maxHeapSize = "1024M";
compiler {
strict = true;
}
modules 'test.GWTT'
}
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
args '-XjsInteropMode', 'JS'
}
在`gradle构建``之后我得到:
/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/src/main/java/test/client/GWTT.java:16: error: cannot find symbol
MyWidgetGinjector injector = Dagger_MyWidgetGinjector.create();
^
symbol: variable Dagger_MyWidgetGinjector
我可以看到 Dagger_MyWidgetGinjector.java
已在 build/source/apt/test/client/test2/
中创建。我仍然需要弄清楚如何添加新生成的源,以便 eclipse 使用刷新依赖项找到它?
Dagger 2 还没有屏蔽它的依赖项,因此您必须将所有 dagger-compiler 依赖项添加到工厂路径。
编辑: 有一个包含所有依赖项的 jar-with-dependencies
风格,让像您这样不使用所谓的 managed 的用户更容易使用dependencies,代价是在使用具有相同传递依赖关系的其他注释处理器时可能发生冲突。理想情况下,dagger-compiler 应该 shade 它的依赖关系以产生无冲突的 uber-jar;我相信这最终会到来。
我有 Eclipse Luna 和一个标准的 GWT Web 应用程序项目。我尝试启用注释处理,使 Dagger2 正常工作。这是我的项目特定配置:
点击应用后,Eclipse 显示以下错误:
如何解决这个错误?
编辑: 我创建了一个演示项目来演示问题:https://github.com/confile/GWT-Dagger2-Demo
我查看了dagger2 编译器的pom.xml 并添加了进一步的依赖项,但仍然没有任何进展。这是我所做的:
编辑:我尝试将 dagger2 编译器 jar 与来自 here 的依赖项一起使用:
当我进行 GWT 编译时,出现以下错误:
Compiling module test.GWTT
Tracing compile failure path for type 'test.client.test2.Dagger_MyWidgetGinjector'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/Dagger_MyWidgetGinjector.java'
[ERROR] Line 9: No source code is available for type javax.inject.Provider<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'test.client.test2.MyWidgetClientModule$$ProvideSomeServiceFactory'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/MyWidgetClientModule$$ProvideSomeServiceFactory.java'
[ERROR] Line 7: No source code is available for type dagger.Factory<T>; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
我的 Java 构建路径中有以下库:
编辑Gradle:我也试过在eclipse中用gradle激活注解处理。这是我的 gradle build.gradle 文件:
apply plugin: 'apt'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'gwt'
apply plugin: 'jetty'
sourceCompatibility = 1.7
version = '1.0'
eclipse {
classpath {
downloadSources=true
downloadJavadoc=true
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.jimdo.gradle:gradle-apt-plugin:0.5-SNAPSHOT'
}
}
repositories {
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT:jar-with-dependencies'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava-gwt:18.0'
compile 'javax.inject:javax.inject:1'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
}
gwt {
gwtVersion='2.7.0'
logLevel = 'INFO'
minHeapSize = "512M";
maxHeapSize = "1024M";
compiler {
strict = true;
}
modules 'test.GWTT'
}
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
args '-XjsInteropMode', 'JS'
}
在`gradle构建``之后我得到:
/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/src/main/java/test/client/GWTT.java:16: error: cannot find symbol
MyWidgetGinjector injector = Dagger_MyWidgetGinjector.create();
^
symbol: variable Dagger_MyWidgetGinjector
我可以看到 Dagger_MyWidgetGinjector.java
已在 build/source/apt/test/client/test2/
中创建。我仍然需要弄清楚如何添加新生成的源,以便 eclipse 使用刷新依赖项找到它?
Dagger 2 还没有屏蔽它的依赖项,因此您必须将所有 dagger-compiler 依赖项添加到工厂路径。
编辑: 有一个包含所有依赖项的 jar-with-dependencies
风格,让像您这样不使用所谓的 managed 的用户更容易使用dependencies,代价是在使用具有相同传递依赖关系的其他注释处理器时可能发生冲突。理想情况下,dagger-compiler 应该 shade 它的依赖关系以产生无冲突的 uber-jar;我相信这最终会到来。