forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
213 lines (195 loc) · 7.49 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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
prometheus_binary_version = "2.37.2"
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
//this variable for always downloading snapshot version of security plugin.
//need to figure out more elegant solution for integ tests with security.
opensearch_build_snapshot = opensearch_build + '-SNAPSHOT'
if (isSnapshot) {
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT (opensearch_build)
opensearch_build += "-SNAPSHOT"
}
getArchType = {
if (System.getProperty("os.arch").startsWith("x") || System.getProperty("os.arch").startsWith("amd")) {
return "amd64"
}
else {
return "arm64"
}
}
getOSFamilyType = {
def os = org.gradle.internal.os.OperatingSystem.current();
if (os.isMacOsX()) {
return "darwin"
}
else if(os.isLinux()){
return "linux"
}
else if(os.isWindows()) {
return "windows"
}
else {
return os.getFamilyName().toString()
}
}
getPrometheusBinaryLocation = { ->
return "https://github.com/prometheus/prometheus/releases/download/v${prometheus_binary_version}/prometheus-${prometheus_binary_version}."+ getOSFamilyType() + "-" + getArchType() + ".tar.gz"
}
aws_java_sdk_version = "1.12.651"
}
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
}
}
plugins {
id "com.netflix.nebula.ospackage-base" version "11.5.0"
id 'java-library'
id "io.freefair.lombok" version "8.4"
id 'jacoco'
id 'com.diffplug.spotless' version '6.22.0'
}
// import versions defined in https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java#L94
// versions https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/version.properties
apply plugin: 'opensearch.java'
// Repository on root level is for dependencies that project code depends on. And this block must be placed after plugins{}
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral() // For Elastic Libs that you can use to get started coding until open OpenSearch libs are available
maven { url 'https://jitpack.io' }
}
spotless {
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**', '**/gen/**'
}
importOrder()
// licenseHeader("/*\n" +
// " * Copyright OpenSearch Contributors\n" +
// " * SPDX-License-Identifier: Apache-2.0\n" +
// " */\n\n")
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format')
}
}
allprojects {
version = opensearch_version.tokenize('-')[0] + '.0'
if (buildVersionQualifier) {
version += "-${buildVersionQualifier}"
}
if (isSnapshot) {
version += "-SNAPSHOT"
}
plugins.withId('java') {
sourceCompatibility = targetCompatibility = "11"
}
configurations.all {
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.9.10"
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10"
}
}
subprojects {
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url 'https://jitpack.io' }
}
}
// TODO: fix compiler warnings
compileJava.options.warnings = false
compileJava {
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
doFirst {
// TODO: do not fail build on warnings, need to fix all compiler warnings
options.compilerArgs.remove('-Werror')
// TODO: need to fix all java doc format
options.compilerArgs.remove('-Xdoclint:all')
}
}
// TODO: Similarly, need to fix compiling errors in test source code
compileTestJava.options.warnings = false
compileTestJava {
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
doFirst {
options.compilerArgs.remove('-Werror')
options.compilerArgs.remove('-Xdoclint:all')
}
}
jacoco {
toolVersion = "0.8.7"
}
jacocoTestReport {
reports {
xml.required = false
csv.required = false
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/antlr/parser/**'])
}))
}
}
test.finalizedBy(project.tasks.jacocoTestReport)
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.5
}
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/antlr/parser/**'])
}))
}
}
check.dependsOn jacocoTestCoverageVerification
configurations.all {
resolutionStrategy.force 'junit:junit:4.13.2'
exclude group: "commons-logging", module: "commons-logging"
// enforce 1.1.3, https://www.whitesourcesoftware.com/vulnerability-database/WS-2019-0379
resolutionStrategy.force 'commons-codec:commons-codec:1.13'
resolutionStrategy.force 'com.google.guava:guava:32.0.1-jre'
}
// updateVersion: Task to auto increment to the next development iteration
task updateVersion {
onlyIf { System.getProperty('newVersion') }
doLast {
ext.newVersion = System.getProperty('newVersion')
println "Setting version to ${newVersion}."
// String tokenization to support -SNAPSHOT
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
ant.replaceregexp(match:'"version": "\\d+.\\d+.\\d+.\\d+', replace:'"version": ' + '"' + newVersion.tokenize('-')[0] + '.0', flags:'g', byline:true) {
fileset(dir: projectDir) {
include(name: "workbench/package.json")
include(name: "workbench/opensearch_dashboards.json")
}
}
ant.replaceregexp(file:'workbench/opensearch_dashboards.json', match:'"opensearchDashboardsVersion": "\\d+.\\d+.\\d+', replace:'"opensearchDashboardsVersion": ' + '"' + newVersion.tokenize('-')[0], flags:'g', byline:true)
}
}