Exporting eclipse maven project as a non-maven eclipse project with dependencies
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 ques开发者_如何学Pythontion 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?
Any magic here?
No, no magic. You'll have to:
- get all dependencies (all scopes + transitively) and copy them into, say
./lib
. - rewrite the .classpath to point on the libraries inside
./lib
. - package the sources, the
./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.
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
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.
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.
精彩评论