Building JMS Projects with Maven

Apache Maven is a software management tool that can be used to build, install, and distribute Java-based projects. With Apache Maven, you can:

  • obtain PubSub+ Messaging API for JMS artifacts from Maven Central
  • install PubSub+ Messaging API for JMS artifacts in a local corporate Maven repository
  • deploy PubSub+ Messaging API for JMS artifacts to remote repositories

To build a project with Maven, the PubSub+ Messaging API for JMS requires the following artifacts:

  • sol-jms-10.x.x.jar—the PubSub+ Messaging API for JMS libraries
  • sol-jcsmp-10.x.x.jar—the PubSub+ Messaging API for Java libraries
  • solsuite-10.x.x.pom—Solace API project configuration file
  • sol-common-10.x.x.jar—PubSub+ Messaging API for Java utilities

Obtaining Artifacts from Maven Central

To obtain the required Solace JMS artifacts for your project from the Maven Central Repository, you must declare the following dependency in your pom.xml file:

<dependency>
 <groupId>com.solacesystems</groupId>
 <artifactId>sol-jms</artifactId>
 <version>10.25.x</version>
</dependency>

Using JMS 1.1 with the PubSub+ JMS API

Some applications may need to continue to use the Geronimo 1.1 Spec if they have components that are dependent on version 1.1 of the JMS Specification. For versions 10.20 and later of the PubSub+ Messaging API for JMS, you need to use a compatibility layer to allow backwards compatibility with applications that have Geronimo JMS 1.1 dependencies (geronimo-jms_1.1_spec). You also need to exclude the Geronimo JMS 2.0 specifications to avoid conflicts. To achieve this, add the following to your pom.xml file:

<dependency>
	<groupId>com.solacesystems</groupId>
	<artifactId>sol-jms</artifactId>
	<version>10.20.x</version>
	<exclusion>
		<groupId>org.apache.geronimo.specs</groupId>
		<artifactId>geronimo-jms_2.0_spec</artifactId>
	</exclusion>
</dependency>
						
<dependency>
	<groupId>com.solacesystems</groupId>
	<artifactId>sol-jms-compat-1.1</artifactId>
	<version>1.0.0</version>
</dependency>		

Installing Artifacts Locally

To use PubSub+ Messaging API for JMS artifacts as Maven dependencies, you must install the PubSub+ JMS jar files and pom.xml files into your local repository.

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

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

Example of installing a .jar:

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

Example of installing a pom.xml file:

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

Deploying Artifacts to Remote Repositories

To use PubSub+ Messaging API for JMS artifacts as Maven dependencies, you must deploy the jar and pom.xml files to a remote Maven remote repository for your project.

To deploy a jar or a pom.xml 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-pomfile>
  -DrepositoryId=release
  -Durl=<repository-url>