Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - How do I validate dependencies are available in the declared repositories?

Tags:

java

maven

I have just edited the <repositories /> section of my pom.xml file for a project, removing a couple of repo's I thought were unneeded.

I'd like to validate that the declared dependencies are still resolvable in the available repositories.

However, all of the declared dependencies are available in my local repo, so any attempt to build will just use the local ones.

I don't want to simply nuke my local repo, as it takes many hours to download all the dependencies from scratch.

Similarly, I'm not interested in having maven attempt to download all the dependencies, I just want it to ensure that they're all resolvable (including transitive dependencies).

How do I do this?

like image 978
Marty Pitt Avatar asked May 07 '12 22:05

Marty Pitt


People also ask

Where are the Maven dependencies are available?

Maven local repository is located in your local system. It is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/. m2 directory.

How do I force Maven to download dependencies from remote repository?

Force maven to fetch dependencies from the remote repository while building the project. We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository.


3 Answers

run mvn dependency:analyze

it will check dependencies for you.

ref: http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html

like image 90
Hawk Avatar answered Sep 27 '22 20:09

Hawk


The first thing i can say is not to define repositories in a pom, cause it will cause many problems in particular for others who are using this project. Furthermore i recommend to use a repository manager which will solve the problem and improve performance during download and will simplify the check of such circumstances which means simply delete the local repo and try to build.

like image 27
khmarbaise Avatar answered Sep 27 '22 18:09

khmarbaise


Emptying the local repo seems to be the only option. This link may help prevent maven to resolve dependencies in local repository.

like image 36
Maniganda Prakash Avatar answered Sep 27 '22 20:09

Maniganda Prakash