In large projects it is common to share libraries across applications. Typically, libraries are hosted either via public cloud repository like Maven Central or hosted in private repositories, and they are pulled when required.
Typical solution for the artifact management is to go with artifact repositories such as JFrog, Nexus, etc. Either install and manage them or use a managed service.
Of course both are secured. The former is costly in terms of effort required and the latter is costly in terms of the pricing of managed services.
When there is little efficiency often we ask this question “Is there a better way to solve this and add value to the delivery cycle?” and the answer is of course “Yes”.
Similar to other services offered, major public cloud vendors have solutions out of the box SaaS offerings for hosting artifact repository, and they also have managed services for hosting artifact needs.
Cloud native solutions are cost-effective, easy set up, easy to use, availability and secure. With near zero management and maintenance requirements ease DevOps work load.
GCP’s Artifactory Registry was an effective choice for our use case (as our application was relying GCP for build and hosting requirements) where we quickly need to have a maven repository with security and cost. The set-up & maintenance cost is almost zero, the operating costs to store the artifacts is free up to 0.5 GB and for every additional GB the cost is $0.10 and the network egress cost max $0.15 per GB.
Artifact Registry is a fully managed artifact repository service - you can use it to store container images, NPM packages, and Java artifacts, without having to setup any infrastructure and worry about availability or disk space.
As such it provides you total control your artifacts:
Thus, Artifact Registry helps your organization deliver software at scale, reduce operational overhead, and thus free developers to focus on building your core application.
Let us setup a maven repository on GCP’s Artifact Registry and setup our project to push and pull our private artifacts to/from it.
pom configuration to add to your project:
Your project specific snippet is then generated. Make sure to insert this into your project’s
First begin by generating the credentials file for your service account.
Now download this keyfile
.json file to your local machine.
You need to add this file’s path to an environment variable named
Follow your OS specific steps on setting a system environment variable.
You can now successfully deploy your libraries to the repository through maven’s build lifecycle.
Or you can also manually add package to repo that were packaged outside of maven.
To verify that your artifact has been deployed to your private repository:
You can now setup your applications to pull from your private repository.
To ensure that your application can resolve the private libraries, you may need to add
repository & Google’s Artifact Registry Wagon to the project’s
pom.xml so that you can to access your artifacts from the repository.
To include in all of your projects’
That is it. Now your projects can pull any private artifact hosted on your GCP Artifact Registy during the maven build lifecycles.
Making use of shared libraries across common projects helps ease development workflows for large scale applications.
You can now have a managed cloud solution like Artifact Registry to help build and deploy your own libraries to a private Maven repository without having to work about maintaining or securing custom solutions.