Allow custom geode integration (#87)

* Add Gradle option to consume Geode as an includeBuild

Building examples has required a published Geode tgz and jars. Use
Gradle's `includeBuild` feature to allow mapping to a custom Geode clone
for integration and API testing. Invoke with:
`./gradlew -Dcomposite -PgeodeCompositeDirectory=../geode build`

* For composite builds, set JVM memroy options for Geode compilation
diff --git a/build.gradle b/build.gradle
index 9bdc417..073ea65 100644
--- a/build.gradle
+++ b/build.gradle
@@ -42,11 +42,17 @@
 }
 
 dependencies {
-    geodeDistribution "org.apache.geode:apache-geode:$geodeVersion@tgz"
-
+    geodeDistribution("org.apache.geode:apache-geode:$geodeVersion@tgz") {
+      if (gradle.usingGeodeCompositeBuild) {
+        targetConfiguration = 'compositeTarget'
+      }
+    }
 }
 
 task installGeode(type: Copy) {
+    if (gradle.usingGeodeCompositeBuild) {
+        dependsOn(gradle.includedBuild('geode').task(':geode-assembly:distTar'))
+    }
     from tarTree(configurations.geodeDistribution.singleFile)
     into buildDir
 }
@@ -150,6 +156,12 @@
             }
         }
     }
+    if (gradle.usingGeodeCompositeBuild) {
+        tasks.withType(JavaCompile) {
+            options.fork = true
+            options.forkOptions.jvmArgs += ['-Xmx3g']
+        }
+    }
 
     task runAll(dependsOn: [verifyNoMembersRunning, start, run, stop, waitForExitingMembers])
     start.mustRunAfter verifyNoMembersRunning
diff --git a/gradle/release.gradle b/gradle/release.gradle
index 5b1d677..2a7f7fe 100644
--- a/gradle/release.gradle
+++ b/gradle/release.gradle
@@ -63,6 +63,7 @@
         exclude 'KEYS'
         exclude '**/.gradle'
         exclude '**/build/**'
+        exclude '**/out/**'
         exclude '**/.project'
         exclude '**/.classpath'
         exclude '**/.settings/**'
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 21818fa..e36600c 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
diff --git a/settings.gradle b/settings.gradle
index c9408ec..57d108d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -40,3 +40,24 @@
 include 'jdbc'
 include 'sessionState'
 include 'colocation'
+
+// Logic for defining a custom Geode clone for integration with this project
+// Define `-PgeodeCompositeDirectory` to your geode root, default `../geode`
+// Define `-Dcomposite` to enable Gradle includeBuild feature
+def geodeCompositePropertyName = 'geodeCompositeDirectory'
+def geodePath = hasProperty(geodeCompositePropertyName) ? geodeCompositeDirectory : '../geode'
+def geodeDirectory = file(geodePath).absolutePath
+def geodeDirectoryExists = file(geodeDirectory).exists()
+def compositeBuildEnabled = System.getProperty("composite") != null
+gradle.ext.usingGeodeCompositeBuild = compositeBuildEnabled && geodeDirectoryExists
+
+if (gradle.ext.usingGeodeCompositeBuild) {
+  includeBuild(geodeDirectory) {
+    it.dependencySubstitution {
+      // Any submodule used by examples must should be listed here
+      it.substitute it.module("org.apache.geode:geode-cq") with it.project(':geode-cq')
+      it.substitute it.module("org.apache.geode:geode-core") with it.project(':geode-core')
+      it.substitute it.module("org.apache.geode:apache-geode") with it.project(':geode-assembly')
+    }
+  }
+}