john miran
john miran

Reputation: 393

Add artifact to local repository from project

Is there a way add artifact to local maven repository from my eclipse project?

currently i have a project that contain many jars, and i have started using maven. what i need is to add all these jars to the local repository in an automated way without redownload them or adding them one by one and specifying their coordinates.

Upvotes: 0

Views: 178

Answers (2)

Jesse van Bekkum
Jesse van Bekkum

Reputation: 1526

Make a new Maven project in Eclipse, and add all your code to the src/main directory. Now you will have lots of compile errors, because of missing dependencies.

Now start auto adding the dependencies. In Intellj you can add something using alt-enter, which also has the option to "add maven dependency". This adds that dependency from the maven repository to the pom. I do not know eclipse well enough, but it probably also has this feature.

Now, in a normal project, you will find most of your required dependencies somewhere in Maven Central. If you miss any, you can add them using manual installation to your local repository, as suggested by Manas Mukherjee

mvn install:install-file -Dfile={jar_file_name_path}.jar -DgroupId={groupId} 
-DartifactId={artifactId} -Dversion={version} -Dpackaging=jar

Upvotes: 1

Manas Mukherjee
Manas Mukherjee

Reputation: 5340

you can write a script using mvn install command.

mvn install:install-file -Dfile={jar_file_name_path}.jar -DgroupId={groupId} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar

You can add all dependencies in pom file as well

Thanks

Upvotes: 0

Related Questions