forked from opensearch-project/opensearch-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
210 lines (184 loc) · 6.83 KB
/
build.gradle
File metadata and controls
210 lines (184 loc) · 6.83 KB
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
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import java.nio.file.Files
import org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFramework
plugins {
id 'java'
id "com.diffplug.spotless" version "6.16.0" apply false
id 'jacoco'
id "com.form.diff-coverage" version "0.9.5"
}
ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}
apply plugin: 'application'
apply from: 'gradle/formatting.gradle'
apply plugin: 'maven-publish'
// Temporary to keep "gradle run" working
// TODO: change this to an extension designed for testing instead of duplicating a sample
// https://github.com/opensearch-project/opensearch-sdk-java/issues/175
mainClassName = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'
group 'org.opensearch.sdk'
version '2.0.0-SNAPSHOT'
publishing {
publications {
group = "${group}"
version = "${version}"
mavenJava(MavenPublication) {
from components.java
}
sourceCompatibility = 11
targetCompatibility = 11
}
repositories {
maven {
name = "Snapshots" // optional target repository name
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/"}
}
configurations {
requireJavadoc
}
dependencies {
def opensearchVersion = "3.0.0-SNAPSHOT"
def log4jVersion = "2.20.0"
def nettyVersion = "4.1.89.Final"
def jacksonDatabindVersion = "2.14.2"
def guavaVersion = "31.1-jre"
def guiceVersion = "5.1.0"
def junit4Version = "4.13.2"
def junit5Version = "5.9.2"
def junitPlatform = "1.9.2"
def jaxbVersion = "2.3.1"
def requireJavadocVersion = "1.0.6"
implementation("org.opensearch:opensearch:${opensearchVersion}")
implementation("org.apache.logging.log4j:log4j-api:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
implementation("org.opensearch.client:opensearch-rest-high-level-client:${opensearchVersion}")
implementation("org.opensearch.client:opensearch-rest-client:${opensearchVersion}")
implementation("org.opensearch.client:opensearch-java:${opensearchVersion}")
implementation("org.opensearch.plugin:transport-netty4-client:${opensearchVersion}")
implementation("io.netty:netty-all:${nettyVersion}")
testCompileOnly("junit:junit:${junit4Version}") {
exclude module : 'hamcrest'
exclude module : 'hamcrest-core'
}
implementation("javax.xml.bind:jaxb-api:${jaxbVersion}")
implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonDatabindVersion}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava:${jacksonDatabindVersion}")
constraints {
implementation("com.google.guava:guava:${guavaVersion}") {
because 'versions below 30.0 have active CVE'
}
}
implementation("com.google.inject:guice:${guiceVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${junit5Version}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junit5Version}")
testImplementation("org.opensearch.test:framework:${opensearchVersion}")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:${junitPlatform}")
requireJavadoc("org.plumelib:require-javadoc:${requireJavadocVersion}")
}
// this task tests for the presence of javadocs but not the content/tags
task requireJavadoc(type: JavaExec) {
group = 'Documentation'
description = 'Ensures that Javadoc documentation exists.'
mainClass = "org.plumelib.javadoc.RequireJavadoc"
classpath = configurations.requireJavadoc
args "src/main/java"
// javadocs on private methods optional
args "--dont-require-private=true"
// javadocs on trivial getters/setters optional
args "--dont-require-trivial-properties"
}
check.dependsOn requireJavadoc
// this task checks the content/tags of existing javadocs
task javadocStrict(type: Javadoc) {
group = 'Documentation'
description = 'Run Javadoc in strict mode: with -Xdoclint:all, on all members.'
source = sourceSets.main.allJava
classpath = sourceSets.main.runtimeClasspath
options.addStringOption('Xdoclint:all', '-quiet')
options.memberLevel = JavadocMemberLevel.PRIVATE
}
check.dependsOn javadocStrict
// this task runs the helloworld sample extension
task helloWorld(type: JavaExec) {
group = 'Execution'
description = 'Run HelloWorld Extension.'
mainClass = 'org.opensearch.sdk.sample.helloworld.HelloWorldExtension'
classpath = sourceSets.main.runtimeClasspath
}
test {
// Temporary workaround for https://github.com/gradle/gradle/issues/23995
getTestFrameworkProperty().convention(getProviderFactory().provider(() -> new JUnitPlatformTestFramework(it.getFilter(), false)))
jvmArgs '--enable-preview'
systemProperty 'tests.security.manager', 'false'
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
jacoco {
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
}
}
// Get uncommitted files via git diff
// https://github.com/form-com/diff-coverage-gradle/issues/73
ext.createDiffFile = { ->
def file = Files.createTempFile(URLEncoder.encode(project.name, 'UTF-8'), '.diff').toFile()
def diffBase = 'refs/remotes/origin/main'
// Only run locally
if (!System.getenv('CI')) {
file.withOutputStream { out ->
exec {
commandLine 'git', 'diff', '--no-color', '--minimal', diffBase
standardOutput = out
}
}
}
return file
}
diffCoverageReport {
afterEvaluate {
diffSource.file = createDiffFile()
}
// View report at build/reports/jacoco/diffCoverage/html/index.html
reports {
html = true
}
violationRules {
minBranches = 0.60
minLines = 0.75
failOnViolation = true
}
}