-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathbuild.gradle
240 lines (195 loc) · 8.06 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
plugins {
id "com.github.jk1.dependency-license-report" version "2.5"
id 'org.unbroken-dome.test-sets' version '4.1.0'
}
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'application'
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
version = "4.4.12-SNAPSHOT"
def targetJavaRelease = 11
def jvmVersion = "11"
def testJvmVersion = project.findProperty("testJvmVersion") ?: jvmVersion
def jvmVendor = JvmVendorSpec.ADOPTIUM
println "Compiling for Java ${targetJavaRelease} using JVM ${jvmVersion} (${jvmVendor}), testing using JVM ${testJvmVersion}"
tasks.withType(JavaCompile).configureEach { options.release = targetJavaRelease }
java {
toolchain {
languageVersion = JavaLanguageVersion.of(jvmVersion)
vendor = jvmVendor
}
}
// https://github.com/unbroken-dome/gradle-testsets-plugin
testSets {
integrationTest
}
integrationTest {
minHeapSize = "128m"
maxHeapSize = "512m"
jvmArgs '-verbose:gc', '-XX:+HeapDumpOnOutOfMemoryError'
}
tasks.withType(Test) {
testLogging.showStandardStreams = true
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(testJvmVersion)
vendor = jvmVendor
}
}
integrationTest.dependsOn(test)
task exhaustiveTest(group: "Verification", description: "Runs the integration tests against *all* supported server versions") {
doLast {
tasks.withType(Test) {
systemProperty 'com.couchbase.integrationTest.exhaustive', 'true'
}
}
finalizedBy integrationTest
}
dependencies {
implementation 'org.jspecify:jspecify:1.0.0'
implementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1'
implementation 'org.slf4j:jcl-over-slf4j:2.0.12'
implementation 'co.elastic.logging:log4j2-ecs-layout:1.6.0'
implementation 'com.couchbase.client:java-client:3.7.6'
implementation 'com.couchbase.client:dcp-client:0.52.0'
implementation(platform('com.squareup.okhttp3:okhttp-bom:4.12.0'))
implementation 'co.elastic.clients:elasticsearch-java:8.14.3'
implementation('org.opensearch.client:opensearch-java:2.12.0')
implementation("org.opensearch.client:opensearch-rest-client:2.15.0")
implementation('org.apache.httpcomponents.client5:httpclient5:5.3.1')
implementation(platform('software.amazon.awssdk:bom:2.20.26'))
implementation("software.amazon.awssdk:sdk-core")
implementation("software.amazon.awssdk:apache-client")
implementation("software.amazon.awssdk:regions")
implementation("software.amazon.awssdk:auth")
implementation platform('com.fasterxml.jackson:jackson-bom:2.18.2')
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
implementation platform('io.fabric8:kubernetes-client-bom:7.0.0')
implementation 'io.fabric8:kubernetes-client'
implementation 'io.fabric8:kubernetes-httpclient-okhttp'
implementation 'com.github.therapi:therapi-json-rpc:0.5.0'
implementation platform('io.micrometer:micrometer-bom:1.10.5')
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.dropwizard.metrics:metrics-json:4.2.16'
implementation 'io.dropwizard.metrics:metrics-jvm:4.2.16'
implementation 'com.google.guava:guava:33.2.1-jre'
implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'org.apache.tuweni:tuweni-toml:2.0.0'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'info.picocli:picocli:4.7.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.apache.commons:commons-lang3:3.15.0'
testImplementation 'commons-io:commons-io:2.16.1'
testImplementation('org.assertj:assertj-core:3.26.3')
integrationTestImplementation 'com.jayway.jsonpath:json-path:2.9.0'
implementation platform('org.testcontainers:testcontainers-bom:1.20.4')
integrationTestImplementation 'org.testcontainers:testcontainers'
integrationTestImplementation 'org.testcontainers:couchbase'
integrationTestImplementation 'org.testcontainers:elasticsearch'
integrationTestImplementation 'org.opensearch:opensearch-testcontainers:2.1.2'
def immutablesVersion = '2.10.1'
compileOnly "org.immutables:value:${immutablesVersion}"
annotationProcessor "org.immutables:value:${immutablesVersion}"
}
configurations.all {
exclude group: 'commons-logging' // using jcl-over-slf4j instead
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' // always update snapshots instead of waiting 24 hrs
}
// Prohibit snapshot dependencies unless we're building a snapshot
if (!version.endsWith("SNAPSHOT")) {
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.version.endsWith("-SNAPSHOT")) {
throw new GradleException("Can't release with SNAPSHOT dependency: $details.requested")
}
}
}
}
// IntelliJ doesn't play nice with classes generated by annotation processors.
// This dirty workaround aligns Gradle with IDEA's default behavior so we can use org.immutables.
// Assumes IDEA is storing generated sources relative to the module content root,
// using the default directory name of "generated"
ext.generatedFilesDir = file('src/main/generated')
compileJava.options.generatedSourceOutputDirectory = generatedFilesDir
sourceSets.main.java.srcDirs += generatedFilesDir
clean {
delete generatedFilesDir
}
tasks.withType(Tar) {
compression = Compression.GZIP
}
// Patch the start scripts to export the APP_HOME environment variable
// so we can read log4j config and write log files in usual location.
// See https://discuss.gradle.org/t/linux-launcher-script-should-export-app-home-before-starting-the-application/3570
tasks.withType(CreateStartScripts) {
doLast {
unixScript.text = unixScript.text.replace('exec', 'export APP_HOME; exec')
// Apparently the Windows launcher already exposes the variable (NOT VERIFIED)
// tidy up the class path, yeah? Maybe add $APP_HOME/lib-ext as well?
unixScript.text = unixScript.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=\\$APP_HOME/lib/*')
//windowsScript.text = windowsScript.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=%APP_HOME%\\\\lib\\\\*')
}
}
application {
mainClass = "com.couchbase.connector.elasticsearch.ElasticsearchConnector"
applicationDefaultJvmArgs = ['-server']
}
startScripts {
applicationName = 'cbes'
}
def extraStartScripts = [
'cbes-checkpoint-backup' : 'com.couchbase.connector.elasticsearch.cli.CheckpointBackup',
'cbes-checkpoint-restore': 'com.couchbase.connector.elasticsearch.cli.CheckpointRestore',
'cbes-checkpoint-clear' : 'com.couchbase.connector.elasticsearch.cli.CheckpointClear',
'cbes-consul' : 'com.couchbase.connector.elasticsearch.cli.ConsulCli'
]
extraStartScripts.each { scriptName, driverClass ->
Task t = task(scriptName + "-script", group: 'CLI Script Generation', type: CreateStartScripts) {
mainClass = driverClass
applicationName = scriptName
outputDir = startScripts.outputDir
classpath = startScripts.classpath
}
startScripts.dependsOn(t)
}
def requireFileExists(filename) {
if (!file(filename).exists()) throw new GradleException("File '$filename' not found")
return filename
}
application {
def readmeFilename = requireFileExists("DIST_README.txt")
applicationDistribution.from(".") {
include(readmeFilename, requireFileExists("LICENSE"))
rename(readmeFilename, 'README.txt')
}
applicationDistribution.into("notices") {
// https://github.com/jk1/Gradle-License-Report
from(generateLicenseReport)
}
}
def getGitInfo() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty', '--always'
standardOutput = stdout
}
return stdout.toString().trim()
}
def gitInfo = getGitInfo()
//if (gitInfo.contains("dirty")) {
// println "WARNING: workspace is dirty"
//}
processResources {
inputs.property("version", project.property("version"))
inputs.property("gitInfo", gitInfo)
filteringCharset = 'UTF-8'
filesMatching('**/*.properties') {
filter ReplaceTokens, tokens: [
"application.version": project.property("version"),
"git.info" : gitInfo
]
}
}