OpenSearch/x-pack/plugin/sql/build.gradle

139 lines
4.2 KiB
Groovy
Raw Normal View History

apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin {
name 'x-pack-sql'
description 'The Elasticsearch plugin that powers SQL for Elasticsearch'
classname 'org.elasticsearch.xpack.sql.plugin.SqlPlugin'
QL: Backport project to 7.x (#51497) * Introduce reusable QL plugin for SQL and EQL (#50815) Extract reusable functionality from SQL into its own dedicated project QL. Implemented as a plugin, it provides common components across SQL and the upcoming EQL. While this commit is fairly large, for the most part it's just a big file move from sql package to the newly introduced ql. (cherry picked from commit ec1ac0d463bfa12a02c8174afbcdd6984345e8b4) * SQL: Fix incomplete registration of geo NamedWritables (cherry picked from commit e295763686f9592976e551e504fdad1d2a3a566d) * QL: Extend NodeSubclass to read classes from jars (#50866) As the test classes are spread across more than one project, the Gradle classpath contains not just folders but also jars. This commit allows the test class to explore the archive content and load matching classes from said source. (cherry picked from commit 25ad74928afcbf286dc58f7d430491b0af662f04) * QL: Remove implicit conversion inside Literal (#50962) Literal constructor makes an implicit conversion for each value given which turns out has some subtle side-effects. Improve MathProcessors to preserve numeric type where possible Fix bug on issue compatibility between date and intervals Preserve the source when folding inside the Optimizer (cherry picked from commit 9b73e225b0aa07a23859550fb117bae571a2b672) * QL: Refactor DataType for pluggability (#51328) Change DataType from enum to class Break DataType enums into QL (default) and SQL types Make data type conversion pluggable so that new types can be introduced As part of the process: - static type conversion in QL package (such as Literal) has been removed - several utility classes have been broken into base (QL) and extended (SQL) parts based on type awareness - operators (+,-,/,*) are - due to extensibility, serialization of arithmetic operation has been slightly changed and pushed down to the operator executor itself (cherry picked from commit aebda81b30e1563b877a8896309fd50633e0b663) * Compilation fixes for 7.x
2020-01-27 15:03:58 -05:00
extendedPlugins = ['x-pack-ql', 'lang-painless']
}
ext {
// SQL dependency versions
jlineVersion = "3.14.1"
antlrVersion = "4.5.3"
// 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'
// All integration tests live in qa modules
integTest.enabled = false
dependencies {
compileOnly project(path: xpackModule('core'), configuration: 'default')
compileOnly(project(':modules:lang-painless')) {
// exclude ASM to not affect featureAware task on Java 10+
exclude group: "org.ow2.asm"
}
api project('sql-action')
api project(':modules:aggs-matrix-stats')
api "org.antlr:antlr4-runtime:${antlrVersion}"
QL: Backport project to 7.x (#51497) * Introduce reusable QL plugin for SQL and EQL (#50815) Extract reusable functionality from SQL into its own dedicated project QL. Implemented as a plugin, it provides common components across SQL and the upcoming EQL. While this commit is fairly large, for the most part it's just a big file move from sql package to the newly introduced ql. (cherry picked from commit ec1ac0d463bfa12a02c8174afbcdd6984345e8b4) * SQL: Fix incomplete registration of geo NamedWritables (cherry picked from commit e295763686f9592976e551e504fdad1d2a3a566d) * QL: Extend NodeSubclass to read classes from jars (#50866) As the test classes are spread across more than one project, the Gradle classpath contains not just folders but also jars. This commit allows the test class to explore the archive content and load matching classes from said source. (cherry picked from commit 25ad74928afcbf286dc58f7d430491b0af662f04) * QL: Remove implicit conversion inside Literal (#50962) Literal constructor makes an implicit conversion for each value given which turns out has some subtle side-effects. Improve MathProcessors to preserve numeric type where possible Fix bug on issue compatibility between date and intervals Preserve the source when folding inside the Optimizer (cherry picked from commit 9b73e225b0aa07a23859550fb117bae571a2b672) * QL: Refactor DataType for pluggability (#51328) Change DataType from enum to class Break DataType enums into QL (default) and SQL types Make data type conversion pluggable so that new types can be introduced As part of the process: - static type conversion in QL package (such as Literal) has been removed - several utility classes have been broken into base (QL) and extended (SQL) parts based on type awareness - operators (+,-,/,*) are - due to extensibility, serialization of arithmetic operation has been slightly changed and pushed down to the operator executor itself (cherry picked from commit aebda81b30e1563b877a8896309fd50633e0b663) * Compilation fixes for 7.x
2020-01-27 15:03:58 -05:00
compileOnly project(path: xpackModule('ql'), configuration: 'default')
testImplementation project(':test:framework')
testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts')
testImplementation project(path: xpackModule('security'), configuration: 'testArtifacts')
testImplementation project(path: xpackModule('ql'), configuration: 'testArtifacts')
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.
*/
bundlePlugin {
from(configurations.bin) {
into 'bin'
}
}
// add all sub-projects of the qa sub-project
gradle.projectsEvaluated {
project.subprojects
.find { it.path == project.path + ":qa" }
.subprojects
.findAll { it.path.startsWith(project.path + ":qa") }
.each { check.dependsOn it.check }
}
/**********************************************
* 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'
tasks.register("cleanGenerated", Delete) {
delete fileTree(grammarPath) {
include '*.tokens'
}
delete fileTree(outputPath) {
include 'SqlBase*.java'
}
}
tasks.register("regenParser", 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"
}
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')
}
}
}