Mark Lalor Mark Lalor - 3 months ago 11
Bash Question

Copying jar from local Maven repository

I'm working on a sort of deployment script for a Java project using Python/shell. The script currently can copy jars either from a Sonatype Nexus repository or from the project's target folder. The remote/Nexus setup seems all good, but I'm interested in instead copying from the local maven repository because allows me to always know the location of the jar regardless of where the project is installed.

I guess my question is: Am I overlooking anything by just copying the first jar from the folder

~/.m2/repository/{groupid}/{artifactid}/{version}
? Or is this totally a good way to go about this?

Answer

If the groupId consists of more than one part, for example org.apache.httpcomponents , then the folder structure reflects this: org/apache/httpcomponents/...

enter image description here

There may exist more than one jar file inside the version directory.