1
votes

In various shell scripts, we need to download artifacts from a Maven repository (Nexus 2.x at the moment, but may change in the future).

The servers that run the scripts usually have no Maven installed. So I am looking for something http based.

On the one hand, there is a REST interface which can be used like

wget "http://local:8081/service/local/artifact/maven/redirect?g=com.mycompany&a=some-app&v=1.2.3"

On the other hand, you can construct a "standard" URL that seems to work for different Maven repositories. It consists of a prefix, then the groupId with slashes instead of dots, then the artifactId, then the version and then a file name of the form artifactId-(classifier)-version.type.

What is the recommended practise?

1

1 Answers

3
votes

The Maven coordinates section of the POM reference describes the second scenario you mentioned. In general I've found that pattern easiest to explain to folks learning Maven, i.e. whether local or remote, an artifact is located at

$REPO/groupId/as/path/artifactId/version/artifactId-version[-classifier].type

where $REPO can be $USER_HOME/.m2/repository or https://remote.repo:port/....

I would also prefer the second as I suspect it will be easier for this app to work with another repository some day if needed. Even if not quite true, it's more self-documenting, so seems like it would be easier to adjust.