Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list locally installed maven dependencies

Tags:

maven

local

on my development machine i'm actively working on perhaps 20 inter-dependent maven projects, most of which get published to ossrh from time to time, and i also depend on many other projects from maven central

i'd like to list the dependencies that have been installed locally as opposed to those that have been downloaded from a repository. i'm aware that mvn -U will check remote repositories for snapshot dependencies, but in many cases my versions aren't -SNAPSHOT

is there a way to tell which dependencies have been installed locally ?

like image 865
nqzero Avatar asked Feb 26 '18 21:02

nqzero


People also ask

Where are Maven dependencies stored locally?

The Local Repository Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.

How are dependencies stored in Maven?

Maven local repository keeps your project's all dependencies (library jars, plugin jars etc.). When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build.


1 Answers

The local repository has files of name _remote.repositories in the artifact directories. They are not a public interface, but they might allow you to reverse engineer where the artifacts came from.

@nqzero came up with the expression

mvn dependency:list -DoutputAbsoluteArtifactFilename -DoutputFile=/dev/fd/2 2>&1 1>/dev/null | grep -o "/.*/" | xargs -Ixxx grep -L "jar>central=$" xxx_remote.repositories

that actually does the trick.

like image 51
J Fabian Meier Avatar answered Oct 08 '22 17:10

J Fabian Meier