mavenrepositorydependency-management

Locate original repository of each dependency in maven


Scenario: New enterprise policy forbids from using public repositories. For every dependency used (which are a lot) we have to provide to the devOps team the artifact group, id, version and from which repository it came.

We have used more than one external repository on our code base. Since all the artifacts are now on the local repository, we don't know where they came from.

What I was able to do:

I can use mvn dependency:list -DoutputAbsoluteArtifactFilename=true -DprependGroupId on each project to get artifact group, id, version.

And mvn dependency:list-repositories to get the repositories used in that project

What's missing:

Knowing which artifact is from which repository.

Thanks in advance


Solution

  • I am afraid this will not be possible in maven. Prior to maven 3.0.x, maven did not even kept track of remote repositories. After Maven 3.0.x, it moved to eclipse aether. Eclipse aether create _remote.repositories file for every repository which has repository information. It contains repository id which is defined in your settings.xml file. You could,

    1. Delete your local repo contents.
    2. Run following command,

      find . -name _remote.repositories -exec grep "^[^#;]" {} \; > repo_info.txt
      

    This will atleast give you the mapping.