red888
red888

Reputation: 31652

Pre-populate local Maven cache with specific dependencies

It looks like mvn install:install-file is for downloading a jar to a specific location.

I just want to manually download some publicly accessible dependencies to my local Maven cache (specifically the help and versions plugin). It doesn't have to be specific versions, just the latest versions is fine

I want Maven to install them just like it would with the install goal but just execute this from command line without a pom. Is this possible?

Upvotes: 1

Views: 775

Answers (1)

Ramu
Ramu

Reputation: 681

If you don't want create a pom.xml then you can use download-maven-plugin's artifact goal as shown in the below example.

You need pass groupId, artifactId and version. It can't download the file if any one of these 3 are missing or not matching with central repo. If you don't want to download pom file, you can ignore the second line.

Example:

mvn com.googlecode.maven-download-plugin:download-maven-plugin:1.4.2:artifact -DgroupId=log4j -DartifactId=log4j -Dversion=1.2.4 -Dtype=jar -DoutputDirectory=C:\Temp

mvn com.googlecode.maven-download-plugin:download-maven-plugin:1.4.2:artifact -DgroupId=log4j -DartifactId=log4j -Dversion=1.2.4 -Dtype=pom -DoutputDirectory=C:\Temp

This will download both JAR and POM files for log4j:log4j:1.2.4 from central repository to your local repository and also copies the files to C:\Temp folder. Once you are done downloading all the files, you can delete the Temp folder.

Upvotes: 2

Related Questions