java.lang.IllegalStateException:endPosTable已设置

api*_*ang 16 maven-2 compiler-errors java-8 dagger-2

试图建立一个alexa(亚马逊:回声)技能组合.同时,尝试使用这种经验作为通过匕首2依赖注入的学习测试平台.但是,使用maven-2 cmd构建包:

mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. 
Run Code Online (Sandbox Code Playgroud)

生成具有完整依赖项的zip jar会产生以下异常跟踪:

[INFO] ------------------------------------------------------------------------
[INFO] Building Echo Device Client 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ echo-device-client ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/apil.tamang/Dropbox/Git/echo-device-client/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ echo-device-client ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 46 source files to /Users/apil.tamang/Dropbox/Git/echo-device-client/target/classes
An exception has occurred in the compiler (1.8.0_60). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.IllegalStateException: endPosTable already set
        at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
        at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
        at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
        at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:892)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
Run Code Online (Sandbox Code Playgroud)

初始编译很好,所有测试都运行并成功执行.我觉得在"连接"事物向南的依赖关系时.请查看此文件以查看构建期间的控制台输出.

我的问题是,如果尝试使用不同的方式生成依赖项是值得的.我为此目的不太了解maven.是否有可以使用的补丁或其他东西?你认为甚至可以提出一个解决方法吗?我希望能够继续使用dagger 2框架来构建这个项目.

Hol*_*ger 13

错误报告中描述了该问题JDK-8067747:

(作者Jan Lahoda)

据我所知,这个bug存在两个方面:

  1. 它碰到异常的javac错误.我正在研究这个问题,但请注意,当修复此问题时,javac将不会编译输入,它会从Filer抛出一个适当的异常(见下文).

  2. 似乎是一个maven bug:当项目使用"clean install"编译时,注释处理器将生成一个源文件到"target/generated-sources/annotations".增量编译完成后,此生成的文件将作为输入传递给javac,注释处理器将尝试再次生成它,这是不允许的.

这意味着当maven bug被修复时,javac用不适当的异常报告问题的bug变得无关紧要.但是,考虑到Maven 2的生命终结的实际日期,我怀疑你可以期待找到它的修复或补丁.

  • tl; dr - `mvn clean` (8认同)
  • 我在 Maven 3.6.2 上遇到过这个问题。而`mvn clean`对他没有任何影响。最后只有 `&lt;useIncrementalCompilation&gt;false&lt;/useIncrementalCompilation&gt;` 帮助了我。 (2认同)

laf*_*ste 10

本期所述,解决方法是禁用useIncrementalCompilation

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>

    <configuration>
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)