RuntimeException无法编译的源代码 - maven shade uber jar

时间:2016-04-11 21:19:51

标签: java maven jar gerrit maven-shade-plugin

我正在为Gerrit编写一个插件,根据Gerrit documentation的要求之一是该插件必须将所有依赖项打包在jar中。他们建议使用我所使用的Maven Shade plugin

在我的pom.xml中,我添加了对com.mypackage和shade插件的依赖。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <finalName>uber-${artifactId}-${version}</finalName>
    </configuration>
</plugin>

所以我运行了mvn clean package并生成了uber-myplugin.jar。如果我检查jar xf uber-mypugin.jar的输出,我的依赖.class文件就在那里。然而,当我尝试使用我的插件时,我得到了

java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:206)
......
Caused by: java.lang.ExceptionInInitializerError
    at com.googlesource.gerrit.plugins.testplugin.CommitValidator$$FastClassByGuice$$a5e3cd18.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
...
Caused by: java.lang.RuntimeException: Uncompilable source code - package com.mypackage does not exist
    at com.googlesource.gerrit.plugins.testplugin.CommitValidator.<clinit>(CommitValidator.java:32)

我在命令行上维护了mvn,所以这不应该与IDE有任何关系。

0 个答案:

没有答案