-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
154 lines (128 loc) · 5.27 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
import java.nio.file.Files
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider;
buildscript {
dependencies {
classpath "org.elasticsearch.gradle:build-tools:${elasticsearchVersion}"
}
}
plugins {
id 'java-gradle-plugin'
id "com.github.humblerookie.gradle" version "0.4.4"
id "com.github.ben-manes.versions" version '0.36.0'
}
sourceSets {
yamlRestTest
}
repositories {
mavenCentral()
// only needed for beta1, can be removed after upgrading to newer version
maven {
url = 'https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/cc2a31f2be8'
}
}
group = 'com.succez.elasticsearch.plugin'
version = "${elasticsearchVersion}.1-SNAPSHOT"
apply plugin: 'java'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.testclusters'
sourceCompatibility = '11'
esplugin {
name = 'ingest-markdown'
description = 'Ingest processor extracting plain text from markdown file'
classname = 'org.elasticsearch.plugin.ingest.markdown.MarkdownPlugin'
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}
// remove me after alpha-2 release
configurations {
resolveableCompileOnly {
exclude(group: 'org.elasticsearch', module: 'elasticsearch-lz4')
}
implementation {
exclude(group: 'org.elasticsearch', module: 'elasticsearch-lz4')
}
}
// 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/ingest-markdown-${version}.zip").exists()
// rename zip file
def currentVersion = version.replace('-SNAPSHOT', '')
def filename = "build/distributions/ingest-markdown-${currentVersion}.zip"
Files.copy(file("build/distributions/ingest-markdown-${version}.zip").toPath(), file(filename).toPath())
// configuration
github {
owner = 'zengshenw'
repo = 'elasticsearch-ingest-markdown'
token = System.getProperty('GITHUB_TOKEN')
tagName = currentVersion
assets = [filename]
targetCommitish = 'main'
}
}
// 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"
}
/**
* 设置下编译java的编码格式,否则在win下面会因为编码不同出错。
*/
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
// options.compilerArgs << '--add-exports=jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED' << '--add-exports=jdk.scripting.nashorn/jdk.nashorn.internal.objects=ALL-UNNAMED'
options.compilerArgs << '-Xlint:-deprecation' << '-Xlint:-unchecked'
}
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())
// lingua requires a ton of heap to load all the models!
System.setProperty("tests.heap.size", "3g")
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 {
implementation 'com.youcruit.com.cybozu.labs:langdetect:1.1.2-20151117'
implementation 'net.arnx:jsonic:1.3.10'
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.11.1'
testImplementation ('junit:junit:4.12') {
exclude module : 'hamcrest'
exclude module : 'hamcrest-core'
}
testImplementation "org.elasticsearch.test:framework:$elasticsearchVersion"
restTestSpecs "org.elasticsearch:rest-api-spec:$elasticsearchVersion"
implementation "org.commonmark:commonmark:$commonVersion"
implementation group: 'org.apache.directory.studio', name: 'org.apache.commons.io', version: '2.4'
}