DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How to Publish Artifacts to Maven Central
  • Private Remote Maven Repository With Artipie
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]
  • An Explanation of Jenkins Architecture

Trending

  • Streamlining Event Data in Event-Driven Ansible
  • Mastering Fluent Bit: Installing and Configuring Fluent Bit on Kubernetes (Part 3)
  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  • Kubeflow: Driving Scalable and Intelligent Machine Learning Systems
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. How to Set Up a Maven Repository In Minutes

How to Set Up a Maven Repository In Minutes

A tutorial on how to set up Artifactory as a Maven repository to resolve and deploy artifacts in Maven builds.

By 
Sam Rubashkin user avatar
Sam Rubashkin
·
Jun. 22, 16 · Tutorial
Likes (8)
Comment
Save
Tweet
Share
27.6K Views

Join the DZone community and get the full member experience.

Join For Free

A post published several years ago showed how easy it was to set up Artifactory as a Maven repository to resolve and deploy artifacts in Maven builds. While much water has passed under the bridge since then, and there are new build tools available on the market, I believe that Maven is still popular enough to warrant an update. The competitive landscape for Maven repositories has also changed, but I think that Artifactory is still your best choice for setting one up. In addition to meeting all the criteria for selection in the original article, in its commercial form, Artifactory integrates with all major build tools, all major continuous integration servers and supports all major packaging formats.

Basic Requirements

With the latest version of Artifactory, the only significant requirement you need to concern yourself with is that you’re running JDK 8 update 45 and above. Artifactory comes bundled with its own Tomcat 8 which is used to run the UI as a web application.

You can download Artifactory OSS from JFrog’s download page which pulls the latest version from Bintray. Then extract the Zip file to the location on your file system where you want Artifactory installed. This is your ARTIFACTORY_HOME location.

There are several ways you can install Artifactory, but since that’s not the focus of this article, I’ll just go over the main points you need to install and run it as a service on Windows or Linux.

Linux: Once you have unzipped the Zip file you’re pretty much done. You can now run Artifactory by executing $ARTIFACTORY_HOME/bin/artifactory.sh or running it as a daemon process using $ARTIFACTORY_HOME/bin/artifactoryctl start

Windows:

  • First you need to define the ARTIFACTORY_HOME environment variable and set it to your where you unzipped the download file.
  • Now browse to %ARTIFACTORY_HOME%\bin and execute InstallService.bat. You can now start and stop the Artifactory service using sc start | stop artifactory

To access Artifactory, just go to http://SERVER_DOMAIN:8081/artifactory. For example, if you are testing on your local machine you should use: http://localhost:8081/artifactory.

This is what you should see once Artifactory starts up.

HomeScreenOSSClean.jpg

Log in using the default admin user:

  • Username: admin

  • Password: password

Artifactory comes with some Maven repositories out-of-the-box reflecting best practices in Java artifact management. You can view all the repositories in the Artifacts module.

SSLibsSnapshotLocal.jpg

First, configure your Maven client to resolve dependencies through Artifactory. To do that, you need to modify your settings.xml file which is located in the Maven home directory (typically, this will be /user.home/.m2/settings.xml). All you need to do is click Set Me Up.

SSSetMeUp2.jpg

(Take note of this screenshot, you’ll need it later when configuring deployment.)

On the Set Me Up dialog, click Generate Maven Settings and select the repositories you want to use to resolve dependencies for your plugins and libraries, both release and snapshot versions.

MvnGenerateSettings.jpg

After clicking Generate Settings, you can copy and paste the generated code into your settings.xml file (or just download the snippet as a new one). Be sure to configure the <server> tag in your settings.xml file with your Artifactory username and password (admin/password by default). The <id> element in this tag will soon be used in your project’s POM file:

MvnServerTag.jpg

You’re almost done.

Let’s also configure Maven to deploy its build through Artifactory. Back in the Artifacts module, select the repository into which you want to deploy your build artifacts and click Set Me Up again (remember that screenshot I asked you to take note of?). Artifactory displays a distributionManagement snippet already configured for the repository you selected. Simply copy this code snippet and paste it into your project’s POM file. Then match up the <id> element in the <distributionManagement> tag of your POM file to the one you set in the <server> tag of your settings.xml file:

MvnDistributionManagement.jpg

That’s it! You’re ready to do a Maven build that resolves dependencies and deploys its build output through Artifactory. Just run: mvn clean install

As you run the build, you will see that Maven is resolving artifacts through Artifactory.

SSDownloading.jpg

If you also need to deploy artifacts, Artifactory comes with a set of plugins that allow common CI servers such as Jenkins, TeamCity and Bamboo to direct the build output to Artifactory.

That’s it!

That’s how easy it is to setup a Maven repository in Artifactory. You can even see it in action in this screencast. Artifactory still offers all the benefits presented in the original article and then some:

  • Reliable and consistent access to remote artifacts: As a proxy for remote repositories, Artifactory caches remote artifacts locally, so you are not dependent on the network or remote resources.

  • Optimized builds through reduced network traffic: Builds are faster since all remote artifacts are accessed from the local cache without any external networking.

  • Full integration with any build ecosystem: Through a series of plugins, Artifactory supports fully automated builds using common CI servers both on-premises and in the cloud.

  • Security and access control: Artifactory provides fine-grained access control from the level of a complete repository down to a single artifact.

  • License compliance and open source governance: Artifactory performs license checks on your artifacts and all ensuing dependencies. Integration with Black Duck Code Center enables a full range of license compliance and open source governance features.

  • System stability and reliability: Artifactory supports a High Availability configuration that can provide up to “five-nines” availability.

  • Distribution and sharing of artifacts across an organization: Local repositories give a central location to store binaries internally. Repository replication lets you share artifacts with different teams around the world.

  • Artifactory Query Language: A unique query language providing a simple way to formulate complex queries enabling you to dig deep into the endless goldmine of metadata stored in your repositories.

  • Rich REST API: Almost any action can be performed through a REST API allowing you to fully automate your software delivery pipeline.

Go ahead and give it a try. You can have your first Maven repository setup with Artifactory within minutes. Using Maven has never been easier.

Related Refcard:

Maven Repository Management

Repository (version control) Apache Maven Continuous Integration/Deployment Artifact (UML) File system Open source

Opinions expressed by DZone contributors are their own.

Related

  • How to Publish Artifacts to Maven Central
  • Private Remote Maven Repository With Artipie
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]
  • An Explanation of Jenkins Architecture

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!