2018-01-17 15:48:58 -05:00
|
|
|
description = 'The Elasticsearch plugin that powers SQL for Elasticsearch'
|
|
|
|
|
2017-12-12 18:48:43 -05:00
|
|
|
apply plugin: 'elasticsearch.build'
|
|
|
|
|
|
|
|
archivesBaseName = 'x-pack-sql'
|
|
|
|
|
2018-01-17 15:48:58 -05:00
|
|
|
dependencies {
|
|
|
|
provided "org.elasticsearch:elasticsearch:${version}"
|
|
|
|
compile project(':x-pack-elasticsearch:sql:rest-proto')
|
|
|
|
compile "org.elasticsearch.plugin:x-pack-core:${version}"
|
|
|
|
compile 'org.antlr:antlr4-runtime:4.5.3'
|
|
|
|
testCompile "org.elasticsearch.test:framework:${version}"
|
|
|
|
}
|
2017-12-12 18:48:43 -05:00
|
|
|
|
|
|
|
dependencyLicenses {
|
|
|
|
mapping from: /server.*/, to: 'elasticsearch'
|
2018-01-17 15:48:58 -05:00
|
|
|
mapping from: /rest-proto.*/, to: 'elasticsearch'
|
|
|
|
|
2017-12-12 18:48:43 -05:00
|
|
|
ignoreSha 'x-pack-core'
|
2018-01-17 15:48:58 -05:00
|
|
|
ignoreSha 'rest-proto'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************
|
|
|
|
* SQL Parser regeneration *
|
|
|
|
**********************************************/
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
regenerate
|
2017-12-12 18:48:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2018-01-17 15:48:58 -05:00
|
|
|
regenerate 'org.antlr:antlr4:4.5.3'
|
|
|
|
}
|
2017-12-12 18:48:43 -05:00
|
|
|
|
2018-01-17 15:48:58 -05:00
|
|
|
String grammarPath = 'src/main/antlr'
|
|
|
|
String outputPath = 'src/main/java/org/elasticsearch/xpack/sql/parser'
|
|
|
|
|
|
|
|
task cleanGenerated(type: Delete) {
|
|
|
|
delete fileTree(grammarPath) {
|
|
|
|
include '*.tokens'
|
|
|
|
}
|
|
|
|
delete fileTree(outputPath) {
|
|
|
|
include 'SqlBase*.java'
|
|
|
|
}
|
|
|
|
}
|
2017-12-12 18:48:43 -05:00
|
|
|
|
2018-01-17 15:48:58 -05:00
|
|
|
task regenParser(type: JavaExec) {
|
|
|
|
dependsOn cleanGenerated
|
|
|
|
main = '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"
|
2017-12-12 18:48:43 -05:00
|
|
|
}
|
|
|
|
|
2018-01-17 15:48:58 -05:00
|
|
|
task 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')
|
|
|
|
}
|
|
|
|
}
|
2017-12-12 18:48:43 -05:00
|
|
|
}
|