My team is just starting out with Maven in Java Projects. We now have all the projects using Maven to get dependencies from internet but we wanted to use a Maven repository to share common share java classes we make and package in jars.
I setup a Maven Nexus Server and it looks like it's working great as a proxy. Next step is to take one of the jars we built and deploy it into local nexus repo, so any developer can share it as a dependency. However I have no idea on where to start.
If I do a mvn install, it puts code into local (My pc) repo, which is not what I'm looking for. I want to install it on the nexus repo, so everyone on my team can access it. Please help me out.
Click on "Browse Repositories," and you'll see a list of repositories. You will want to right click on the "3rd Party" repository and choose "Upload Artifact." You will then see an "Upload Artifact" form. Choose the JAR to upload, then populate the group id, artifact id, version, and other fields.
You probably know a bit about it, but here is a high-level overview (for others) about setting up a Maven repository.
Once you have a repository, you need to go back to each one of the dependent projects (or if they share a master pom) and define the repository so it will be added to the source repositories that will be pulled for the builds.
I have used Apache's Archiva with good results, and it supports being a "caching proxy" for Maven project requests, such that it will download and collect binary artifacts from upstream repositories if it cannot serve the binary artifact itself. That said, the documentation could be a bit better.
There are other products, like Artifactory which are regarded well. You might want to consider it a candidate for evaluation.
Your builds do not need a repository management system, as any ssh server with the right directory structure will do; however, having such a system can make you life easier by automatic caching combined with request proxying, providing a means to manage user access, structuring and managing multiple repositories (development / QA release / General Availablility), and running odd reports that might make management easier (if you use them).
As far as actually using such a server, there are two "parts" of your pom you will need to modify, and one (possibly) additional file you will need to add.
Beyond that, it becomes a matter of style. I recommend separating the snapshots from the "releases" by setting up two repositories. This allows you to frequently purge older files from the snapshot repositories without risk to long standing needed release versions.
Then you need to decide if you are going to cache all items necessary for the build in-house. If so, you need to reconfigure the projects to not pull from "outside" repositories, and download the artifacts that are "missing" into the right directory on your repository. The "automatic proxy cache" feature of many repository management products does exactly this.
Then you need to decide if you are going to cache all the plugins for the maven system in-house. If so, you need a pluginRepository and if you ever want to deploy a custom plugin, a pluginSnapshotRepository. Yes it sounds like a lot, but it is just a tiny bit more work to do four of these repositories at the same time as it would be to do one.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With