forked from alexklibisz/elastiknn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
305 lines (273 loc) · 11.7 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
buildscript {
ext {
esVersion = '7.17.5'
luceneVersion = '8.11.1'
elastic4sVersion = '7.17.2'
circeVersion= '0.14.1'
circeGenericExtrasVersion= '0.14.1'
scalaShortVersion = '2.13'
scalaFullVersion = '2.13.6'
zioVersion = '1.0.1'
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
classpath 'gradle.plugin.com.github.maiflai:gradle-scalatest:0.32'
classpath "org.elasticsearch.gradle:build-tools:${esVersion}"
}
}
allprojects {
setGroup('com.klibisz.elastiknn')
// Use -Pversion=foo123 to override the version. Otherwise uses the version file.
if (version != 'unspecified') setVersion(version)
else setVersion(rootProject.file('version').getText().strip())
repositories {
mavenCentral()
mavenLocal()
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
// Make sub-projects easy to reference.
Project api4s = project(':api4s')
Project benchmarks = project(':benchmarks')
Project clientElastic4s = project(':client-elastic4s')
Project clientJava = project(':client-java')
Project lucene = project(':lucene')
Project models = project(':models')
Project plugin = project(':plugin')
Project testing = project(':testing')
// Utility to apply multiple configuration closures to a single project.
// TODO: Why can't you just chain .configure(closure1).configure(closure2)...?
def configure(Project p, List<Closure> configClosures) {
configClosures.forEach { configure(p, it) }
}
def scalaProjectConfig = {
apply plugin: 'scala'
tasks.withType(ScalaCompile) {
scalaCompileOptions.setAdditionalParameters(List.of("-Xfatal-warnings", "-Ywarn-unused:imports"))
}
task unifiedScaladocs(type: ScalaDoc, description: 'Generate unified scaladocs', group: 'Documentation') {
Set docProjects = subprojects.findAll { it.plugins.hasPlugin('scala') }
destinationDir = file("${rootProject.buildDir}/docs/scaladoc")
title = "$project.name $version"
scalaDocOptions = new ScalaDocOptions()
subprojects.each { proj ->
if (docProjects.contains(proj.name)) {
proj.tasks.withType(ScalaDoc).each {
source += proj.sourceSets.main.allJava
source += proj.sourceSets.main.allScala
classpath += proj.sourceSets.main.compileClasspath
excludes += scaladoc.excludes
includes += scaladoc.includes
}
}
}
}
}
def publishConfig(String projectDescription, boolean isScala = false) {
return {
// Have to do it this way because gradle.properties doesn't expand `~`, `$HOME`, etc.
ext."signing.secretKeyRingFile" = "${System.getProperty("user.home")}/.gnupg/secring.gpg"
apply plugin: 'maven-publish'
apply plugin: 'signing'
task sourceJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar) {
classifier 'javadoc'
from javadoc.destinationDir
}
publishing {
publications {
maven(MavenPublication) {
artifactId = isScala ? "${project.name}_${scalaShortVersion}" : project.name
from components.java
artifact tasks.sourceJar
artifact tasks.javadocJar
pom {
groupId = "com.klibisz.elastiknn"
name = "${rootProject.group}:${artifactId}"
description = projectDescription
url = 'https://github.com/alexklibisz/elastiknn'
licenses {
license {
name = 'Apache 2.0'
url = 'https://choosealicense.com/licenses/apache-2.0/'
}
}
developers {
developer {
id = 'alexklibisz'
name = 'Alex Klibisz'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/alexklibisz/elastiknn.git'
developerConnection = 'scm:git:ssh://github.com/alexklibisz/elastiknn.git'
url = 'https://github.com/alexklibisz/elastiknn'
}
}
}
}
repositories {
maven {
url = version.contains('SNAPSHOT') ? "https://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username = project.properties.getOrDefault('sonatypeUsername', 'wrong')
password = project.properties.getOrDefault('sonatypePassword', 'wrong')
}
}
}
}
signing {
sign publishing.publications
}
}
}
configure(api4s, List.of(
scalaProjectConfig,
publishConfig("Scala case classes and JSON codecs for the Elastiknn JSON API", true),
{
dependencies {
implementation "org.elasticsearch:elasticsearch-x-content:${esVersion}"
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
}
}
))
configure(benchmarks, List.of(
scalaProjectConfig,
{
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
application {
mainClassName = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'com.klibisz.elastiknn.benchmarks.Enqueue'
}
shadowJar {
// This is needed to preserve the META-INF directory from lucene-core.
mergeServiceFiles()
}
dependencies {
implementation clientElastic4s
implementation lucene
implementation models
implementation plugin
implementation "ch.qos.logback:logback-classic:1.2.3"
implementation "com.amazonaws:aws-java-sdk-s3:1.11.781"
implementation "com.github.scopt:scopt_${scalaShortVersion}:4.0.0-RC2"
implementation "com.nrinaudo:kantan.csv-generic_${scalaShortVersion}:0.6.1"
implementation "dev.zio:zio_${scalaShortVersion}:${zioVersion}"
implementation "dev.zio:zio-logging-slf4j_${scalaShortVersion}:0.4.0"
implementation "dev.zio:zio-streams_${scalaShortVersion}:${zioVersion}"
implementation "io.circe:circe-generic-extras_${scalaShortVersion}:${circeGenericExtrasVersion}"
implementation "io.circe:circe-parser_${scalaShortVersion}:${circeVersion}"
// Without this you get a warning: WARNING: JAXB is unavailable. Will fallback to SDK implementation which may be
// less performant.If you are using Java 9+, you will need to include javax.xml.bind:jaxb-api as a dependency.
implementation 'javax.xml:jaxb-api:2.1'
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
}
}))
configure(clientElastic4s, List.of(
scalaProjectConfig,
publishConfig("Scala client for Elastiknn, based on elastic4s", true),
{
dependencies {
api api4s
api "com.sksamuel.elastic4s:elastic4s-client-esjava_${scalaShortVersion}:${elastic4sVersion}"
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
}
}))
configure(clientJava, List.of(
publishConfig("Java APIs for Elastiknn, intended for use with Elasticsearch REST clients", false),
{
dependencies {
implementation "org.elasticsearch:elasticsearch:${esVersion}"
}
}
))
configure(models, List.of(
publishConfig("Exact and approximate similarity models used in Elastiknn", false)))
configure(lucene, List.of(
publishConfig("Custom Lucene queries used in Elastiknn"),
{
dependencies {
implementation models
implementation "org.apache.lucene:lucene-core:${luceneVersion}"
}
}))
configure(plugin, List.of(scalaProjectConfig, {
apply plugin: 'elasticsearch.esplugin'
configurations {
all {
// Needed to resolve scala minor version conflicts.
resolutionStrategy.preferProjectModules()
}
}
esplugin {
name 'elastiknn'
description 'Elasticsearch plugin for exact and approximate nearest neighbors search on sparse and dense vectors.'
classname 'com.klibisz.elastiknn.ElastiknnPlugin'
licenseFile rootProject.file('LICENSE.txt')
noticeFile rootProject.file('NOTICE.txt')
}
dependencies {
// TODO: a couple of the deps need both runtime _and_ implementation dependencies to run?
implementation api4s
implementation lucene
implementation models
implementation "com.google.guava:guava:28.1-jre"
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
runtimeOnly "com.google.guava:failureaccess:1.0.1"
runtimeOnly "org.scala-lang:scala-library:${scalaFullVersion}"
}
}))
configure(testing, List.of(scalaProjectConfig, {
apply plugin: 'com.github.maiflai.scalatest'
test {
outputs.upToDateWhen { false }
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
events "standardOut", "started", "passed", "skipped", "failed"
}
maxParallelForks = 1
}
dependencies {
implementation benchmarks
implementation clientElastic4s
implementation clientJava
implementation lucene
implementation models
implementation plugin
implementation "ch.qos.logback:logback-classic:1.2.3"
implementation "com.klibisz.futil:futil_${scalaShortVersion}:0.1.2"
implementation "com.storm-enroute:scalameter_${scalaShortVersion}:0.19"
implementation 'com.typesafe:config:1.4.0'
implementation "com.typesafe.scala-logging:scala-logging_${scalaShortVersion}:3.9.2"
implementation 'com.vladsch.flexmark:flexmark-all:0.35.10'
implementation "io.circe:circe-generic-extras_${scalaShortVersion}:${circeGenericExtrasVersion}"
implementation "io.circe:circe-parser_${scalaShortVersion}:${circeVersion}"
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation "org.apache.lucene:lucene-analyzers-common:${luceneVersion}"
implementation "org.apache.lucene:lucene-codecs:${luceneVersion}"
implementation "org.elasticsearch.client:elasticsearch-rest-high-level-client:${esVersion}"
implementation "org.elasticsearch:elasticsearch:${esVersion}"
implementation 'org.pegdown:pegdown:1.4.2'
implementation "org.scala-lang:scala-library:${scalaFullVersion}"
implementation "org.scalanlp:breeze_${scalaShortVersion}:1.3"
implementation "org.scalatest:scalatest_${scalaShortVersion}:3.2.0"
}
}))