forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
144 lines (125 loc) · 4.14 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
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
import org.elasticsearch.gradle.internal.info.BuildParams
esplugin {
name 'x-pack-sql'
description 'The Elasticsearch plugin that powers SQL for Elasticsearch'
classname 'org.elasticsearch.xpack.sql.plugin.SqlPlugin'
extendedPlugins = ['x-pack-ql']
}
ext {
antlrVersion = "4.9.2"
// SQL dependency versions
jlineVersion = "3.21.0"
// SQL test dependency versions
csvjdbcVersion = "1.0.34"
h2Version = "1.4.197"
h2gisVersion = "1.5.0"
}
configurations {
// Bundles the sql-cli.jar into the distribution
bin
}
archivesBaseName = 'x-pack-sql'
dependencies {
compileOnly project(':modules:aggregations')
compileOnly project(path: xpackModule('core'))
compileOnly(project(':modules:lang-painless:spi'))
api project('sql-action')
api project(':modules:aggs-matrix-stats')
compileOnly project(path: xpackModule('ql'))
testImplementation project(':test:framework')
testImplementation(testArtifact(project(xpackModule('core'))))
testImplementation(testArtifact(project(xpackModule('security'))))
testImplementation(testArtifact(project(xpackModule('ql'))))
testImplementation project(path: ':modules:reindex')
testImplementation project(path: ':modules:parent-join')
testImplementation project(path: ':modules:analysis-common')
bin(project(path: xpackModule('sql:sql-cli'), configuration: 'shadow'))
}
/* Bundle the sql-cli into the binary files. It should end up
* in $ES_HOME/bin/x-pack/. This is useful because it is an
* executable jar that can be moved wherever it is needed.
*/
esplugin.bundleSpec.from({configurations.bin}) {
into 'bin'
}
addQaCheckDependencies(project)
/**********************************************
* SQL Parser regeneration *
**********************************************/
configurations {
regenerate
}
dependencies {
regenerate "org.antlr:antlr4:${antlrVersion}"
}
String grammarPath = 'src/main/antlr'
String outputPath = 'src/main/java/org/elasticsearch/xpack/sql/parser'
pluginManager.withPlugin('com.diffplug.spotless') {
spotless {
java {
targetExclude "${outputPath}/*.java"
}
}
}
tasks.register("cleanGenerated", Delete) {
delete fileTree(grammarPath) {
include '*.tokens'
}
delete fileTree(outputPath) {
include 'SqlBase*.java'
}
}
tasks.register("regenParser", JavaExec) {
dependsOn "cleanGenerated"
mainClass = 'org.antlr.v4.Tool'
classpath = configurations.regenerate
systemProperty 'file.encoding', 'UTF-8'
systemProperty 'user.language', 'en'
systemProperty 'user.country', 'US'
systemProperty 'user.variant', ''
args '-Werror',
'-package', 'org.elasticsearch.xpack.sql.parser',
'-listener',
'-visitor',
'-o', outputPath,
"${file(grammarPath)}/SqlBase.g4"
}
tasks.register("regen") {
dependsOn "regenParser"
doLast {
// moves token files to grammar directory for use with IDE's
ant.move(file: "${outputPath}/SqlBase.tokens", toDir: grammarPath)
ant.move(file: "${outputPath}/SqlBaseLexer.tokens", toDir: grammarPath)
// make the generated classes package private
ant.replaceregexp(match: 'public ((interface|class) \\QSqlBase\\E\\w+)',
replace: '\\1',
encoding: 'UTF-8') {
fileset(dir: outputPath, includes: 'SqlBase*.java')
}
// nuke timestamps/filenames in generated files
ant.replaceregexp(match: '\\Q// Generated from \\E.*',
replace: '\\/\\/ ANTLR GENERATED CODE: DO NOT EDIT',
encoding: 'UTF-8') {
fileset(dir: outputPath, includes: 'SqlBase*.java')
}
// remove tabs in antlr generated files
ant.replaceregexp(match: '\t', flags: 'g', replace: ' ', encoding: 'UTF-8') {
fileset(dir: outputPath, includes: 'SqlBase*.java')
}
// fix line endings
ant.fixcrlf(srcdir: outputPath, eol: 'lf') {
patternset(includes: 'SqlBase*.java')
}
}
}
allprojects {
tasks.register("checkNoBwc") {
dependsOn tasks.withType(Test).matching { it.name.contains('bwc') == false }
}
}
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("internalClusterTest").configure{enabled = false }
}