Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Maven Tools 4 Eclipse"

(Updated for new Groovy version)
(Fixed Nexus URL, update to 0.10.0)
 
(10 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
You can find the source on http://git.eclipse.org/c/dash/org.eclipse.dash.m4e.tools.git/
 
You can find the source on http://git.eclipse.org/c/dash/org.eclipse.dash.m4e.tools.git/
  
This tool is used to create the Maven artifacts which you can find on Eclipse's [http://maven.eclipse.org/nexus/index.html Nexus server] at http://maven.eclipse.org/nexus/index.html
+
This tool is used to create the Maven artifacts which you can find on Eclipse's [http://repo.eclipse.org/ Nexus server] at http://repo.eclipse.org/
 +
 
 +
== Why Would I Want This? ==
 +
 
 +
The tool converts Eclipse bundles into Maven artifacts (see [[MT4E FAQ|the FAQ]] for details). This allows you to use Eclipse code in plain Maven projects. No struggles with [http://www.eclipse.org/pde/ PDE], no messing with [http://www.eclipse.org/tycho/ Tycho], no nightmares because of [http://www.osgi.org/Main/HomePage OSGi]. Just plain POMs.
 +
 
 +
Why not use <tt>mvn eclipse:eclipse:make-artifacts</tt>? Actually, my tool eventually calls the [http://maven.apache.org/plugins/maven-eclipse-plugin/ Maven Eclipse plugin] but it does a lot more:
 +
 
 +
# Unpack downloaded archives
 +
# Apply patches like removing dependencies to <tt>system-bundle:system-bundle:[0,)</tt>
 +
# Replace [http://www.eclipse.org/orbit/ Orbit bundles] with artifacts from [http://search.maven.org/ Maven central]
 +
# Strip qualifiers from dependencies (<tt>3.0.0</tt> instead of <tt>3.0.0.v20110517-awesirfh8hgshwerut7zg</tt>).
 +
# Create one POM with a <tt>dependencyManagement</tt> element that nails down all version ranges to the exact version of the artifact that is in your repository. No more unstable builds because another project added a different version of an Eclipse bundle to your local repository which just happens to fit some deeply nested dependency.
 +
# Create a report about possible problems in your repository
 +
 
 +
== Download ==
 +
 
 +
[http://www.eclipse.org/downloads/download.php?file=/technology/dash/org.eclipse.dash.mt4e-0.10.0-jar-with-dependencies.jar Follow this link to download an executable JAR] ([[MT4E Changelog|Changelog]])
  
 
== How it works ==
 
== How it works ==
 +
 +
Replace RUN below with <tt>java -jar org.eclipse.dash.mt4e-0.10.0-jar-with-dependencies.jar</tt>
  
 
A simple workflow:
 
A simple workflow:
  
# Download an Eclipse release from http://www.eclipse.org/downloads/
+
# Create a folder to work. [http://www.eclipse.org/downloads/download.php?file=/technology/dash/org.eclipse.dash.mt4e-0.10.0-jar-with-dependencies.jar Download the tool] and put it into this folder.
# Import it into a temporary Maven repo using <tt>./run.sh import</tt> <i>archive</i>
+
# Download an Eclipse release from http://www.eclipse.org/downloads/ into a new folder <tt>downloads</tt> inside the work folder.
 
# Download the sources for the Eclipse release and/or other archives which contain Eclipse products or OSGi bundles.
 
# Download the sources for the Eclipse release and/or other archives which contain Eclipse products or OSGi bundles.
# Import them as well
+
# Import everything into a temporary Maven repo <tt>tmp/m2repo</tt> using <tt>RUN convert org.eclipse.dash:dependency-management:3.7.0</tt> (you may want to tweak the version number)
# Merge all repositories using <tt>./run.sh merge</tt>
+
# Check the report generated for any problems you may want to fix. Create a patch file (probably using [http://git.eclipse.org/c/dash/org.eclipse.dash.m4e.tools.git/tree/patches the examples]) to do that
# The sources are in the wrong place. Fix that with <tt>./run.sh attach-sources</tt>
+
# Repeat until you're happy with the results
 +
# Upload the content of <tt>tmp/m2repo/</tt> somewhere where Maven can find it (<tt>~/.m2/repository/</tt> or your Maven proxy).
  
'''TODO''' These commands are not yet available with the Groovy version
+
<tt>convert</tt> is actually a wrapper for these commands:
  
# Fix any know problems by applying the patches in the <tt>patches/</tt> folder using the tool <tt>./run.sh apply-patches</tt>
+
# Importing every archive in the folder <tt>downloads</tt> into a temporary Maven repo using <tt>RUN import</tt> <i>archive</i>
# Check the result with <tt>./run.sh analyze</tt>
+
# Merge all repositories using <tt>RUN merge </tt><i>directories...</i><tt> tmp/m2repo</tt>
# Create a POM with the version info to make sure your build picks the correct versions using the <tt>./run.sh dm</tt> tool
+
# The sources are in the wrong place. Fix that with <tt>RUN attach-sources tmp/m2repo</tt>
# If anything goes wrong, use <tt>./run.sh clean</tt> to clean up temporary files and start over.
+
# Fix any know problems by applying the patches in the <tt>patches/</tt> folder using the tool <tt>RUN apply-patches tmp/m2repo </tt><i>patches...</i>
 +
# Check the result with <tt>RUN analyze tmp/m2repo</tt>
 +
# Create a POM with the version info to make sure your build picks the correct versions using the <tt>RUN dm tmp/m2repo </tt><i>groupId:artifactId:version</i>
 +
# If anything goes wrong, use <tt>RUN clean</tt> to clean up temporary files and start over.
  
== How you should use it ==
+
== Building From Source ==
 
+
'''TODO''' These commands are not yet available with the Groovy version
+
Overwhelmed? Here is a more simple version:
+
  
 
# <tt>git clone git://git.eclipse.org/gitroot/dash/org.eclipse.dash.m4e.tools.git</tt>
 
# <tt>git clone git://git.eclipse.org/gitroot/dash/org.eclipse.dash.m4e.tools.git</tt>
 +
# <tt>org.eclipse.dash.m4e.tools</tt> will be our work directory
 
# Download everything you will want and put it into the folder <tt>org.eclipse.dash.m4e.tools/downloads/</tt>
 
# Download everything you will want and put it into the folder <tt>org.eclipse.dash.m4e.tools/downloads/</tt>
# run <tt>./run.sh convert</tt> Yes, you need Linux or MacOS for that.
+
# Compile the code with [http://maven.apache.org/ Maven]: <tt>mvn install</tt>
# Grab some coffee. Not more than 12 cups per day, okay?
+
# See above how to use the tool
# Check the HTML file which was created for any issues that you might care about.
+
 
# Upload the content of <tt>org.eclipse.dash.m4e.tools/tmp/m2repo/</tt> somewhere where Maven can find it (<tt>~/.m2/repository/</tt> or your Maven proxy).
+
== How do I import the result in a Nexus server? ==
 +
 
 +
It's very tedious to deploy the files one by one. Here is a recipe to mass-upload them:
 +
 
 +
# Create a "Hosted Repository" on Nexus
 +
# Copy the files from <tt>tmp/m2repo/</tt> into <tt>sonatype-work/nexus/storage/<name>/</tt> where <tt><name></tt> is the name of the new repository.
 +
# Open the Nexus UI in your web browser
 +
# Login as admin
 +
# Open the "Repositories" tab
 +
# Right click on the hosted repository
 +
# Select "Rebuild Metadata"
 +
 
 +
After that, Maven should be happy.
  
 
== Support ==
 
== Support ==
  
 
Please [https://bugs.eclipse.org/bugs/enter_bug.cgi?product=dash&component=Maven file an issue for Project Dash, Component Maven].
 
Please [https://bugs.eclipse.org/bugs/enter_bug.cgi?product=dash&component=Maven file an issue for Project Dash, Component Maven].
 +
 +
The [[MT4E_FAQ|FAQ is here]]
 +
 +
The [[MT4E_Errors_and_Warnings|list of error messages is here]]
  
 
== Biggest Issues Right Now ==
 
== Biggest Issues Right Now ==
Line 49: Line 86:
  
 
It needs [http://www.python.org/download/ Python 2.7] and [http://lxml.de/ lxml].
 
It needs [http://www.python.org/download/ Python 2.7] and [http://lxml.de/ lxml].
 
  
 
[[Category:Dash Project]]
 
[[Category:Dash Project]]
 +
[[Category:Dash Project:MT4E]]

Latest revision as of 13:39, 9 November 2015

Maven Tools 4 Eclipse (or m4e for short) is a set of tools to convert OSGi bundles into Maven artifacts.

You can find the source on http://git.eclipse.org/c/dash/org.eclipse.dash.m4e.tools.git/

This tool is used to create the Maven artifacts which you can find on Eclipse's Nexus server at http://repo.eclipse.org/

Why Would I Want This?

The tool converts Eclipse bundles into Maven artifacts (see the FAQ for details). This allows you to use Eclipse code in plain Maven projects. No struggles with PDE, no messing with Tycho, no nightmares because of OSGi. Just plain POMs.

Why not use mvn eclipse:eclipse:make-artifacts? Actually, my tool eventually calls the Maven Eclipse plugin but it does a lot more:

  1. Unpack downloaded archives
  2. Apply patches like removing dependencies to system-bundle:system-bundle:[0,)
  3. Replace Orbit bundles with artifacts from Maven central
  4. Strip qualifiers from dependencies (3.0.0 instead of 3.0.0.v20110517-awesirfh8hgshwerut7zg).
  5. Create one POM with a dependencyManagement element that nails down all version ranges to the exact version of the artifact that is in your repository. No more unstable builds because another project added a different version of an Eclipse bundle to your local repository which just happens to fit some deeply nested dependency.
  6. Create a report about possible problems in your repository

Download

Follow this link to download an executable JAR (Changelog)

How it works

Replace RUN below with java -jar org.eclipse.dash.mt4e-0.10.0-jar-with-dependencies.jar

A simple workflow:

  1. Create a folder to work. Download the tool and put it into this folder.
  2. Download an Eclipse release from http://www.eclipse.org/downloads/ into a new folder downloads inside the work folder.
  3. Download the sources for the Eclipse release and/or other archives which contain Eclipse products or OSGi bundles.
  4. Import everything into a temporary Maven repo tmp/m2repo using RUN convert org.eclipse.dash:dependency-management:3.7.0 (you may want to tweak the version number)
  5. Check the report generated for any problems you may want to fix. Create a patch file (probably using the examples) to do that
  6. Repeat until you're happy with the results
  7. Upload the content of tmp/m2repo/ somewhere where Maven can find it (~/.m2/repository/ or your Maven proxy).

convert is actually a wrapper for these commands:

  1. Importing every archive in the folder downloads into a temporary Maven repo using RUN import archive
  2. Merge all repositories using RUN merge directories... tmp/m2repo
  3. The sources are in the wrong place. Fix that with RUN attach-sources tmp/m2repo
  4. Fix any know problems by applying the patches in the patches/ folder using the tool RUN apply-patches tmp/m2repo patches...
  5. Check the result with RUN analyze tmp/m2repo
  6. Create a POM with the version info to make sure your build picks the correct versions using the RUN dm tmp/m2repo groupId:artifactId:version
  7. If anything goes wrong, use RUN clean to clean up temporary files and start over.

Building From Source

  1. git clone git://git.eclipse.org/gitroot/dash/org.eclipse.dash.m4e.tools.git
  2. org.eclipse.dash.m4e.tools will be our work directory
  3. Download everything you will want and put it into the folder org.eclipse.dash.m4e.tools/downloads/
  4. Compile the code with Maven: mvn install
  5. See above how to use the tool

How do I import the result in a Nexus server?

It's very tedious to deploy the files one by one. Here is a recipe to mass-upload them:

  1. Create a "Hosted Repository" on Nexus
  2. Copy the files from tmp/m2repo/ into sonatype-work/nexus/storage/<name>/ where <name> is the name of the new repository.
  3. Open the Nexus UI in your web browser
  4. Login as admin
  5. Open the "Repositories" tab
  6. Right click on the hosted repository
  7. Select "Rebuild Metadata"

After that, Maven should be happy.

Support

Please file an issue for Project Dash, Component Maven.

The FAQ is here

The list of error messages is here

Biggest Issues Right Now

  1. The name m4e sucks. Suggestions?
  2. Find the time to create a repo with Eclipse 3.7

Old Python Version

You can find the original Python project on Github: https://github.com/digulla/org.eclipse.dash.m4e.tools/

It needs Python 2.7 and lxml.

Back to the top