代码之家  ›  专栏  ›  技术社区  ›  Alexander Rühl

多模块项目中的奇怪编译器行为

  •  2
  • Alexander Rühl  · 技术社区  · 6 年前

    我有以下项目结构(在Windows 10 x64上):

    root-folder: containing parent pom, defining 1.8 for build and group/version, listing sub1, sub2, sub3 as modules
    sub1: first module (jar), refering to parent pom
    sub2: second module (jar), refering to parent pom, sub1 as dependency
    sub3: third module (jar), refering to parent pom, sub2 as dependency
    

    现在,当我做一个 mvn clean install 在每个模块中,按照上面声明的顺序,每件事情都构建良好。

    但是,当我做一个 MVN清洁安装 在父POM上,sub1和sub2构建良好,在sub3中,我得到了不祥的构建错误。

    An exception has occurred in the compiler (1.8.0_181). Please file a bug against the Java compiler via the Java bug reporting page [..]
    java.lang.IllegalAccessError: tried to access class com.sun.tools.javac.tree.JCTree$1 from class com.sun.tools.javac.tree.JCTree$JCLiteral
            at com.sun.tools.javac.tree.JCTree$JCLiteral.getValue(JCTree.java:2044)
            at com.sun.tools.javac.parser.JavacParser.merge(JavacParser.java:1034)
    [..]
    

    我更新到最新的JDK8和Maven,但仍然有相同的错误。我确认java_home和path设置正确(因为系统上有更新的jdk)。我也通过maven-opts增加了maven的记忆,但也没有改变。

    有没有人有过类似的行为,能给我一个解决办法,或者至少提出一个想法,什么会导致这种情况?手动编译或让Maven来编译每一个代码时有什么不同?依赖性是一个问题,还是更可能是我自己的代码中的某个问题?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Karol Dowbecki    6 年前

    mvn clean install -pl :sub3 -am sub3

    https://github.com/ztellman/virgil/issues/16

    mvn dependency:tree

    Maven Compiler Plugin compile:compile properties

     maven.compiler.compilerReuseStrategy=alwaysNew
     maven.compiler.fork=true