maven-shade-plugin报告:创建阴影jar时出错:... target / classes(是一个目录) [英] maven-shade-plugin reports: Error creating shaded jar: ...target/classes (Is a directory)

查看:1171
本文介绍了maven-shade-plugin报告:创建阴影jar时出错:... target / classes(是一个目录)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在eclipse中使用m2eclipse工具在为 Maven Shade Plugin ,构建失败,并显示以下错误消息:

When running a Maven build in eclipse using the m2eclipse tooling for a project that is configured for the Maven Shade Plugin, the build fails with the following error message:

无法执行目标org.apache.maven .plugins:maven-shade-plugin:2.4.3:项目xxx上的阴影(默认):创建阴影jar的错误:/.../project/target/classes(是目录) - > [帮助1]

我尝试了不同版本的Shade插件,并尝试使用不同的Java版本(6,7,8 )。所有这些都导致相同的错误。

I tried different versions of the Shade plugin and tried with different Java versions (6,7,8). All lead to the same error.

解决方法:

a href =https://stackoverflow.com/a/31330682/270662>此问题提供了一种解决方法:该错误仅在选项 Resolve Workspace Artifacts 被选中。如果未选择此选项,则构建运行正常。

The solution for this question provides a workaround: The error only occurs if the option Resolve Workspace Artifacts is selected. If this option is not selected, the build runs fine.

(但是,这并不能解决问题,因为使用启用的工作区分辨率构建项目通常非常有用)

(However, this does not solve the problem since it is often very useful to build projects with enabled workspace resolution).

推荐答案


通过启用工作区分辨率构建项目通常非常有用

it is often very useful to build projects with enabled workspace resolution

我曾经认为一样...显然,能够从另一个项目建立项目是非常有用的位于当前工作区。然而,我很快就与Eclipse,m2eclipse和Maven进入了一场噩梦。

I used to think the same... Obviously, it was pretty useful to be able to build project right from another project located in the current workspace. However, I quickly entered a nightmare with Eclipse, m2eclipse and Maven.

一方面,Maven应该在存储库中查找项目依赖关系(本地,中央.. )。另一方面,m2eclipse诱惑Maven使得它相信位于Eclipse工作空间中的项目是一个众所周知的Maven位置(即存储库)的依赖。

On one hand, Maven is supposed to find the project dependencies in a repository (local, central ...). On the other hand, m2eclipse "lures" Maven making it believe that a project located in the Eclipse workspace is a dependency in a well known Maven place (ie a repository).

这个m2eclipse魔术在某些情况下非常棒,但在其他情况下,它只是显而易见(maven shade插件就是一个例子)。您还注意到,默认情况下, Resolve Workspace Artifacts 选项不会被激活?

This m2eclipse magic works great in some cases but in others... it just plainly fails (maven shade plugin is an example). Did you also notice that the option Resolve Workspace Artifacts is not activated by default?

为了逃避nigthmare,我发现从始终从存储库获取我的项目依赖项很有用。如果我的项目A依赖于我的工作区中的另一个项目B,我只需在本地存储库中安装B(右键单击项目B,运行为> Maven安装,这就是)。

To escape the nigthmare, I found it useful to always fetch my projects dependencies from a repository. If my project A depends on another project B in my workspace, I just install B in the local repository (Right click on the project B, Run as > Maven install. That's all).

我可以看到这个解决方法有三个优点:

I can see three advantages with this workaround:


  • 没有更多的恶梦

  • 没有m2eclipse魔法涉及

  • 完整的标准和常规的Maven方式荣幸

你可以看到这种方法是一个小自由的食者。如果您仍然想要使用漂亮的选项 Resolve Workspace Artifacts 发送问题到m2eclipse团队。不要忘记准备一个重现问题的示例项目。

You can see this approach as a little freedom eater. If you still really want to go with the nifty option Resolve Workspace Artifacts, send an issue to the m2eclipse team. Don't forget to prepare a sample project reproducing the problem.

这篇关于maven-shade-plugin报告:创建阴影jar时出错:... target / classes(是一个目录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆