1

I'm developing a plugin for another software, which - in theory - I can update by replacing the jar file and executing the reload endpoint in the software the plugin is for.

As my plugin is published to a maven repository, I wondered if I could use the maven resolver to get those dependencies. I tried to build the download URI manually, by looking at the meta-data and downloading the artifact based on the latest tag, but I realized that this doesn't work for snapshots, for which I would have to parse yet another xml file to retrieve the latest "version"/"revision" of this snapshot.

So I wondered if it is somehow possible to use mavens internal tools for this, and if possible also use the local repository to install SNAPSHOT versions that are not yet published to the repository.

Also I would need to authenticate to my maven repository with a username and a password, which I could either read from a config file (preferred, as not all machines I use the plugin on have maven installed yet) or could be placed in the settings.xml.

Is it possible to use the code that maven uses to resolve dependencies programmatically in java, and if so which additional dependencies would I need?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Jojomatik
  • 156
  • 2
  • 16
  • This is a bit old, but should still work: https://stackoverflow.com/a/48582332/927493 – J Fabian Meier Dec 29 '20 at 19:19
  • @JFabianMeier Thank you, my program is pretty small though. Adding this many dependencies feels kind of wrong for this fairly simple process, don't you think? Also: I would like to determine the latest version automatically, is this also possible using this answer? – Jojomatik Dec 29 '20 at 20:13
  • Maybe you should also have a look at the REST interface of your Maven repository. – J Fabian Meier Dec 30 '20 at 10:29
  • I use the open source variant of artifactory. Most of the features are unfortunately blocked in the non paid version. E.g. sorting by version and picking the first one does not seem to be possible. I could write a simple web app that does nothing more than relaying credentials and selecting the latest one, I might look into that later. – Jojomatik Dec 30 '20 at 12:51

0 Answers0