Monday, March 5, 2018

list locally installed maven dependencies

i posted the following question to stack overflow, but the Close-Vote-Ring tends to delete "niche" questions like this so i'm posting it here as well:
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 ?
user JF Meier made the critical observation in a comment that there's a _remote.repositories file in the local repository. based on this, i came up with the following:
versions=$(mvn dependency:list -DoutputAbsoluteArtifactFilename -DoutputFile=/dev/fd/2 2>&1 1>/dev/null | grep -o "/.*/" | xargs -Ixxx grep -L "jar>central=$" xxx_remote.repositories) | grep -o ".*/"
and then i use that to copy the local artifacts to a remote machine for testing: rsync -aRvO $versions example.com:/ caveat emptor - the file format isn't a public api and includes the following
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.

No comments: