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:
-
Locate the Local Maven Repository Location: Typically, the local Maven repository is located in the
.m2folder within the user's home directory. The specific path is~/.m2/repository. However, this location can be modified in the Maven configuration filesettings.xml. -
Locate the Target Project Folder: Within the
repositoryfolder, each installed artifact is stored in a directory path named aftergroupId,artifactId, andversion. For example, if you have an artifact withgroupIdcom.example,artifactIdmylib, and version1.0.0, the corresponding path is typically~/.m2/repository/com/example/mylib/1.0.0. -
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.pomfiles and.sha1checksum files). This will completely remove this version of the artifact from your local repository. -
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:
bashrm -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.