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
<project xmlns=...> ... <dependencies> <dependency> <groupId>com.mycompany.foo</groupId> <artifactId>foolib</artifactId> <version>1.0-SNAPSHOT</version> <scope>test</scope> </dependency> </dependencies> ... </project>
Next, you will need to add your Gemfury account Maven’s repository, so Maven can find the artifact.
<project xmlns=...> ... <repositories> <repository> <id>fury</id> <url>https://maven.fury.io/USERNAME/</url> </repository> </repositories> ... </project>
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.
repositories tags should each be a direct child of your
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
settings.xml file should include this:
<settings xmlns=...> ... <servers> <server> <id>fury</id> <username>DEPLOY_TOKEN</username> <password>NOPASS</password> <configuration> <httpConfiguration> <all> <usePreemptive>true</usePreemptive> </all> </httpConfiguration> </configuration> </server> </servers> ... </settings>
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.
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
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.