How do I download JAR during a build in Maven script?
You can use:
mvn dependency:copy -Dartifact=<group>:<artifact-name>:<version> -DoutputDirectory=/tmp/my_custom_dir
(Replace <values>
with the ones of your case)
That's the full documentation of the goal: https://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html
Note: the other "dependecy:get" way of doing this has been deprecated.
See How to use Maven pom to download jar files only. This worked really nicely for me.
My use case was that I wanted to download some of the dependency jars to deploy to a QA server, and was doing it manually (outside of the Maven build). I'm not sure exactly what your use case is.
You can download Jar package to specific directory.
mvn dependency:get -Dartifact=org.riversun:random-forest-codegen:1.0.0 -Ddest=./
Go to http://mvnrepository.com. Search for the artifact you want to download, choose the version from the list of results and simply download the bundle.
Or since 3.1, simply as
mvn dependency:get -Dartifact=org.springframework:spring-instrument:3.2.3.RELEASE
It's possible to download a JAR from a Gitlab Maven private repository. The URL is appearing when running some Maven command so it's a bit hacky but it's working for me.
Like this:
wget --header "PRIVATE-TOKEN: ${GITLAB_PRIVATE_TOKEN}" "https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/packages/maven/${MAVEN_PACKAGE_NAME}/${MAVEN_VERSION}/${JAR_FILE}"
Where,