The simplest way to manage and organize your Java dependencies is with a Maven or Gradle repository. You need reliable, secure, consistent and efficient access to your dependencies that are shared across your team, in a central location. Including a place to set up multiple registries, that work transparently with the Maven and Gradle clients.
With the JFrog free cloud subscription, including JFrog Artifactory, Xray and Pipelines, you can set up a free local, remote and virtual Maven/Gradle Registry in minutes. This blog post will take you through the steps.
Before you start
Here’s what you’ll need:
- Maven installed or Gradle installed
- JFrog self-hosted subscription or JFrog cloud subscription
- JFrog CLI installed
Step 1: Login to your environment
Login using the default username: admin, and password: password for the on-prem installation, or the credentials provided to you by email for the cloud installation.
Step 2: Add local Maven/Gradle repository
Used to store your custom Maven / Gradle you will create in a later step. Navigate to the Administration Module. Expand the Repositories menu and click on the Repositories menu item.
Add a new Local Repository with the Maven / Gradle package type. Enter the Repository Key “maven-challenge-local” or “gradle-challenge-local” and keep the rest of the default settings.
Step 3: Add remote Maven/Gradle repository
Used as a caching proxy, to store 3rd party from https://mvnrepository.com/
Click on the Remote tab on the Repositories page and add a new Remote Repository with the Maven / Gradle package type. Enter the Repository Key “maven-challenge-remote” or “gradle-challenge-local” and keep the rest of the default settings.
Step 4: Add virtual Maven / Gradle repository
Used when creating your custom Maven / Gradle image.
Click on the Virtual tab on the Repositories page and add a new Virtual Repository with the Maven / Gradle package type. Enter the Repository Key “Maven / Gradle” and add the local and remote Maven / Gradle repositories you created in Steps 2 and 3 (move them from Available Repositories to Selected Repositories using the arrow buttons). The order of these repositories in the list will determine the order used to resolve the dependencies required for building your Maven / Gradle image. Select your local repository that you created in Step 2 as the Default Deployment Repository. The Default Deployment Repository is the repository that the Maven / Gradle dependencies you build will be pushed to. Keep the rest of the default settings.
Step 5: Fork the JFrog Maven / Gradle example GitHub repo
This repository contains a simple you will use to build your project.
Step 6: Configure JFrog CLI
Configure JFrog CLI, a smart client that provides a simple interface that automates access to JFrog products simplifying our automation scripts.
- Configure the Artifactory server.
$ jfrog rt c
- Take the following steps to build the project with Maven/Gradle and resolve the project dependencies from Artifactory.
- Move to the root project directory (cd
- Configure the project’s repositories.
$ jfrog rt mvn-config
$ jfrog rt gradle-config
- Build the project with resolve the project dependencies from Artifactory.
$ jfrog rt mvn clean install -f path/to/pom-file --build-name maven-challenge --build-number 1.0.0
$ jfrog rt gradle clean artifactoryPublish -b path/to/build.gradle --build-name gradle-challenge --build-number 1.0.0
- Publish the build info to Artifactory.
$ jfrog rt bp maven-challenge 1.0.0
$ jfrog rt bp gradle-challenge 1.0.0
Step 8: View your repository
Navigate to the Application Module, in the Platform UI, expand the Artifactory menu and click the Artifacts menu item. Here you’ll be able to see the details of your new artifacts.
Your Maven/Gradle repository
Once you’re done and configured your Maven/Gradle repository, you’ll be able to store all your dependencies in your local, remote and virtual repositories. Here’s how it will look:
Now, all that’s left is for you to try it for yourself.