forked from opensearch-project/performance-analyzer-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
246 lines (216 loc) · 8.44 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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
ext {
// Detect version from version.properties and align it with the build settings
def build = new Properties()
file("version.properties").withInputStream { build.load(it) }
var isSnapshot = System.getProperty("build.snapshot", "true")
buildVersion = build.getProperty("version")
if (isSnapshot.toBoolean() && !buildVersion.endsWith("SNAPSHOT")) {
buildVersion = buildVersion + "-SNAPSHOT"
} else if (!isSnapshot && buildVersion.endsWith("SNAPSHOT")) {
throw GradleException("Expecting release (non-SNAPSHOT) build but version is not set accordingly: " + buildVersion)
}
// Check if tag release version (if provided) matches the version from build settings
tagVersion = System.getProperty("build.version", buildVersion)
if (!buildVersion.equals(tagVersion)) {
throw GradleException("The tagged version " + tagVersion + " does not match the build version " + buildVersion)
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath group: 'com.google.guava', name: 'guava', version: '30.1-jre'
}
}
plugins {
id 'java'
id 'application'
id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '5.11.0'
id 'com.github.spotbugs' version '5.0.13'
}
spotbugsMain {
excludeFilter = file("checkstyle/findbugs-exclude.xml")
effort = 'max'
ignoreFailures = true // TODO: Set this to false later as they are too many warnings to be fixed.
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugsTest {
ignoreFailures = true
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://plugins.gradle.org/m2/" }
}
group 'org.opensearch.performanceanalyzer.commons'
version = buildVersion
}
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'signing'
apply plugin: 'maven-publish'
apply from: 'build-tools/coverage.gradle'
dependencies {
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
implementation files("${System.properties['java.home']}/../lib/tools.jar")
}
def jacksonVersion = "2.15.1"
def jacksonDataBindVersion = "2.14.1"
def junitVersion = "4.13.1"
def log4jVersion = "2.17.1"
implementation "org.jooq:jooq:3.10.8"
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDataBindVersion}"
implementation 'com.google.guava:guava:31.1-jre'
implementation 'com.google.code.gson:gson:2.9.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4jVersion}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4jVersion}"
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.0'
testImplementation group: 'org.javassist', name: 'javassist', version: '3.24.0-GA'
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.0'
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.3'
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
testImplementation group: 'junit', name: 'junit', version: "${junitVersion}"
}
//TODO: remove once spotbugs upgrades to 4.7.4
configurations.each {
c -> c.resolutionStrategy.dependencySubstitution {
all { DependencySubstitution dependency ->
if (dependency.requested.group == 'org.apache.bcel') {
dependency.useTarget 'org.apache.bcel:bcel:6.6.1'
}
}
}
}
compileJava {
dependsOn spotlessApply
JavaVersion targetVersion = JavaVersion.toVersion(targetCompatibility);
if (targetVersion.isJava9Compatible()) {
options.compilerArgs += ["--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED"]
options.compilerArgs += ["--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"]
}
}
test {
testLogging {
exceptionFormat "full"
events "skipped", "passed", "failed", "started"
showStandardStreams true
}
}
distributions {
main {
contents {
eachFile {
it.path = it.path.replace("-$version/", '/')
}
}
}
}
spotless {
java {
licenseHeaderFile(file('license-header'))
googleJavaFormat('1.12.0').aosp()
importOrder()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
// add support for spotless:off and spotless:on tags to exclude sections of code
toggleOffOn()
}
}
tasks.withType(Test) {
jvmArgs('-Dopensearch.path.conf=src/test/resources/config')
jvmArgs('--add-opens=java.base/sun.nio.fs=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.nio.file=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util=ALL-UNNAMED')
jvmArgs('--add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED')
}
javadoc {
exclude 'org/opensearch/performanceanalyzer/commons/jvm/**'
}
task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier.set("javadoc")
from sourceSets.main.allJava
dependsOn javadoc
}
publishing {
publications {
create(MavenPublication) {
groupId = 'org.opensearch'
artifactId = 'performance-analyzer-commons'
from(components["java"])
artifact sourcesJar
artifact javadocJar
pom {
name = "OpenSearch Performance Analyzer Commons"
packaging = "jar"
url = "https://github.com/opensearch-project/performance-analyzer-commons"
description = "OpenSearch Performance Analyzer Commons Library"
scm {
connection = "scm:[email protected]:opensearch-project/performance-analyzer-commons.git"
developerConnection = "scm:[email protected]:opensearch-project/performance-analyzer-commons.git"
url = "[email protected]:opensearch-project/performance-analyzer-commons.git"
}
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/performance-analyzer-commons"
}
}
}
}
}
repositories {
if (buildVersion.toString().endsWith("SNAPSHOT")) {
maven {
name = "Snapshots"
url = "https://aws.oss.sonatype.org/content/repositories/snapshots/"
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
maven {
name = "localRepo"
url = "${rootProject.buildDir}/repository"
}
}
gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS)
gradle.startParameter.setLogLevel(LogLevel.DEBUG)
}