-
Notifications
You must be signed in to change notification settings - Fork 63
/
build.gradle
158 lines (130 loc) · 4.8 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
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
plugins {
id "de.undercouch.download" version "4.1.1"
// 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.33.0'
}
repositories {
mavenCentral()
}
group = 'de.spinscale.elasticsearch.plugin.ingest'
version = "${elasticsearchVersion}.1-SNAPSHOT"
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = '17'
task pluginDescriptor(type: Copy) {
from('src/main/resources') {
include '**/*.properties'
filter(ReplaceTokens, tokens: [
'version': version.replace('-SNAPSHOT', '').toString(),
'elasticsearchVersion': elasticsearchVersion.toString()
])
}
into 'build/libs'
}
task copyCommands(type: Copy) {
into 'build/libs/bin'
from 'src/main/bin'
}
task copyDependencies(type: Copy) {
into 'build/libs'
from configurations.default
from 'NOTICE.txt'
from 'LICENSE.txt'
}
task packageDistribution(type: Zip) {
archiveFileName = "elasticsearch-ingest-opennlp.zip"
destinationDirectory = layout.buildDirectory.dir('distribution')
from layout.buildDirectory.dir("libs")
}
task builderDockerImage(type: Exec) {
commandLine 'docker', 'build', '.'
}
// split tests between unit and integration tests
def testReporter = { desc, result ->
if (!desc.parent) {
def duration = java.time.Duration.ofMillis(result.endTime - result.startTime)
println "\nTest summary: ${result.resultType}, ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped, took ${duration}"
}
}
tasks.named('test') {
useJUnitPlatform {
excludeTags 'slow'
}
afterSuite testReporter
}
task integrationTest(type: Test) {
useJUnitPlatform {
includeTags 'slow'
}
afterSuite testReporter
}
test.dependsOn 'downloadModels'
packageDistribution.dependsOn 'pluginDescriptor'
packageDistribution.dependsOn 'copyCommands'
packageDistribution.dependsOn 'copyDependencies'
packageDistribution.dependsOn 'jar'
builderDockerImage.dependsOn 'packageDistribution'
integrationTest.dependsOn 'builderDockerImage'
// 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')
}
def currentVersion = version.replace('-SNAPSHOT', '')
def filename = "build/distribution/ingest-opennlp-${currentVersion}.zip"
Files.copy(file("build/distribution/elasticsearch-ingest-opennlp.zip").toPath(), file(filename).toPath())
// configuration
github {
owner = 'spinscale'
repo = 'elasticsearch-ingest-opennlp'
token = System.getProperty('GITHUB_TOKEN')
tagName = currentVersion
assets = [ filename ]
targetCommitish = 'main'
}
}
githubRelease.dependsOn 'packageDistribution'
dependencies {
def junitVersion = '5.8.2'
implementation 'org.apache.opennlp:opennlp-tools:1.9.4'
compileOnly "org.elasticsearch:elasticsearch:$elasticsearchVersion"
testImplementation "org.elasticsearch:elasticsearch:$elasticsearchVersion"
testImplementation "co.elastic.clients:elasticsearch-java:$elasticsearchVersion"
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.3'
testImplementation('org.testcontainers:elasticsearch:1.17.1') {
exclude group: 'junit', module: 'junit'
}
testImplementation 'org.testcontainers:junit-jupiter:1.17.1'
testImplementation "org.assertj:assertj-core:3.22.0"
testImplementation "org.slf4j:slf4j-simple:1.7.36"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
// download the models but dont overwrite existing ones
task downloadModels {
doLast {
downloadIfNotExists('http://opennlp.sourceforge.net/models-1.5/en-ner-person.bin', 'en-ner-persons.bin')
downloadIfNotExists('http://opennlp.sourceforge.net/models-1.5/en-ner-location.bin', 'en-ner-locations.bin')
downloadIfNotExists('http://opennlp.sourceforge.net/models-1.5/en-ner-date.bin', 'en-ner-dates.bin')
}
}
def downloadIfNotExists(String url, String file) {
String dir = rootDir.getAbsolutePath() + File.separator + 'src' + File.separator + 'test' + File.separator + 'resources' + File.separator + 'models'
new File(dir).mkdirs()
if (new File(dir + File.separator + file).exists() == false) {
download {
src url
dest new File(dir, file)
}
}
}