Gringo Golf Gringo Golf - 6 months ago 17
Java Question

Adding a newly created Maven SNAPSHOT into another project

Help,

I've created my first maven snapshot jar file. I've uploaded it to my Git repository (In Target directory) Now I want to use the jar file in another project. How do I enable the maven dependency in my new eclipse project? As for my groupID was not sure how to create that since I'm doing this on my own.

<dependency>
<groupId>org.firstName.LastName</groupId>
<artifactId>bichromate</artifactId>
<version>0.1.1 SNAPSHOT</version>



Answer

Maven downloads dependencies from a centralized location and puts them into target/lib. Accessing dependencies from this folder will only be overwritten when mvn clean install is run again.

I highly suggest you do a mvn deploy to deploy your artifact to a number of maven compatible artifact stores. Sonatype Nexus, jFrog Artifactory, etc are designed to host your artifacts for use in gradle and maven project builds.

If you performed a mvn clean install of the dependency on your local machine, it will be in the ~/.m2/repository or your local repository location. In which case you can reference the artifact as normal.

Group ID's are typically the domain name of the company or persons releasing the artifact. Artifact ID is the name of the artifact (of course).

If you want to include jar's locally (i.e. part of your project, from say a lib folder) then you'll want to use something similar to this:

<dependency>
    <groupId>sample</groupId>
    <artifactId>com.sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/sample.jar</systemPath>
</dependency>
Comments