Question

Just downloaded the m2e Eclipse plugin and love it! I am wondering what web service it uses to resolve all of a project's transitive dependencies.

I assume that it works by parsing all of the <dependency> elements out of the project pom.xml, and uses a service to query Maven for each transitive dependency.

Basically, I'm asking: how does m2e populate the local Maven cache stored at ~/.m2?

Was it helpful?

Solution

The plugin works the same as the Maven command line progam mvn.

Assuming your project's POM and Maven settings file does not change the default repository settings Maven will download files from Maven Central

http://repo1.maven.org/maven2/

So taking a dependency as follows:

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
</dependency>

Maven will use the following URL convention (Maven2 repository layout):

<Repository URL>/<groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging>

To download 2 files:

  1. http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.pom
  2. http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar

The first is the module POM, whose packaging element will indicate the file name extension to use when downloading the second file (defaults to "jar").

Finally Maven will recursively read the POM files associated with other dependencies listed in the POM and decide which other modules to download (Dependencies of Dependencies)

OTHER TIPS

By running the normal Maven dependency resolution process; for each dependency it recursively resolves transitive dependencies. The "service" is just a query of the dependencies' POMs from any configured Maven repositories.

I'm not sure how m2e does it specifically, but you can do the same on the command line using mvn dependency:tree. That command supports various output formats: text, dot, graphml, tgf. See maven dependency plugin docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top