As a Maven repository, Artifactory is both a source for artifacts needed for a build, and a target to deploy artifacts generated in the build process. By using Artifactory as your Maven repository you gain consistent and reliable access to remote Maven resources, optimized builds with exhaustive information for fully reproducible builds , security and access control, sharing of internal and external artifacts and more.
For more details on setting up your Maven repository, please refer to the JFrog Artifactory user guide. You can get started with a free 30-day trial here.
This screencast will show you how to set up JFrog Artifactory and start using it as a Maven repository in minutes.
JFrog Artifactory is a universal artifact repository. It works with different build tools, CI servers, and packaging systems. Please see additional screencasts from JFrog to learn how to use Artifactory with other tools.
Download and Installation
Let’s start by downloading Artifactory from www.jfrog.com. Notice that Artifactory is being downloaded from JFrog Bintray, a modern, feature rich distribution platform. For example, you can use Bintray to get notifications when new versions of Artifactory are released. After the download is finished, we’ll extract the downloaded file.
Now, let’s start up Artifactory. First, locate the Artifactory executable under the bin directory. Now, just run the artifactory.bat file or the artifactory.sh file. There are more ways to install and run Artifactory. RPM for Linux, running as a service for both Windows and Linux, installation in existing servlet containers, and even a Docker image for running Artifactory as a Docker container.
Now when Artifactory is up and running, let’s log in to its web interface.
Configuring Maven to Use Artifactory as a Maven Repository
As you can see, Artifactory comes pre-configured with a number of Maven repositories. Reflecting the best practices in Java artifact management.
For setting up your tools to work with Artifactory, the Set Me Up button is your best friend. The pop up window gives you all the instructions and provides you with valuable configuration snippets. It is context sensitive and shows the relevant information based on the focus location in the tree browser.
In our case, we need to configure Maven. So we’ll click on Set Me Up while focusing on a Maven repository. Now we can generate the default Maven settings file, for use by our build process.
After choosing a resolution repository for releases and snapshots, we can save the file in the user Maven configuration directory.
Downloading Dependencies From and Deploying Artifacts to Artifactory
Maven now is configured to resolve dependencies from Artifactory. In order to configure a Maven project to deploy artifacts to Artifactory, we need to add a distribution management part to the project POM. Again, the Set Me Up button to the rescue. Clicking on it while focusing on a local Maven repository will bring up the snippet of a POM file. Which configure as a Maven project to deploy the build artifacts to Artifactory. All we have to do is to copy-paste the snippet into the POM XML.
Let’s run the existing project and use the newly installed Artifactory to resolve the dependencies from and to deploy the artifacts too. Notice how all the dependencies are being downloaded from the Artifactory server and all the artifacts are uploaded to Artifactory. Looking at the Artifactory log, you can observe the resolution and the deployment process as well.
Browsing the Artifactory UI you can see the artifacts that were just created and deployed to Artifactory, stored in the appropriate repository.
This concludes our Maven set-up screencast. You can use JFrog Artifactory to run Java builds with Maven, Gradle, Ivy, and Ant, and work with packaging systems of other development platforms: like Nuget, RubyGems, or NPM. Artifactory also offers tight integration with Jenkins, Hudson, TeamCity, Bamboo, or any other CI server. Artifactory is also a great artifact repository for your dev ops needs since it natively supports managing Docker images, Vagrant images, as well as RPM and Debian packaging managers.
You are welcome to visit our user guide to discover more features and our YouTube channel for additional screencasts.