Clear artifacts using maven-dependency-plugin

I want to run a command mvnto get rid of all artifacts in ~/.m2/repository/here/goes/my/groupid. To do this, I run:

mvn -pl my-module dependency:purge-local-repository -DresolutionFuzziness=groupId -Dinclude=<here-goes-my-groupid> -DactTransitively=false -DreResolve=false -Dverbose=true

This works fine if the current version (3.0.0) of the current artifact (my-maven-plugin) is in the local repo.

If the current version (3.0.0) of the current artifact (my-maven-plugin) is not in the local repo (for example, in the local version there is only an old version of this repo artifact, say 2.9.0), nothing is cleared:

[INFO] --- maven-dependency-plugin:3.0.0:purge-local-repository (default-cli) @ my-maven-plugin ---
Downloading: https://repo.maven.apache.org/maven2/here/goes/my/groupid/my-maven-plugin/3.0.0/my-maven-plugin-3.0.0.jar
[INFO] Unable to resolve all dependencies for : <here-goes-my-groupid>:my-maven-plugin:3.0.0. Falling back to non-transitive mode for initial artifact resolution.
[INFO] No artifacts included for purge for project: <here-goes-my-groupid>:my-maven-plugin:maven-plugin:3.0.0

I do not understand why maven-dependency-plugin is trying to download something from the maven center. All you need to do is recursively delete the folder in the local file system.

How can I clean up all artifacts in a given group, regardless of whether the current version of the current artifact is in the local repo or not?

+5
source share
1 answer

includeexpects groupIdthe dependency being cleared to be exactly the same as the project. Options resolutionFuzziness, actTransitivelyand reResolveapply only when the specified condition is groupIdmet. I think this may be due to the fact that plug-in developers want to prevent accidentally cleaning artifacts that are not part of the project group. This is my wild guess, though.

Relax manualIncludecomes to the rescue. It can clean artifacts regardless of project groupId.

Try it:

mvn dependency:purge-local-repository -DmanualInclude=<group-id>:<artifact-id>

or that:

mvn dependency:purge-local-repository -DmanualIncludes=<group-id>:<artifact-id>

, include , , reResolve.

.

-1

Source: https://habr.com/ru/post/1666849/


All Articles