Getting started on Gemfury with Maven

Upload your Java library

Now that you have created your Java library, you can now push the generated artifact into your Gemfury account. To do that, you can use the Maven deploy function.

Configure Maven project

First, you will need to configure your Maven project. Add a new repository entry in the distributionManagement section on the pom.xml of your project with your Repository URL. The distributionManagement tag should be a direct child of your project tag.

The pom.xml should include this:

<project xmlns=...>
  ...
  <distributionManagement>
    <repository>
      <id>fury-push</id>
      <name>Fury</name>
      <url>https://maven.fury.io/ACCOUNT/</url>
    </repository>
  </distributionManagement>
  ...
</project>

The ACCOUNT in the path of your Repository URL is the destination of the artifact. It may be your personal username if uploading to your personal repository, or an organization username if uploading to a shared repository.

Configure for remote server authentication

Second, you will need to configure Maven to use your push token to authenticate your uploads. You can do this 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 your project’s pom.xml file (for example fury), then set username and password to your push token credentials.

The resulting settings.xml file should look like this:

<settings xmlns=...>
  ...  
  <servers>
    <server>
      <id>fury-push</id>
      <username>PUSH_USERNAME</username>
      <password>PUSH_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 artifacts.

Deploy your artifact

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

$ mvn deploy

You can confirm the uploaded artifacts by visiting your Gemfury account’s dashboard.


Next