5

I'm writing a shell script, which should install an artifact if it isn't already installed.

Is it exist something like mvn install:check artifact-name?


I'm using: Apache Maven 3.3.9

Silk0vsky
  • 941
  • 1
  • 18
  • 34
  • RUnning the build will automatically download the missing artifacts into the local repo? Why writing a script for this? – khmarbaise Apr 06 '17 at 13:14
  • Duplicate of https://stackoverflow.com/questions/10177292/how-to-determine-if-a-maven-artifact-is-in-my-repo-from-command-line – Ben Creasy Feb 03 '23 at 09:52

1 Answers1

6

You can try with dependenct:get in offline mode and specify your repository, the command has the following structure:

mvn dependency:get -Dartifact={groupId}:{artifactId}:{version} -o -DrepoUrl=file://your/repo/path

For example:

mvn dependency:get -Dartifact=junit:junit:4.10 -o -DrepoUrl=file://~/.m2/repository

If it finds the dependency, then you will get:

[INFO] BUILD SUCCESS
JUAN CALVOPINA M
  • 3,695
  • 2
  • 21
  • 37