1

运行 Maven Shade 插件时,出现以下错误。我该如何调试呢?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (make-shade) on project csprocessor-client: Error creating shaded jar: Unexpected end of ZLIB input stream -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (make-shade) on project csprocessor-client: Error creating shaded jar: Unexpected end of ZLIB input stream
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: Unexpected end of ZLIB input stream
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:551)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:411)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:188)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:174)
    at org.apache.maven.plugins.shade.DefaultShader.addRemappedClass(DefaultShader.java:259)
    at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:151)
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:484)
    ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
4

2 回答 2

1

事实证明,使用 m2eclipse 插件,您实际上可以在执行 maven 插件时对其进行调试。为此,您需要选择要单步执行的代码,您可以通过在 Maven 运行配置中设置调试输出选项来实现。您还需要设置Resolve Workspace artifacts选项。

在此处输入图像描述

使用这两个选项,我可以单击错误中列出的文件位置(在本例中为 ZipFile.java:411),设置断点,然后使用Debug As > Maven Build在调试模式下运行 Maven 构建。一旦断点被​​命中,我就可以知道哪个文件导致了错误,并使用JAR 命令重新打包它。即使有问题的 JAR 文件可以使用 GUI 存档工具打开,一旦使用 JAR 命令重新打包,我也可以成功运行 Maven Shade plgin。

于 2012-10-02T09:30:09.327 回答
0

仅供参考,如果这是由下载期间损坏的 JAR 引起的,强制重新下载的快速方法是mvn dependency:purge-local-repository着色项目中运行。这将从本地 Maven 存储库中删除项目的所有依赖项(直接和传递)并重新下载它们。

于 2017-08-23T13:30:39.013 回答