将 eclipse maven 项目导出为带有依赖项的非 maven eclipse 项目
是否可以将 Eclipse 上的 maven Java 项目导出给没有 maven 或 eclipse maven 插件的用户?我想到的第一个问题是如何强制将所有依赖项包含在导出中。
我想让不使用Maven的人更容易在Eclipse上导入我的项目并使用它,换句话说,我想为不使用maven或m2eclipse的用户生成一个可以通过eclipse导入的项目的zip。
这里有什么魔法吗?
Is it possible to export my maven Java project on Eclipse to users that do not have maven or the eclipse maven plugin? The first question that comes to my mind is how to force all the dependencies to be included with the export.
I want to make it easier for people who are not using Maven to import my project on Eclipse and use it, in other words, i want to generate a zip with the project that can be imported by eclipse for users not using maven or m2eclipse.
Any magic here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不,没有魔法。您必须:
./lib
中。./lib
内的库。./lib
、Eclipse 配置文件打包到某个存档中。1. 和 3. 可以通过 Maven 程序集插件 实现。对于 2. GMaven 插件可能会有所帮助。或者也许可以手动完成。人们实际上可以想象扩展 Maven Eclipse 插件 来提供某种< code>eclipse:export 目标,这样会好很多。
但让我警告您,这一点都不容易,老实说,对于每个人来说,使用 Maven 和 eclipse:eclipse 或 m2eclipse 会更容易。
No, no magic. You'll have to:
./lib
../lib
../lib
, the eclipse configuration files into some archive.1. and 3. are doable with the Maven Assembly Plugin. For 2. the GMaven plugin might help. Or maybe do it manually. One could actually imagine extending the Maven Eclipse Plugin to provide some kind of
eclipse:export
goal, this would be much better.But let me warn you, this won't be easy at all and honestly, it would be wayyyy more easy for everybody to either use Maven and
eclipse:eclipse
or m2eclipse.如果您想将其作为 zip 来执行此操作,则 maven-dependency 插件是正确的答案,而程序集插件是正确的答案。使用依赖项插件复制所有依赖项并通过程序集插件创建 zip...也许没有依赖项插件也是可能的...您应该检查有关它的文档
If you like to do this as a zip the maven-dependency plugin is the correct answer and the assembly plugin. With the dependency plugin copy all dependencies and create a zip via the assembly plugin...may be it's possible without the dependency plugin...you should check the docs about it
实际上这并没有什么神奇之处,Eclipse 项目是由它的
.project
文件定义的,无论它是否是 Maven 项目。您可以自由地分发您的项目,其他人将能够成功地将它们导入到他们的 Eclipse 实例中,而不会遇到更多麻烦。
您可以分发 共享 eclipse 用户库 文件指定这些依赖项以及您的项目,这当然远不及 Maven 的灵活性,但它可能会有所帮助。
Actually there is no magic, an eclipse project is defined by its
.project
file, no matter if it is a Maven project or not.You can freely distribute your project and others will be able to successfully import them in their eclipse instance without further trouble.
You can distribute a shared eclipse user library file specifying those dependencies along with your project, this of course is nowhere near the flexibility of Maven, but it might help.
事实上,现在有一种魔法可用;-)
如果您喜欢生活在边缘,您可以尝试 JBoss Tools 3.3.0 的开发版本(需要 Indigo),更具体地说,您需要 JBoss Tools JDT扩展功能(来自 http://download .jboss.org/jbosstools/builds/nightly/trunk/latest/all/repo/ 更新站点)。
这是 https://issues.jboss.org/browse/JBIDE-8972
基本上,右键单击项目资源管理器中显示的 Maven 库,选择“Materialize Library...”,选择目标文件夹、要复制的 jar(可以重命名它们),然后单击“确定”。 Jas 将被复制,项目的类路径也会相应更新。 Maven 库和性质将被删除。
然后您只需压缩您的项目并与任何您想要的人共享。
如果您想重新使用 Maven,请恢复本地更改(使用 svn 或 git 或您正在使用的任何 SCM),或者只需右键单击您的项目 >配置>转换为 Maven 项目,然后删除 lib 文件夹的内容。
Well actually, there's a kind a magic available now ;-)
If you like living on the edge, you can try a dev build of JBoss Tools 3.3.0 (requires Indigo), more specifically, you need the JBoss Tools JDT Extensions feature (from the http://download.jboss.org/jbosstools/builds/nightly/trunk/latest/all/repo/ update site).
This is the implementation of https://issues.jboss.org/browse/JBIDE-8972
Basically, you right-click on the Maven Library shown on the Project Explorer, select "Materialize Library...", select the destination folder, the jars you want to copy (you can rename them) and click OK. Jars will be copied and the classpath of your project updated accordingly. The Maven library and nature will be removed.
You just then have to zip your project and share it with whoever you want.
If you want to go back to using maven, revert your local changes (using svn or git or whatever SCM you're using) or just right-click on your project > Configure > Convert to Maven Project, then delete the content of your lib folder.