forked from opensearch-project/common-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
227 lines (200 loc) · 7.2 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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
ext {
opensearch_group = "org.opensearch"
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
kotlin_version = System.getProperty("kotlin.version", "1.6.10")
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "${opensearch_group}.gradle:build-tools:${opensearch_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
// classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0-RC1"
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.18.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
allprojects {
group 'org.opensearch.commons'
version = opensearch_version.tokenize('-')[0] + '.0'
if (buildVersionQualifier) {
version += "-${buildVersionQualifier}"
}
if (isSnapshot) {
version += "-SNAPSHOT"
}
}
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'signing'
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
// apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'
apply plugin: 'opensearch.repositories'
apply from: 'build-tools/opensearchplugin-coverage.gradle'
configurations {
ktlint
}
dependencies {
compileOnly "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
compileOnly "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" // ${kotlin_version} does not work for coroutines
compileOnly "com.cronutils:cron-utils:9.1.6"
compileOnly "commons-validator:commons-validator:1.7"
testImplementation "org.opensearch.test:framework:${opensearch_version}"
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
testImplementation "org.mockito:mockito-core:3.10.0"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testImplementation 'org.mockito:mockito-junit-jupiter:3.10.0'
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
testImplementation "com.cronutils:cron-utils:9.1.6"
testImplementation "commons-validator:commons-validator:1.7"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
ktlint "com.pinterest:ktlint:0.44.0"
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat "full"
events "skipped", "passed", "failed" // "started"
showStandardStreams true
}
}
spotless {
java {
removeUnusedImports()
importOrder 'java', 'javax', 'org', 'com'
licenseHeaderFile 'spotless.license.java'
eclipse().configFile rootProject.file('.eclipseformat.xml')
}
}
// TODO: enable detekt only when snakeyaml vulnerability is fixed
/*detekt {
config = files("detekt.yml")
buildUponDefaultConfig = true
}*/
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
shadowJar {
archiveClassifier = null
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
publishing {
repositories {
maven {
name = 'staging'
url = "${rootProject.buildDir}/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"
}
}
}
publications {
shadow(MavenPublication) {
project.shadow.component(it)
groupId = 'org.opensearch'
artifactId = 'common-utils'
artifact sourcesJar
artifact javadocJar
pom {
name = "OpenSearch Common Utils"
packaging = "jar"
url = "https://github.com/opensearch-project/common-utils"
description = "OpenSearch Common Utils"
scm {
connection = "scm:[email protected]:opensearch-project/common-utils.git"
developerConnection = "scm:[email protected]:opensearch-project/common-utils.git"
url = "[email protected]:opensearch-project/common-utils.git"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "amazonwebservices"
organization = "Amazon Web Services"
organizationUrl = "https://aws.amazon.com"
}
}
}
}
}
gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS)
gradle.startParameter.setLogLevel(LogLevel.DEBUG)
}
// 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
// Include the required files that needs to be updated with new Version
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}