forked from couchbase/couchbase-elasticsearch-connector
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
170 lines (138 loc) · 5.67 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
plugins {
id "com.github.jk1.dependency-license-report" version "1.2"
id 'org.unbroken-dome.test-sets' version '1.5.1'
id 'com.adarshr.test-logger' version '1.5.0'
}
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'application'
repositories {
mavenCentral()
//jcenter() // for testcontainers release candidate
//maven { url 'https://jitpack.io' } // for testcontainers snapshot
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "4.0.1-SNAPSHOT"
// https://github.com/unbroken-dome/gradle-testsets-plugin
testSets {
integrationTest
}
integrationTest.dependsOn(test)
// https://github.com/radarsh/gradle-test-logger-plugin
def runningInJenkins = System.getenv("JENKINS_URL") != null
testlogger {
theme runningInJenkins ? 'plain' : 'mocha'
showStandardStreams runningInJenkins
showPassedStandardStreams runningInJenkins
showSkippedStandardStreams runningInJenkins
showFailedStandardStreams runningInJenkins
}
task exhaustiveTest(group: "Verification", description: "Runs the integration tests against *all* supported server versions") {
doLast {
tasks.withType(Test) {
systemProperty 'com.couchbase.integrationTest.exhaustive', 'true'
}
}
}
exhaustiveTest.finalizedBy(integrationTest)
dependencies {
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.0'
compile 'org.apache.logging.log4j:log4j-core:2.9.1'
compile 'com.couchbase.client:java-client:2.6.1'
compile 'com.couchbase.client:dcp-client:0.20.0'
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.3.2'
compile 'com.orbitz.consul:consul-client:1.2.1'
compile 'com.github.therapi:therapi-json-rpc:0.4.0'
compile 'io.dropwizard.metrics:metrics-json:4.0.3'
compile 'io.dropwizard.metrics:metrics-jvm:4.0.3'
compile 'com.google.guava:guava:26.0-jre'
compile 'net.consensys.cava:cava-toml:0.3.1'
compile 'net.sf.jopt-simple:jopt-simple:5.0.4'
testCompile 'junit:junit:4.12'
testCompile("org.assertj:assertj-core:3.11.1")
integrationTestCompile 'com.jayway.jsonpath:json-path:2.3.0'
def testcontainersVersion = '1.10.1'
integrationTestCompile "org.testcontainers:testcontainers:${testcontainersVersion}"
integrationTestCompile "org.testcontainers:couchbase:${testcontainersVersion}"
//def testcontainersCommit = 'ac05988143e8d433d' // avoid port conflicts between multiple Couchbase containers on same host
//integrationTestCompile "com.github.testcontainers.testcontainers-java:testcontainers:${testcontainersCommit}"
//integrationTestCompile "com.github.testcontainers.testcontainers-java:couchbase:${testcontainersCommit}"
compileOnly 'org.immutables:value:2.6.3'
annotationProcessor 'org.immutables:value:2.6.3'
}
// 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.annotationProcessorGeneratedSourcesDirectory = 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\\\\*')
}
}
mainClassName = "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'
]
extraStartScripts.each { scriptName, driverClass ->
task(scriptName + "-script", group: 'CLI Script Generation', type: CreateStartScripts) {
mainClassName = driverClass
applicationName = scriptName
outputDir = startScripts.outputDir
classpath = startScripts.classpath
}
}
// include the additional start scripts in the distribution
applicationDistribution.into("bin") {
from(tasks.withType(CreateStartScripts))
fileMode = 0755
}
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
]
}
}