-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
197 lines (179 loc) · 8.04 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id "org.nosphere.apache.rat" version "0.7.1"
id "com.diffplug.spotless" version "6.16.0"
id "de.undercouch.download" version "4.0.4"
}
allprojects {
repositories {
if (!gradle.usingGeodeCompositeBuild) {
maven {
if (project.getProperty('gemfireRepositoryUrl').contains('broadcom.com') || project.getProperty('gemfireRepositoryUrl').contains('commercial-repo.pivotal.io')) {
credentials {
username "$gemfireReleaseRepoUser"
password "$gemfireReleaseRepoPassword"
}
}
url project.getProperty('gemfireRepositoryUrl')
content {
includeGroup 'com.vmware.gemfire'
}
}
}
if(project.hasProperty("useMavenLocal")) {
mavenLocal()
}
mavenCentral()
}
}
def installDir = System.getenv('GEMFIRE_HOME') ?: System.getenv('GEODE_HOME')
task checkEnv {
if (installDir==null || installDir.isEmpty()) {
throw new GradleException("Please export GEMFIRE_HOME=<the top-level directory extracted from your GemFire .tgz> (if this message persists, you may also need to ./gradlew --stop)")
} else {
println("GemFire directory is $installDir")
}
if (project.getProperty('gemfireRepositoryUrl').contains('commercial-repo.pivotal.io')) {
if (!project.hasProperty("gemfireReleaseRepoUser") || gemfireReleaseRepoUser.isEmpty()) {
throw new GradleException("Please set gemfireReleaseRepoUser in gradle.properties to the email address you registered at https://commercial-repo.pivotal.io/")
}
if (!project.hasProperty("gemfireReleaseRepoPassword") || gemfireReleaseRepoPassword.isEmpty()) {
throw new GradleException("Please set gemfireReleaseRepoPassword in gradle.properties to the https://commercial-repo.pivotal.io/ password for $gemfireReleaseRepoUser")
}
}
if (project.getProperty('gemfireRepositoryUrl').contains('broadcom.com')) {
if (!project.hasProperty("gemfireReleaseRepoUser") || gemfireReleaseRepoUser.isEmpty()) {
throw new GradleException("Please set gemfireReleaseRepoUser in gradle.properties to the email address you registered at https://support.broadcom.com/")
}
if (!project.hasProperty("gemfireReleaseRepoPassword") || gemfireReleaseRepoPassword.isEmpty()) {
throw new GradleException("Please set gemfireReleaseRepoPassword in gradle.properties to the access token (without quotes) for $gemfireReleaseRepoUser found by navigating to https://support.broadcom.com/ > My Downloads - Tanzu > Vmware Tanzu GemFire > VMware Tanzu GemFire > Show All Releases then click on green icon to the right of Click Green Token for Repository Access")
}
}
}
configurations {
compositeTarget
gemfireDistribution
}
subprojects {
apply plugin: 'java-library'
dependencies {
// All callouts to com.vmware.gemfire here, need to be specified in settings.gradle
// for composite build to work
api(platform("com.vmware.gemfire:gemfire-all-bom:$gemfireVersion"))
implementation("com.vmware.gemfire:gemfire-core")
implementation("com.vmware.gemfire:gemfire-cq")
implementation("com.vmware.gemfire:gemfire-logging")
implementation('com.google.guava:guava')
implementation('org.apache.commons:commons-lang3')
implementation("org.apache.logging.log4j:log4j-core")
testImplementation("org.awaitility:awaitility")
testImplementation("junit:junit")
testImplementation("org.mockito:mockito-core")
testImplementation("com.github.stefanbirkner:system-rules")
testImplementation("org.assertj:assertj-core")
testImplementation('org.apache.httpcomponents:httpcore')
testImplementation('org.apache.httpcomponents:httpclient')
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl"
}
project.version = null
jar {
}
task cleanServer {
doLast {
delete 'locator'
delete 'locator-ln'
delete 'locator-ln1'
delete 'locator-ln2'
delete 'locator-ny'
delete 'server1'
delete 'server2'
delete 'server-ln-1'
delete 'server-ln-2'
delete 'server-ny-1'
delete 'server-ny-2'
}
}
clean.finalizedBy cleanServer
task start(type: Exec, dependsOn: [checkEnv, build, cleanServer]) {
workingDir projectDir
environment 'GEODE_HOME', installDir
commandLine 'sh', '-c', "$installDir/bin/gfsh run --file=${projectDir}/scripts/start.gfsh"
}
task stop(type: Exec, dependsOn: checkEnv) {
workingDir projectDir
environment 'GEODE_HOME', installDir
commandLine 'sh', '-c', "$installDir/bin/gfsh run --file=${projectDir}/scripts/stop.gfsh"
}
task run(type: JavaExec, dependsOn: build) {
description = 'Run example'
classpath = sourceSets.main.runtimeClasspath
main = "com.vmware.gemfire.examples.${project.name}.Example"
}
task waitForExitingMembers(type: Exec) {
workingDir projectDir
environment 'GEODE_HOME', installDir
ignoreExitValue true
commandLine 'sh', '-c', "" +
"TIMEOUT=120 ;" +
"echo \"Waiting at most \$TIMEOUT seconds for all members to shut down...\" ;" +
"while pgrep -f \"(Server|Locator)Launcher\" > /dev/null ; do" +
" printf \".\" ; " +
" sleep 1 ;" +
" TIMEOUT=\$((\$TIMEOUT - 1)) ;" +
" if [ \$TIMEOUT -eq 0 ] ; then" +
" echo \"\" ;" +
" exit 10 ;" +
" fi ;" +
"done ;" +
"echo \"\""
doLast {
// We use exit code 10 to avoid conflict with pgrep exit codes.
if (executionResult.orNull.exitValue == 10) {
throw new GradleException("A member process persisted beyond permitted timeout. Aborting.")
} else if (executionResult.orNull.exitValue != 0) {
throw new GradleException("waitForExistingMembers failed with exit code: " + executionResult.orNull.exitValue)
}
}
}
task verifyNoMembersRunning(type: Exec) {
workingDir projectDir
environment 'GEODE_HOME', installDir
ignoreExitValue true
commandLine 'sh', '-c', "echo \"Looking for existing member processes...\" ; " +
"pgrep -f \"(Server|Locator)Launcher\" ; "
doLast {
if (executionResult.orNull.exitValue == 0) {
throw new GradleException("Existing members detected. Examples expect a clean environment in which to run.")
}
}
}
if (gradle.usingGeodeCompositeBuild) {
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs += ['-Xmx3g']
}
}
task runAll(dependsOn: [verifyNoMembersRunning, start, run, stop, waitForExitingMembers])
start.mustRunAfter verifyNoMembersRunning
run.mustRunAfter start
stop.mustRunAfter run
waitForExitingMembers.mustRunAfter stop
}
apply from: "gradle/spotless.gradle"
apply from: "gradle/ide.gradle"
apply from: "gradle/rat.gradle"