Guide-Maven

Introduction

This guide will walk you through the process of creating a Java library in a Maven project, push a built artifact to Gemfury, and then import it as a dependency in another Maven project. Before you get started, be sure you have the following: Local Maven installation (3.3.1+) Gemfury account Maven is a project management tool, commonly used in the Java ecosystem. It can be used to specify project information for Java libraries, so the library can easily be linked in other Maven projects. 

Creating a Java library

To get started in creating your Java library, initialize your Maven project with mvn archetype:generate: $ mvn archetype:generate -DgroupId=com.mycompany.foo -DartifactId=foolib \ -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 \ -DinteractiveMode=false $ cd foolib Please take note to use your own values for groupId and artifactId. This command will create an initial pom.xml file to describe your project. The file will contain the project’s name and its dependencies. At this point, you may customize the generated pom. 

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. 

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=...> ... <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. 

Upload with Gradle

Gradle has built-in support to upload packages to Maven repositories using its publish plugin. 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) in the build.gradle.kts of your project with your Repository URL. The resulting build.gradle.kts should include this: plugins { id("maven-publish") } publishing { repositories { maven { name = "furyMaven" url = uri("https://maven. 

Install library with Gradle

You can use a library from your Gemfury account as a dependency in a Gradle project. To do that, you can reference the artifact as a dependency in your project’s build.gradle.kts: dependencies { implementation("com.example.group:artifact") } Next, you will add your Gemfury Gradle repository: repositories { maven { url = uri("https://maven.fury.io/ACCOUNT/") } } If the artifact is set to public, no other settings are needed. If the artifact is set to private, you will need to expand the above entry with this authentication configuration: