1

Let's say I have a repository with two versions: 1.1 and 1.2:

com/mycomp/myproj/1.1/
com/mycomp/myproj/1.2/
com/mycomp/myproj/maven-metadata.xml

Latest file contents:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>com.mycomp</groupId>
  <artifactId>myproj</artifactId>
  <versioning>
    <release>1.2</release>
    <versions>
      <version>1.1</version>
      <version>1.2</version>
    </versions>
    <lastUpdated>20180606133322</lastUpdated>
  </versioning>
</metadata>

Is there a tool or a way to remove version 1.2 and change maven-metadata.xml to not have it declared without need to manually edit the file? I researched around mvn command, but looks like it is only applicable for maven projects, while my maven repository is populated by gradle with maven plugin.

  • Possible duplicate of [How to remove jar file from local maven repository which was added with install:install-file?](https://stackoverflow.com/questions/15358851/how-to-remove-jar-file-from-local-maven-repository-which-was-added-with-install) – Kit Menke Jun 12 '18 at 19:20

1 Answers1

2

Your local maven repo is by default at $HOME/.m2/repository, so just go into the file system and blow away the folder

$HOME/.m2/repository/com/mycomp/myproj/1.2/

You can also blow away the maven-metadata.xml file it is recreated every time you do a

mvn clean install.
Essex Boy
  • 7,565
  • 2
  • 21
  • 24
  • Thanks for the suggestion. You are right, I can just remove 1.2 folder. But if I will remove maven-metadata.xml, and then push a new release with "./gradle uploadArchives" (remember, I don't have a maven project, only gradle one), but in this case recreated maven-metadata.xml will not include version 1.1 anymore, though the folder 1.1 is still there. So I'm seeking for more intelligent way to remove the release that would adjust maven-metadata.xml automatically for me. I understand that I mat end up writing this tool myself, though – Leonid Yurchenko Jun 13 '18 at 10:52
  • @LeonidYurchenko gradle is using maven under the covers anyway. You can play fast and loose deleting directories under ~/.m2/repository, maven/gradle will recreate them as needed. Think of it as a cache. Would you accept my answer if you're happy, thanks. – Essex Boy Jun 13 '18 at 11:01