How to deal with vanished Maven repository (caching)?

77 Views Asked by At

There used to be a repository that supplied us a certain version of a certain package - au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1. Let's pretend the repository was at 12.3.4.567. In my settings.xml, I have an entry for it:

<repository>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
  <id>3rdParty</id>
  <url>https://12.3.4.567:8081/repository/maven-group</url>
</repository>

When that repository was up and running, I was able to acquire the package and my mvn build succeeds. Other, newer developers can't build with the same configuration, because that repository no longer can supply them the jar file. If I comment out that repository in my settings.xml, my build fails:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  57.864 s
[INFO] Finished at: 2022-12-16T06:35:31-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-project: 
Could not resolve dependencies for project gov.x.y:my-project:jar:1.1.0-SNAPSHOT: 
Could not find artifact au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1 
in central (https://repo1.maven.org/maven2) -> [Help 1]

If I remove the comment characters in my settings.xml, it builds again.

I don't have a good feel for how Maven caching works. There appears to be some kind of caching of mvn artifacts on my local machine that gets found based on a repository key. I'm afraid that at some point the cache will be modified, and I will no longer be able to build.

How can I make my development world a safer place and also make au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1 (and its dependencies) available to other developers? (BTW, I haven't been able to find that version of variant-spark on any public repositories.) Is there a way I can work backwards from my local Maven artifacts such that we could create a local repository to supply the artifacts?

I'm open to hearing about kludgy, simple safeguards as well as how to do things the right way.

1

There are 1 best solutions below

0
On

You have now found out why it is so important to use artifacts published to Maven Central or somewhere similar that won't go away. Your build server should have found this a while back - you may want to consider setting one up for the next time something breaks.

Right now, I would suggest:

  1. back up your computer (or at least the .m2 folder).
  2. set up a local repository manager like Nexus or Artifactory and install these files in it in the same location so others can use it immediatlye.
  3. create a virtual repository that invisibly merges this local repository with Maven Central
  4. tell everybody to set up their settings.xml to use that as a mirror.

This should get everybody up and running again.

Then, strongly reconsider if depending on an artifact only present in your office is a good idea. Is it elsewhere under a different name? Can you utilize something else? Can you get the source so you can fork and maintain it yourself?