How to load maven dependency from another project
Answered
I have a maven project A which depends on maven project B.
I'm currently deploying project B to maven repository with snapshot (e.g version 1.3-SNAPSHOT) and loading it in project A via maven dependencies in the pom.xml.
While working on project B I would like to test it's affects on project A without deploying it to the repo. I know in eclipse if the 2 projects are in the same workspace it automatically loads the dependency from the workspace instead from the repo.
I have no knowledge on how modules in intellij works, and currenty don't have .iml file in my projects, and I would prefer to keep it this way if possible.
I'd appreciate any suggestions, thanks
Please sign in to leave a comment.
For IDE to resolve dependencies to the Maven modules with sources instead of the jars from the local repository these requirements should be met:
Additional note: If dependency is of 'SNAPSHOT' version, module dependency of the 'LATEST' version will be resolved (to the module). For versions without 'SNAPSHOT' dependencies with versions declared as 'LATEST' and 'RELEASE' will be resolved.
I can't get it working. I've tried to increment the version of the dependent project, and in the pom.xml of the other project updated the dependency to LATEST, and I see in the 'External Libraries' that it still refers to the previous version which is in the remote repo, and not the newer version which is in the project in another module
How do you references these dependencies in pom.xml?
How do you declare version in these modules themselves?
Are they located under same IDE project and added as Maven modules into project?
They are defined as separate maven projects, not as multi module project or something.
I have project A:
com.me
useme
1.4-SNAPSHOT
And in project B I reference it:
...
com.me
useme
LATEST
...
I started out with project B in intellij, and then from the project structure I imported module and pointed to project A, so now I have IDE project which contain two separate maven projects
>And in project B I reference it:
Try as
does it work?
Also tried, stiil same result.
Maybe the project must be defined as maven multi module project?
Strange, it should work. Do you reference it in dependencies section? Can you provide pom.xmls?
If there is some parent project where you define some project information, make sure it is also included in IDEA project.
Is there a link with screenshots on how to connect 2 projects ? Say project B is a git clone in the local and project A has a dependency on the B jar.
Hello,
Here you could find information about adding dependencies: https://www.jetbrains.com/help/idea/working-with-module-dependencies.html
Also check similar discussion: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000322004-Adding-Project-Dependancy-is-not-working?page=1#community_comment_115000346264