2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 id "org.nosphere.apache.rat" version "0.3.0"
20 id "com.diffplug.gradle.spotless" version "3.0.0"
21 id "de.undercouch.download" version "3.1.2"
26 if (geodeRepositoryUrl != "") {
28 url geodeRepositoryUrl
33 url 'http://repository.apache.org/snapshots'
38 def installDir = "$buildDir/apache-geode-${geodeVersion}"
45 geodeDistribution "org.apache.geode:apache-geode:$geodeVersion"
48 task installGeode(type: Copy) {
49 from zipTree(configurations.geodeDistribution.singleFile)
57 compile "org.apache.geode:geode-core:$geodeVersion"
59 testCompile "com.jayway.awaitility:awaitility:$awaitilityVersion"
60 testCompile "junit:junit:$junitVersion"
61 testCompile "org.mockito:mockito-core:$mockitocoreVersion"
62 testCompile "com.github.stefanbirkner:system-rules:$systemrulesVersion"
63 testCompile "org.assertj:assertj-core:$assertjVersion"
64 compile "org.apache.logging.log4j:log4j-core:$log4jVersion"
65 runtime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
69 archiveName "${baseName}.${extension}"
79 clean.finalizedBy cleanServer
81 def geodePath = "${System.env.PATH}${System.getProperty('path.separator')}${installDir}/bin"
82 task start(type: Exec, dependsOn: [installGeode, build, cleanServer]) {
84 environment 'GEODE_HOME', installDir
85 environment 'PATH', geodePath
86 commandLine 'sh', '-c', "gfsh run --file=${projectDir}/scripts/start.gfsh"
89 task stop(type: Exec, dependsOn: installGeode) {
91 environment 'GEODE_HOME', installDir
92 environment 'PATH', geodePath
93 commandLine 'sh', '-c', "gfsh run --file=${projectDir}/scripts/stop.gfsh"
96 task run(type: JavaExec, dependsOn: build) {
97 description = 'Run example'
98 classpath = sourceSets.main.runtimeClasspath
99 main = "org.apache.geode_examples.${project.name}.Example"
102 task waitForExitingMembers(type: Exec) {
103 workingDir projectDir
104 environment 'GEODE_HOME', installDir
105 environment 'PATH', geodePath
107 commandLine 'sh', '-c', "" +
109 "echo \"Waiting at most \$TIMEOUT seconds for all members to shut down...\" ;" +
110 "while pgrep -f \"(Server|Locator)Launcher\" > /dev/null ; do" +
113 " TIMEOUT=\$((\$TIMEOUT - 1)) ;" +
114 " if [ \$TIMEOUT -eq 0 ] ; then" +
121 // We use exit code 10 to avoid conflict with pgrep exit codes.
122 if (execResult.exitValue == 10) {
123 throw new GradleException("A member process persisted beyond permitted timeout. Aborting.")
124 } else if (execResult.exitValue != 0) {
125 throw new GradleException("waitForExistingMembers failed with exit code: " + execResult.exitValue)
130 task verifyNoMembersRunning(type: Exec) {
131 workingDir projectDir
132 environment 'GEODE_HOME', installDir
133 environment 'PATH', geodePath
135 commandLine 'sh', '-c', "echo \"Looking for existing member processes...\" ; " +
136 "pgrep -f \"(Server|Locator)Launcher\" ; "
138 if (execResult.exitValue == 0) {
139 throw new GradleException("Existing members detected. Examples expect a clean environment in which to run.")
144 task runAll(dependsOn: [verifyNoMembersRunning, start, run, stop, waitForExitingMembers])
145 start.mustRunAfter verifyNoMembersRunning
146 run.mustRunAfter start
147 stop.mustRunAfter run
148 waitForExitingMembers.mustRunAfter stop
151 apply from: "gradle/spotless.gradle"
152 apply from: "gradle/ide.gradle"
153 apply from: "gradle/rat.gradle"
154 apply from: "gradle/release.gradle"