generated from opensearch-project/opensearch-plugin-template-java
-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle
151 lines (123 loc) · 5.07 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
import org.opensearch.gradle.test.RestIntegTestTask
import java.util.regex.Matcher
import java.util.regex.Pattern
buildscript {
ext {
// Four {digit(s)} concatenated with a "." followed by -rc{digit(s)}
// Examples: 1.0.0.1-rc2, 2.10.4.0-rc5
// Group (3) refers to the last .{digit{(s)} pattern (this is what we want to remove for OpS version)
final Pattern RC_pattern = Pattern.compile(/([0-9](\.[0-9]+){2})(\.[0-9]+)(-rc[0-9]+)$/)
// Four {digit(s)} concatenated with a "." followed by null or -SNAPSHOT
// Examples: 1.0.0.1, 2.10.4.0-SNAPSHOT
// Group (3) refers to the last .{digit{(s)} pattern (this is what we want to remove for OpS version)
final Pattern OTHER_pattern = Pattern.compile(/([0-9](\.[0-9]+){2})(\.[0-9]+)(|-SNAPSHOT)$/)
String opensearch_version
String plugin_version = version
Matcher rc_matcher = RC_pattern.matcher(plugin_version)
Matcher other_matcher = OTHER_pattern.matcher(plugin_version)
println("Identifing version of OpenSearch based on plugin version")
if (rc_matcher.find()) {
opensearch_version = rc_matcher.group(1) + rc_matcher.group(4)
} else if (other_matcher.find()) {
opensearch_version = other_matcher.group(1)
} else {
throw new InvalidUserDataException("Invalid plugin version [" + version + "] in gradle.properties file.")
}
println("- OpenSearch version: " + opensearch_version)
println("- Prometheus exporter plugin version: " + plugin_version)
versions = [
"opensearch": opensearch_version,
"prometheus": "0.16.0"
]
}
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/releases" }
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:${versions.opensearch}"
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.yaml-rest-test'
//apply plugin: 'checkstyle'
def pluginName = pluginName
def pluginDescription = pluginDescription
//def projectPath = 'org.opensearch'
//def pathToPlugin = 'path.to.plugin'
def pluginClassName = pluginClassname
opensearchplugin {
name pluginName
description pluginDescription
// classname "${projectPath}.${pathToPlugin}.${pluginClassName}"
classname pluginClassName
licenseFile rootProject.file('LICENSE.txt')
noticeFile rootProject.file('NOTICE.txt')
}
// thirdparty audit needs can be enabled
thirdPartyAudit.enabled = false
// This requires an additional Jar not published as part of build-tools
loggerUsageCheck.enabled = false
// No need to validate pom, as we do not upload to maven/sonatype
validateNebulaPom.enabled = false
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/releases" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}
dependencies {
// Deprecated in Gradle 6.8.1, use "implementation" instead
// See https://docs.gradle.org/6.8.1/userguide/java_plugin.html#sec:java_plugin_and_dependency_management
// compile "io.prometheus:simpleclient:${versions.prometheus}"
// compile "io.prometheus:simpleclient_common:${versions.prometheus}"
implementation group: 'io.prometheus', name: 'simpleclient', version: '0.16.0'
implementation group: 'io.prometheus', name: 'simpleclient_common', version: '0.16.0'
}
restResources {
restApi {
includeCore '_common', 'cat', 'cluster', 'nodes', 'indices', 'index'
}
}
test {
include '**/*Tests.class'
}
// Print more details if any deprecated APIs are used
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:deprecation']
}
task integTest(type: RestIntegTestTask) {
description = "Run tests against a cluster"
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
}
tasks.named("check").configure { dependsOn(integTest) }
// Temporary disable task :testingConventions
testingConventions.enabled = false
testClusters.all {
numberOfNodes = 2
// It seems cluster name can not be customized here. It gives an error:
// Testclusters does not allow the following settings to be changed:[cluster.name] for node{::yamlRestTest-0}
// setting 'cluster.name', 'PrometheusExporterITCluster'
}
integTest {
// 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'
}
}
testClusters.integTest {
testDistribution = "INTEG_TEST"
// This installs our plugin into the testClusters
plugin(project.tasks.bundlePlugin.archiveFile)
}
run {
useCluster testClusters.integTest
}