I want to use one maven project as dependency using POM.xml in other project with few limitations.
My Maven project1 is framework project. I have created a jar file for that project. This project will reside in a private git repo. I donot want to expose this project other user to edit it.
In my maven project2 or maven project3 i want to use the maven project1 as dependency. the jar file should be downladed to maven dependencies during run time.
Note: the user will not have mave project1 in his eclipse.
For example: when i add testNG dependency to my POM.xml testNG jar will be downloaded to my project similarly, I need to add my maven project1 as dependency to any other maven project and it should downlod project1 as jar.
Please do let me know how to achieve it.
You can set up a private maven repository to host the jar file. More setup information can be found under https://maven.apache.org/guides/introduction/introduction-to-repositories.html
e.g. an example pom.xml in project2 / project3 using the project1 as dependency:
Or just use JFrog Artifactory for hosting any dependencies: https://www.jfrog.com/open-source/
I guess you should upload your project to the Maven repository: https://maven.apache.org/guides/mini/guide-central-repository-upload.html
You can use
mvn install:install-file -DgroupId=projecta -DartifactId=projecta -Dversion=1.0.0 -Dpackaging=jar -Dfile=path to you .jar file here
.You can install your jar into your local m2 repository by using this command and then access it like any other dependency in your projectB by using the groupid, artifactid and version you defined in the command above.
You should be able to add that jar to your local repository using this within your pom:
After installing it, the jar can be implemented like any other dependency.