maven

How to remove maven dependencies downloaded by a particular build?


Like, I have some deps in local repo, then create (clone) a new project, build it (id downloads plethora of deps), then I want to remove the project I've cloned and also remove downloaded maven deps from local repo - those downloaded by that build. I know some of those could be used by oter local projects, but is there a way to manage it? Maybe storing those deps in project dir only like with NPM projects?


Solution

  • If I remember correctly, you can set per-project cache directory with the maven.repo.local flag:

    $ mvn -Dmaven.repo.local={project-dir}/dependencies clean install
    

    This way, when you delete your project, the downloaded deps will be deleted with it.