-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
151 lines (126 loc) · 4.57 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 com.github.mgk.gradle.*
import java.nio.file.Files
buildscript {
ext {
// es_version = version.replaceAll(/\.[0-9]+(|-SNAPSHOT)$/, "")
es_version = version.replaceAll(/(|-SNAPSHOT)$/, "")
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${es_version}"
classpath group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
classpath group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
classpath group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
classpath group: 'javax.activation', name: 'activation', version: '1.1.1'
}
}
plugins {
id "co.riiid.gradle" version "0.4.2"
// the old co.riiid.gradle is not gradle 7.0 compatible
// id "com.github.humblerookie.gradle" version "0.4.4"
id "java"
id "checkstyle"
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.rest-resources'
apply plugin: 'opensearch.testclusters'
// Uncomment if you want to use: System.out.println("Emergency!");
// Logs are found in build/testcluster/integTest-*/logs/ folder.
//forbiddenApis {
// ignoreFailures = true
//}
// license of this project
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices
noticeFile = rootProject.file('NOTICE.txt')
// POM validation can be enabled
validatePom.enabled = false
// No unit tests in this plugin
test.enabled = false
println "Host: " + java.net.InetAddress.getLocalHost()
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()
println "Build: group: '${project.group}', name: '${project.name}', version: '${project.version}'"
println "Timestamp: " + java.time.Instant.now().atZone(java.time.ZoneId.systemDefault()).toString()
repositories {
mavenCentral()
mavenLocal()
}
ext {
versions = [
"opensearch": es_version,
"prometheus" : "0.8.0",
"log4j" : "2.17.1",
"junit" : "4.12"
]
}
configurations {
runtime
releaseJars {
extendsFrom runtime
exclude group: "org.opensearch"
exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
exclude group: "org.apache.logging.log4j"
}
}
githubRelease.doFirst {
if (!System.getProperty('GITHUB_TOKEN', '')) {
throw new Exception('Missing property GITHUB_TOKEN')
}
// check if zip file is there
assert file("build/distributions/prometheus-exporter-${version}.zip").exists()
// rename zip file
def currentVersion = version.replace('-SNAPSHOT', '')
def filename = "build/distributions/prometheus-exporter-${currentVersion}.zip"
Files.copy(file("build/distributions/prometheus-exporter-${version}.zip").toPath(), file(filename).toPath())
// configuration
github {
owner = 'aparo'
repo = 'opensearch-prometheus-exporter'
token = System.getProperty('GITHUB_TOKEN')
tagName = currentVersion
assets = [ filename ]
targetCommitish = 'main'
}
}
dependencies {
api "org.opensearch:opensearch:${versions.opensearch}"
api "io.prometheus:simpleclient:${versions.prometheus}"
api "io.prometheus:simpleclient_common:${versions.prometheus}"
api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
testImplementation (group: 'junit', name: 'junit', version: "${versions.junit}") {
exclude group:'org.hamcrest' //also included in ES test framework
}
releaseJars "${project.group}:${project.name}:${project.version}"
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked,deprecation"
}
opensearchplugin {
licenseFile rootProject.file('LICENSE.txt')
noticeFile rootProject.file('NOTICE.txt')
name pluginName
description pluginDescription
classname pluginClassname
}
testClusters.all {
numberOfNodes = 2
// There does not seem to be any easy way how to setup custom cluster name.
// This worked in ES 7.4.x, but now results in:
// A problem occurred evaluating root project 'prometheus-exporter'.
// > Cannot set the property 'clusterName' because the backing field is final.
// clusterName = "PrometheusExporterITCluster"
// This does not work in ES 7.5.x too:
// Execution failed for task ':integTestRunner'.
// > Testclusters does not allow the following settings to be changed:[cluster.name] for node{::integTest-0}
// setting 'cluster.name', 'PrometheusExporterITCluster'
}
checkstyle {
configFile = new File(rootDir, "checkstyle.xml")
toolVersion = "8.2"
}