Reputation: 41
I have a Maven project configured to use a custom repository defined in settings.xml. The setup works as expected initially:
Maven first checks the custom repository configured in settings.xml.
If the artifact is not found there, it falls back to Maven Central (https://repo.maven.apache.org/maven2).
However, here's the issue:
If I upload the missing artifact to my custom repository after an initial failure, Maven does not honor the custom repository on subsequent builds. Instead, it keeps looking in Maven Central, even though the artifact is now available in the custom repository.
Temporary Workarounds I Tried:
Deleting the local .m2/repository directory resolves the issue temporarily. However, this is not feasible to perform across all environments every time.
I found another suggestion to delete the _maven.repositories file in the artifact's directory within .m2/repository. This works but is also impractical to automate or perform on all environments.
Question:
How can I ensure Maven consistently checks the custom repository first and avoids relying on cached "not found" states or Maven Central, especially after uploading an artifact to the custom repository? Is there a proper way to handle this without manually clearing the local cache or deleting specific files?
Upvotes: 0
Views: 43