Building Java Projects with Maven

Apache Maven is a software management tool that can be used to build, install, and distribute Java-based projects. You can retrieve the PubSub+ Messaging API for Java with either Maven (pom.xml) or Gradle (build.gradle).

For the Java API, you can:

  • obtain the Solace Java API artifacts from Maven Central
  • install Solace Java API  artifacts in a local corporate Maven repository
  • deploy Solace Java API  artifacts to remote repositories

To build a project with Maven that requires the Java API, the following artifacts are required:

  • solace-messaging-client-1.x.x.jar — the Solace Java messaging API libraries
  • The JCSMP artifacts are required:
    • sol-jcsmp-10.x.x.jar — the Solace JCSMP messaging API libraries
    • solsuite-10.x.x.pom — Solace API project configuration file
    • sol-common-10.x.x.jar — Solace Java messaging API utilities

Obtaining Artifacts from Maven Central

The PubSub+ Java API is available on Maven Central. To add the Solace Java API to your Maven or Gradle project, use the following examples:

Using Maven (pom.xml):

<dependencies>
       <dependency>
               <groupId>com.solace</groupId>
               <artifactId>solace-messaging-client</artifactId>
               <version>1.1.0</version>
       </dependency>
</dependencies>

Using Gradle (build.gradle):

...
...
dependencies {
// https://mvnrepository.com/artifact/com.solace/solace-messaging-client
implementation group: 'com.solace', name: 'solace-messaging-client', version: '1.1.0'
...
}

Installing Artifacts Locally

To use Solace Java API or JCSMP artifacts from Solace as Maven dependencies, you can install the Solace .jar and .pom files into your local repository.

To install a .jar or .pom file locally, enter the following command in a terminal window:

mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pom-file> -Dmaven.repo.local=<path-to-local-repository>

For example, to install a .jar file for JCSMP:

$ mvn install:install-file
 -Dfile=/downloads/sol-jcsmp/lib/sol-jcsmp-10.x.x.jar
    -DpomFile=/downloads/sol-jcsmp/lib/sol-jcsmp-10.x.x.pom
 -Dmaven.repo.local=./.repository
 $ ls /tmp/.repository/com/solace/sol-jcsmp/10.x.x/
 _remote.repositories sol-jcsmp-10.x.x.jar sol-jcsmp-10.x.x.pom

Example of installing a .pom file for JCSMP:

$ mvn install:install-file -Dfile=/downloads/sol-jcsmp/lib/solsuite-10.x.x.pom 
  -DpomFile=/downloads/sol-jcsmp/lib/solsuite-10.x.x.pom 
  -Dmaven.repo.local=./.repository

Deploying Artifacts to Remote Repositories

To use Solace Java API or JCSMP artifacts as Maven dependencies, you can deploy the Solace .jar and .pom files to a remote Maven remote repository for your project.

To deploy a .jar or a .pom file to a Maven remote repository, enter the following command in a terminal window:

mvn deploy:deploy-file
  -Dfile=<path-to-file>
  -DpomFile=<path-to-pom-file>
  -DrepositoryId=release
  -Durl=<repository-url>