Field Mobility

Dependency Management with ArcGIS Runtime SDK for Java

ArcGIS Runtime SDK for Java 100.0.0 now supports downloading the SDK through dependency management.  Most projects are not self-contained, instead they require dependent libraries to be compiled or tested.  In the case of ArcGIS Java projects the requirement includes a Java Jar file, native libraries, and resources.  Furthermore, our Java Jar file has dependencies on third party SDK’s, these are called transitive dependencies.  Dependency management can greatly simplify maintaining multi-module dependency projects and the ArcGIS Runtime SDK for Java now supports Gradle and Maven dependency management workflows. 

Custom Maven Repository

We distribute both our Gradle and Maven dependencies and plugins through a custom maven repository https://esri.bintray.com/arcgis.  You provide this URL to your projects build scripts to include it as a server to discover the ArcGIS Java SDK Gradle and Maven plugins.

Gradle

Gradle is an open source build automation tool that uses Groovy as it’s domain specific language (DSL).  With the release of ArcGIS Java 100.0.0 we include a custom Gradle plugin to handle all of the dependencies required by the SDK.

There are 4 requirements you must add to your build.gradle buildscript:

  1. Apply the ArcGIS Java SDK Plugin
  2. Provide the custom maven repository url
  3. Add the ArcGIS Java SDK plugin classpath dependency
  4. Add the version of the ArcGIS SDK
The groovy code below shows how to add these 4 requirements in a simplified build.gradle buildscript.

[sourcecode language=”java” title=”build.gradle”]
// apply the ArcGIS Java SDK plugiun
apply plugin: ‘com.esri.arcgisruntime.java’

buildscript {
repositories {
// provide custom maven url
maven { url ‘https://esri.bintray.com/arcgis’ }
}
dependencies {
// ArcGIS Java plugin dependency
classpath ‘com.esri.arcgisruntime:gradle-arcgis-java-plugin:1.0.0’
}
}
// specify the Java SDK version version
arcgis.version = ‘100.0.0’
[/sourcecode]

The SDK’s native libraries and resources will be downloaded to $USER_HOME/.arcgis/[version], e.g. $USER_HOME/.arcgis/100.0.0. You should see the log messages the first time you build the project indicating that the libs and resources are being downloaded.

You can see the Gradle developer workflow in our Gradle Callout demo. Gradle is also used in the ArcGIS Java SDK Samples. We recommend reading Getting Started with Gradle if you are new to Gradle.

Maven

Maven is an open source build automation tool that uses XML for declaring project configuration. To pull the plugin you need to provide a pluginRepositories config and include the plugin in your build config:

[sourcecode language=”xml”]
<pluginRepositories>
<pluginRepository>
<id>esri-arcgis</id>
<url>https://esri.bintray.com/arcgis</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.0.0</version>
</configuration>
</plugin>
</plugins>
</build>
[/sourcecode]

Once you have the plugin it will need to know where the SDK libraries are located. You do this with the following SDK dependency:

[sourcecode language=”xml”]
<dependencies>
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.0.0</version>
</dependency>
</dependencies>
[/sourcecode]

As with Gradle, the SDK’s native libraries and resources will be downloaded to $USER_HOME/.arcgis/[version] directory. Below is the full requirements you need in your apps POM file:

[sourcecode language=”xml” title=”pom.xml”]
<project>
<!– Project configuration… –>
<repositories>
<repository>
<id>esri-arcgis</id>
<url>https://esri.bintray.com/arcgis</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>esri-arcgis</id>
<url>https://esri.bintray.com/arcgis</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.0.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.0.0</version>
</configuration>
</plugin>
</plugins>
</build>
</project>
[/sourcecode]

You can see the maven developer workflow in our Maven Callout demo. We recommend reading Maven in 5 minutes if you are new to Maven.

Next Article

ArcGIS Pro Tips: Scale-Based Symbol Sizing

Read this article