forked from aparo/opensearch-learning-to-rank
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild.gradle
266 lines (226 loc) · 8.46 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
import java.nio.file.Files
import org.opensearch.gradle.test.RestIntegTestTask
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
is_snapshot = "true" == System.getProperty("build.snapshot", "true")
build_version_qualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (build_version_qualifier) {
opensearch_build += "-${build_version_qualifier}"
}
if (is_snapshot) {
opensearch_build += "-SNAPSHOT"
}
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
}
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
}
}
plugins {
id 'java'
id 'idea'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.23.0'
}
group = 'org.opensearch'
version = opensearch_build
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.java-rest-test'
apply plugin: 'opensearch.rest-resources'
apply plugin: 'opensearch.pluginzip'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
// license of this project
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices
noticeFile = rootProject.file('NOTICE.txt')
// disable uploadArchives task for now, no upload happening currently
//GSI TODO: disabled for now
//uploadArchives.enabled = false
opensearchplugin {
name 'opensearch-ltr'
description 'Learning to Rank Query w/ RankLib Models'
classname 'com.o19s.es.ltr.LtrQueryParserPlugin'
// license of the plugin, may be different than the above license
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices, may be different than the above notice
noticeFile = rootProject.file('NOTICE.txt')
}
publishing {
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = "opensearch-ltr"
description = "Learning to Rank Query w/ RankLib Models"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/opensearch-learning-to-rank-base"
}
}
}
}
}
repositories {
maven {
name = 'staging'
url = layout.buildDirectory.dir('local-staging-repo')
}
maven {
name = "Snapshots"
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
}
// In this section you declare the dependencies for your production and test code
// OpenSearch dependency is included due to the build-tools, test-framework as well
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
implementation "org.apache.lucene:lucene-expressions:${luceneVersion}"
implementation "org.antlr:antlr4-runtime:${antlrVersion}"
implementation "org.ow2.asm:asm:${ow2Version}"
implementation "org.ow2.asm:asm-commons:${ow2Version}"
implementation "org.ow2.asm:asm-tree:${ow2Version}"
implementation 'com.o19s:RankyMcRankFace:0.1.1'
implementation "com.github.spullara.mustache.java:compiler:0.9.3"
implementation "org.apache.httpcomponents.client5:httpclient5:5.3.1"
implementation "org.apache.httpcomponents.core5:httpcore5:5.3"
implementation "org.apache.httpcomponents.core5:httpcore5-h2:5.3"
implementation "org.conscrypt:conscrypt-openjdk-uber:2.5.2"
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'org.slf4j:slf4j-simple:1.7.36'
implementation "org.opensearch:common-utils:${common_utils_version}"
runtimeOnly 'org.locationtech.spatial4j:spatial4j:0.7'
runtimeOnly 'org.locationtech.jts:jts-core:1.15.0'
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.21.0'
}
configurations.all {
resolutionStrategy.force "org.apache.httpcomponents.client5:httpclient5:5.3.1"
resolutionStrategy.force "org.apache.httpcomponents.core5:httpcore5:5.3"
resolutionStrategy.force "org.apache.httpcomponents.core5:httpcore5-h2:5.3"
resolutionStrategy.force 'org.apache.httpcomponents:httpclient:4.5.14'
resolutionStrategy.force "com.google.guava:guava:32.1.3-jre"
resolutionStrategy.force 'org.eclipse.platform:org.eclipse.core.runtime:3.29.0'
}
// see https://github.com/opensearch-project/OpenSearch/blob/0ba0e7cc26060f964fcbf6ee45bae53b3a9941d0/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java
dependencyLicenses {
mapping from: /lucene-.*/, to: 'lucene'
mapping from: /asm-.*/, to: 'asm'
mapping from: /RankyMcRankFace.*/, to: 'lucene'
//mapping from: /Ranky.*/, to: 'lucene'
mapping from: /compiler.*/, to: 'lucene'
}
sourceSets {
javaRestTest {
compileClasspath += sourceSets["main"].output + sourceSets["test"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
withJavadocJar()
}
// Set to false to not use opensearch checkstyle rules
// checkstyleMain.enabled = true
// checkstyleTest.enabled = true
// FIXME dependency license check needs to be enabled
// dependencyLicenses.enabled = false
// FIXME thirdparty audit needs to be enabled
// thirdPartyAudit.enabled = false
// Uncomment this to skip license header checks
// licenseHeaders.enabled = false
// No need to validate POM, as we do not upload to sonatype
validateNebulaPom.enabled = false
// Elastic tried to remove the logging requirement for plugins, but didn't get it quite right so this is a short term fix until 7.11
// https://github.com/elastic/opensearch/issues/65247
loggerUsageCheck.enabled = false
// Custom task for running integration tests
task integTest(type: RestIntegTestTask) {
description = "Run integration tests from src/javaRestTest"
// Specify the classpath for integration tests
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
classpath = sourceSets.javaRestTest.runtimeClasspath
}
testClusters.integTest {
// adds LTR as a plugin to the OS build
plugin(project.tasks.bundlePlugin.archiveFile)
}
tasks.named("check").configure { dependsOn(integTest) }
integTest {
dependsOn "bundlePlugin"
systemProperty 'tests.security.manager', 'false'
systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
if (System.getProperty("test.debug") != null) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}
}
task integTestRemote(type: RestIntegTestTask) {
description = "Run integration tests from src/javaRestTest"
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
classpath = sourceSets.javaRestTest.runtimeClasspath
systemProperty 'tests.security.manager', 'false'
systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")
}
tasks.withType(Test).configureEach { task ->
if (JavaVersion.current().compareTo(JavaVersion.VERSION_17) > 0 && JavaVersion.current().compareTo(JavaVersion.VERSION_21) < 0) {
def policyFile = file("${projectDir}/src/main/plugin-metadata/plugin-security.policy").absolutePath
task.jvmArgs += [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"-Djava.security.manager",
"-Djava.security.policy=" + policyFile
]
}
}
['forbiddenApisTest', 'testingConventions', 'forbiddenApisJavaRestTest'].each { taskName ->
tasks.named(taskName).configure {
enabled = false
}
}
tasks.named('dependencyLicenses') {
enabled = false
}
thirdPartyAudit {
ignoreViolations('org.conscrypt.Platform')
}
spotless {
java {
removeUnusedImports()
importOrder 'java', 'javax', 'org', 'com'
eclipse().configFile rootProject.file('.eclipseformat.xml')
}
}