乐闻世界logo
搜索文章和话题

How to remove jar file from local maven repository which was added with install:install-file?

1个答案

1

To remove JAR files added using the install:install-file command from the local Maven repository, you can manually delete the corresponding folder in the repository. Here is a detailed step-by-step guide:

  1. Locate the Local Maven Repository Location: Typically, the local Maven repository is located in the .m2 folder within the user's home directory. The specific path is ~/.m2/repository. However, this location can be modified in the Maven configuration file settings.xml.

  2. Locate the Target Project Folder: Within the repository folder, each installed artifact is stored in a directory path named after groupId, artifactId, and version. For example, if you have an artifact with groupId com.example, artifactId mylib, and version 1.0.0, the corresponding path is typically ~/.m2/repository/com/example/mylib/1.0.0.

  3. Delete the Relevant Folder: Once you locate the corresponding folder, you can directly delete the entire version folder (here, 1.0.0) that contains the JAR file and other related files (such as .pom files and .sha1 checksum files). This will completely remove this version of the artifact from your local repository.

  4. Verify the Deletion: After deleting the folder, you can verify the deletion by attempting to rebuild the project that depends on this artifact. If Maven cannot find this artifact in the local repository, it will attempt to download it from a remote repository, which is a good sign indicating that the local version has been successfully removed.

Example

Suppose you need to remove the JAR with groupId com.mycompany.app, artifactId my-app, and version 1.0-SNAPSHOT. The path to delete is:

shell
~/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/

Navigate directly to this location in your file manager, or use the following command in the terminal:

bash
rm -rf ~/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/

After this, the specific version of the artifact is removed from your local Maven repository.

2024年8月15日 18:36 回复

你的答案