-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
178 lines (143 loc) · 6.03 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
import java.nio.file.Files
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
import org.gradle.api.tasks.Input;
import org.gradle.process.CommandLineArgumentProvider;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;
buildscript {
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearchVersion}"
}
}
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 "com.github.ben-manes.versions" version '0.36.0'
}
repositories {
mavenCentral()
}
group = 'org.opensearch.plugin'
version = "${opensearchVersion}"
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.testclusters'
opensearchplugin {
name = 'opensearch-analisys-pinyin'
description = 'Pinyin Analysis for OpenSearch'
classname = 'org.opensearch.plugin.analysis.pinyin.AnalysisPinyinPlugin'
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile files('lib/nlp-lang-1.7.jar')
// the yaml tests require a log4j2 dependency, otherwise a dependency is thrown on startup
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.17.0'
// testCompile 'org.powermock:powermock-api-mockito:1.6.2'
// testCompile 'nl.jqno.equalsverifier:equalsverifier:1.7.5'
}
// ignore javadoc warnings for now
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
githubRelease.doFirst {
if (!System.getProperty('GITHUB_TOKEN', '')) {
throw new Exception('Missing property GITHUB_TOKEN')
}
// check if zip file is there
assert file("build/distributions/opensearch-analisys-pinyin-${version}.zip").exists()
// rename zip file
def currentVersion = version.replace('-SNAPSHOT', '')
def filename = "build/distributions/opensearch-analisys-pinyin-${version}.zip"
Files.copy(file("build/distributions/opensearch-analisys-pinyin-${version}.zip").toPath(), file(filename).toPath())
// configuration
github {
owner = 'aparo'
repo = 'opensearch-analisys-pinyin'
token = System.getProperty('GITHUB_TOKEN')
tagName = currentVersion
assets = [ filename ]
targetCommitish = 'main'
}
}
test {
//How to run Gradle test when all tests are UP-TO-DATE? add below line
dependsOn 'cleanTest'
//To enable this fail fast behavior so even a one unit test fail it keeps running
failFast = true
// Give a different location to the gradle html reports in a folder called gradlehtmlReports
reports.html.enabled = true
reports.html.setDestination(file("$projectDir/gradlehtmlReports"))
}
// // setup yaml rest tests
// testClusters {
// yamlRestTest
// }
// sourceSets {
// yamlRestTest
// }
// configurations {
// yamlRestTestImplementation.extendsFrom testImplementation
// yamlRestTestRuntimeOnly.extendsFrom testRuntimeOnly
// restTestSpecs
// }
// tasks.register('copyRestTestSpecs', Copy) {
// from zipTree(configurations.restTestSpecs.singleFile)
// into "$buildDir/restResources/restspec"
// }
// TaskProvider<Zip> bundle = project.getTasks().withType(Zip.class).named("bundlePlugin");
// // Register rest resources with source set
// sourceSets.yamlRestTest.getOutput().dir("$buildDir/restResources/restspec");
// tasks.register('yamlRestTest', StandaloneRestIntegTestTask) { testTask ->
// testTask.dependsOn(bundle, 'copyRestTestSpecs')
// def cluster = testClusters.yamlRestTest
// cluster.plugin(bundle.flatMap(AbstractArchiveTask::getArchiveFile))
// testTask.useCluster(testClusters.yamlRestTest)
// testTask.mustRunAfter(project.getTasks().named("test"))
// testTask.setTestClassesDirs(sourceSets.yamlRestTest.getOutput().getClassesDirs())
// testTask.setClasspath(sourceSets.yamlRestTest.getRuntimeClasspath())
// SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider()
// nonInputProperties.systemProperty("tests.rest.cluster", "${-> String.join(",", cluster.getAllHttpSocketURI())}")
// nonInputProperties.systemProperty("tests.cluster", "${-> String.join(",", cluster.getAllTransportPortURI())}")
// nonInputProperties.systemProperty("tests.clustername", "${-> cluster.getName()}")
// testTask.getJvmArgumentProviders().add(nonInputProperties)
// testTask.systemProperty("tests.rest.load_packaged", Boolean.FALSE.toString())
// }
// // this is a bit of a hack to make sure we run the test tests when releasing...
// check.dependsOn 'yamlRestTest'
// dependencies {
// yamlRestTestImplementation "org.opensearch.test:framework:$opensearchVersion"
// restTestSpecs "org.opensearch:rest-api-spec:$opensearchVersion"
// }
// // This will be available in 7.15 in build tools and not manually declared.
// public class SystemPropertyCommandLineArgumentProvider implements CommandLineArgumentProvider {
// private final Map<String, Object> systemProperties = new LinkedHashMap<>();
// public void systemProperty(String key, Supplier<String> value) {
// systemProperties.put(key, value);
// }
// public void systemProperty(String key, Object value) {
// systemProperties.put(key, value);
// }
// @Override
// public Iterable<String> asArguments() {
// return systemProperties.entrySet()
// .stream()
// .map(
// entry -> "-D"
// + entry.getKey()
// + "="
// + (entry.getValue() instanceof Supplier ? ((Supplier) entry.getValue()).get() : entry.getValue())
// )
// .collect(Collectors.toList());
// }
// // Track system property keys as an input so our build cache key will change if we add properties but values are still ignored
// @Input
// public Iterable<String> getPropertyNames() {
// return systemProperties.keySet();
// }
// }