Installing private Maven artifacts

Once you have signed up for a Gemfury account, you can upload and install Maven packages, using the built-in deployment methods in Maven and Gradle.

Your secret Repository URL

The secret repository URL is the Maven endpoint for your Gemfury account and packages. Do not share this URL to keep your account private. Your Repo-URL has the following format:

https://maven.fury.io/USERNAME/

Uploading packages built by Maven

There are a few guides on the web about creating a Maven package. Your Gemfury account supports Maven’s deployment mechanism using its built-in HTTP transport.

Configure Maven project

To configure Maven, add a new repository entry in the distributionManagement section on the pom.xml of your project with your Repository URL.

The <project> in your pom.xml should include:

<distributionManagement>
  <repository>
    <id>fury</id>
    <name>Fury</name>
    <url>https://maven.fury.io/ACCOUNT/</url>
  </repository>
</distributionManagement>

Configure for remote server authentication

You will need to configure Maven to use your token to authenticate your uploads, in the user-specific configurations file, which is normally found in ~/.m2/settings.xml.

  1. Update or create a ~/.m2/settings.xml file.
  2. Add a server tag under a servers section, with an id that matches the repository id you used in the pom.xml file (for example fury), then set username to your personal token and the keyword NOPASS as your password.

The resulting settings.xml file should look like this:

<settings xmlns=...>
  ...
  <servers>
    <server>
      <id>fury</id>
      <username>USERNAME</username>
      <password>TOKEN</password>
      <configuration>
        <httpConfiguration>
          <all>
            <usePreemptive>true</usePreemptive>
          </all>
        </httpConfiguration>
      </configuration>
    </server>
  </servers>
  ...
</settings>

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

Deploy your package

After the configurations above, you can now use Maven deploy to upload your packages.

mvn deploy

Setup Maven to download packages

To install your packages, you will need to configure Maven to access your Gemfury repository by adding a new repository entry in the repositories section of the pom.xml of your project with your Repository URL.

The <project> in your pom.xml should include:

<repositories>
  <repository>
    <id>fury</id>
    <url>https://maven.fury.io/ACCOUNT/</url>
  </repository>
</repositories>

Then, you can specify the specific package your application depends on, in the <dependencies> section.

After this, you should be able to pull public packages, with

mvn compile

Private packages

To access private packages, you will need to configure Maven with your token, as described in the Configure for remote server authentication section above.

After that, you should be able to pull private packages, with

mvn compile

Uploading packages built by Gradle

Gradle has built-in support to upload packages to Maven repositories using its publish mechanism. Your Gemfury account is fully compatible with this method.

Configure Gradle

To configure Gradle, add a new maven type repository entry in the repositories section (part of publishing configuration) on the build.gradle of your project with your Repository URL.

The resulting build.gradle should include this:

publishing {
  publications {
    jworld(MavenPublication) {
      from components.java
    }
  }

  repositories {
    maven {
      name = "fury"
      url = "https://maven.fury.io/ACCOUNT/"

      authentication {
        basic(BasicAuthentication)
      }

      credentials {
        username = "USERNAME"
        password = "TOKEN"
      }
    }
  }
}

The publications configuration tells Gradle to build a maven type (e.g. MavenPublication) package containing Java code. This is the instruction which produces the Jar file that Gradle will upload to your Gemfury account.

Equivalent Kotlin configuration can be implemented into build.gradle.kts.

Deploy your package

After the configurations above, you can now use Gradle publish to upload your packages.

gradle publish

Keep your token off your code

To keep your token private, you can place it outside the build.gradle file of your project, in a separate gradle.properties file as follows:

furyUsername = USERNAME
furyToken = TOKEN

Then, use the property name in place of your token like this:

      credentials {
        username = furyUsername
        password = furyToken
      }

Setup Gradle to download packages

To install your packages, add your repository URL as a maven type repository in the repositories section on the build.gradle of your project with your Repository URL.

The resulting build.gradle should include this:

  repositories {
    maven {
      name = "fury"
      url = "https://maven.fury.io/ACCOUNT"

      authentication {
        basic(BasicAuthentication)
      }

      credentials {
        username = "USERNAME"
        password = "TOKEN"
      }
    }
  }

The authentication and credentials block is only needed if you need to access private packages. You can omit them if you are only accessing public packages.

With the repository configured, you can specify the specific packages your project depends in the dependencies section.

It is recommended, to keep your credentials outside the Gradle build file. You can follow the steps as described in the Keep your token off your code section.

Equivalent Kotlin configuration can be implemented into build.gradle.kts.