Delmania
Delmania

Reputation: 832

Differences between m2eclipse and maven command line

I am having some issues with building a project via the maven CLI and Eclipse: When I build the project in Eclipse, I have no issues. When I build the project in a shell, I get an error that the compiler can't find a specific package.

This is using the same pom file. The issue are the transitive dependencies. When Eclipse updates the project, it's able to pull down the dependencies just fine, whereas the cli can't. The dependencies are stored in a custom (Ivy) repository layout, but we have mirrors set up that enable maven to read them. Both the cli and Eclipse are reading the same pom file and the same settings.xml.

I'm seeking to understand how Eclipse can resolve those dependencies whereas raw Maven cannot.

Upvotes: 4

Views: 1356

Answers (3)

Roberto TheLaker
Roberto TheLaker

Reputation: 185

M2Eclipse uses an embedded Maven. So it will also use its own .m2 repo. You can force it to use the .m2 repo for the CLI Maven by going to Preferences/Maven/Intallations.

Upvotes: 0

Delmania
Delmania

Reputation: 832

It seems as through when running m2eclipse, Eclipse will discover and resolve all transient dependencies and put them on the classpath. I added those dependencies as explicit (since I was using them) and the project built.

Upvotes: 0

ServerSideCat
ServerSideCat

Reputation: 2072

According to your question: M2Eclipse is just a tool for using Maven inside Eclipse

Here we can find from M2Eclipse site:

M2Eclipse provides tight integration for Apache Maven into the IDE with the following features:

  • Launching Maven builds from within Eclipse
  • Dependency management for Eclipse build path based on Maven's pom.xml
  • Resolving Maven dependencies from the Eclipse workspace without installing to local Maven repository
  • Automatic downloading of the required dependencies from the remote Maven repositories
  • Wizards for creating new Maven projects, pom.xml and to enable Maven support on plain Java project
  • Quick search for dependencies in Maven remote repositories
  • Quick fixes in the Java editor for looking up required dependencies/jars by the class or package name

Upvotes: 1

Related Questions