Module Development Maven Dependencies - tsgrp/OpenMigrate GitHub Wiki

Maven Dependencies

As a part of the refactor that brought OpenMigrate into the Gradle build process we wanted to remove jars from being stored directly in our SVN repo and allow for them to be pulled in via Maven Central / Nexus, which are nothing but repositories full of jars that Gradle can pull from and then cache for future usage. Going forward every module should be utilizing dependencies in this way and there should no longer be jars stored in our SVN repo.

Each module has a build.gradle and a part of this is a section called dependencies. This is where we define the projects we depend on as well as the jars that we want to pull from Maven. The structure for how you define a particular jar dependency is as follows in the given example.

Ex. extMavenDeps group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'

For each jar that you need to pull from Maven we need to get the group, name, and version. This information can easily be pulled from Maven Central (see Maven Central Link) if you look up the jar and its version there.

When you find a particular jar dependency you want to pull in you can see there are tabs that show how to reference the dependency for different build processes. Since we are using Gradle, you would click on the Gradle tab and it would show you what you need to put in your build.gradle.

You will notice in the above picture the information that was mentioned we need to grab with the exception that it has compile group:... instead of extMavenDeps group:.... When we actually place the dependency in the build.gradle we need to make sure we change compile to extMavenDeps correctly. Otherwise our code will compile but the DIST will not contain the jar itself for deployment.

NOTE: Examples of build.gradle files can be found throughout OpenMigrate. Be sure to refer to those while authoring your own gradle configs to supplement the examples that are provided in this guide.