Silk0vsky
Silk0vsky

Reputation: 1042

Maven: how to check if artifact already installen to local repository

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

Upvotes: 5

Views: 4496

Answers (1)

JUAN CALVOPINA M
JUAN CALVOPINA M

Reputation: 3975

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

Upvotes: 7

Related Questions