Search code examples
javaeclipsemaven-2dependenciesm2eclipse

Can't add project from local Maven repository as a dependency


I've written a new Maven project and for now let's call it Utils. I've installed it successfully in my local Maven repository. At least the targets clean install print BUILD SUCCESSFUL in the end. I can also find the jar when I navigate to it manually through the Windows Explorer.

Now there's another project called Import I've written that should have Utils as a dependency. When I now add it to the pom with the scope compile and run the goals eclipse:eclipse I'm again getting the message BUILD SUCCESSFUL. But unfortunately, the Utils project isn't in the referenced libraries of Import.

When I want to add it in the POM view of the Maven Eclipse plugin, Utils is also not found. Interestingly, when I specify an erroneous version of Utils, I'm getting a warning when I want to install Import with Maven.

Do you know where I'm wrong?


Solution

    • If you're using m2eclipse, then it's using workspace resolution by default to resolve dependencies (Import depends on the Utils project of your workspace and Utils won't be listed in the referenced libraries). In other words, the dependency is there but not where you're looking for it.

    • You can run mvn dependency:tree on Import on the command line to confirm everything is ok. You should see Utils in the printed tree.

    • If you're using m2eclipse, don't use the maven eclipse plugin (eclipse:eclipse), import your project as an Existing Maven Projects.

    • Not directly related by I wonder why you are calling maven as an external tool.