Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

java - Maven `dependency:purge-local-repository` doesn't remove all dependencies

I know that there are few questions already about dependency:purge-local-repository to clean up the local repository dependency cache.

Almost all posts say this command will remove all dependencies but it seems not... Especially "test" scope dependencies remain and I can't clean up the local repo.

I debugged this plugin a bit and why this happens. Then eventually I found that the getFilteredResolvedArtifacts method in the PurgeLocalRepositoryMojo calls MavenSession.getProjectBuildingRequest() method and this ProjectBuildingRequest has an exclude for test & provided scopes in the buildingRequest.repositorySession.dependencySelector

Source => https://github.com/apache/maven-dependency-plugin/blob/528a2f9b6683ada0b2cabad8593cd814fd08a1b2/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java#L578-L580

Screenshot of debugging => debug screenshot

I would like to know if this plugin intentionally excludes test dependencies to purge (if so, the reason as well..) I wanted to rise a github issue for that (https://github.com/apache/maven-dependency-plugin) but I couldn't find issue page there.

Thanks a lot for the support in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...