Getting started on Gemfury with Maven βeta

Install library with Maven

Now that you have uploaded the artifact containing your Java library in your Gemfury account, you can use your library as a dependency in a Maven project.

To use your library, you can reference the artifact as a dependency in your project’s pom.xml.

<project xmlns=...>

Next, you will need to add your Gemfury account Maven’s repository, so Maven can find the artifact.

<project xmlns=...>

The USERNAME can be your personal username if the artifact is uploaded in your personal repository, or an organization username if it is uploaded in a shared repository.

Both the dependencies and repositories tags should each be a direct child of your project tag.

If the artifact is set to public, no other setting is needed.

If the artifact is set to private, you will need to specify your deploy access token in the user-specific configurations file used by Maven, which is normally found in ~/.m2/settings.xml.

This is the same configuration as specified in the Configure for remote server authentication section, as part of the Upload your Java library step of this guide.

The resulting settings.xml file should include this:

<settings xmlns=...>

The DEPLOY_TOKEN is your deploy read-only access token for your Gemfury account, and NOPASS is an as-is reserved keyword that Gemfury detects to ignore the password. This is needed, since Maven does not support an empty password in the server setting, and Gemfury only needs the access token to properly authenticate your access.

The usePreemptive setting is required to authenticate into your private Maven repository. Without it, you will only be able to access your public artifacts.

Once you have this configuration in place, start your build:

$ mvn compile
Updating dependencies

If you have updated your library, and you want your project to download the latest version, you can tell Maven to check for updates to its dependencies.

$ mvn dependency:resolve

In addition, if applicable, you may want to specify the newer version of your artifact in the project’s pom.xml dependencies section. Or, if you intend to continuously depend on the latest build of an artifact, you can use Maven’s SNAPSHOT versioning support.