2019-11-01 14:33:11 -04:00
|
|
|
import org.elasticsearch.gradle.info.BuildParams
|
|
|
|
|
2018-01-18 08:39:02 -05:00
|
|
|
/*
|
2018-01-18 11:15:02 -05:00
|
|
|
* This project is named sql-cli because it is in the "org.elasticsearch.plugin"
|
2018-01-18 08:39:02 -05:00
|
|
|
* group and it'd be super confusing for it to just be called "cli" there.
|
|
|
|
* Also, the jar we ultimately want to ship is sql-cli-VERSION.jar which is
|
|
|
|
* exactly what gradle makes by default when the project is named sql-cli.
|
|
|
|
*/
|
|
|
|
|
2017-12-13 10:19:31 -05:00
|
|
|
apply plugin: 'elasticsearch.build'
|
2019-10-28 15:11:55 -04:00
|
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
2017-12-13 10:19:31 -05:00
|
|
|
/* We don't use the 'application' plugin because it builds a zip and tgz which
|
|
|
|
* we don't want. */
|
|
|
|
|
2018-04-11 11:29:57 -04:00
|
|
|
archivesBaseName = 'elasticsearch-sql-cli'
|
|
|
|
|
2017-12-13 10:19:31 -05:00
|
|
|
description = 'Command line interface to Elasticsearch that speaks SQL'
|
|
|
|
|
|
|
|
dependencies {
|
2019-03-22 17:20:41 -04:00
|
|
|
|
|
|
|
// select just the parts of JLine that are needed
|
|
|
|
compile "org.jline:jline-terminal:${jlineVersion}"
|
|
|
|
compile("org.jline:jline-terminal-jna:${jlineVersion}") {
|
|
|
|
exclude group: "net.java.dev.jna"
|
|
|
|
}
|
|
|
|
compile "org.jline:jline-reader:${jlineVersion}"
|
|
|
|
compile "org.jline:jline-style:${jlineVersion}"
|
|
|
|
|
2018-06-28 08:56:16 -04:00
|
|
|
compile xpackProject('plugin:sql:sql-client')
|
2019-03-22 17:20:41 -04:00
|
|
|
compile xpackProject('plugin:sql:sql-action')
|
2019-06-04 16:50:23 -04:00
|
|
|
compile project(":libs:elasticsearch-cli")
|
2019-10-31 17:44:34 -04:00
|
|
|
compile project(':libs:elasticsearch-x-content')
|
2018-01-18 11:15:02 -05:00
|
|
|
runtime "org.elasticsearch:jna:${versions.jna}"
|
2019-06-04 16:50:23 -04:00
|
|
|
testCompile project(":test:framework")
|
2017-12-13 10:19:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencyLicenses {
|
2018-01-18 11:15:02 -05:00
|
|
|
mapping from: /elasticsearch-cli.*/, to: 'elasticsearch'
|
|
|
|
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
|
|
|
|
mapping from: /jackson-.*/, to: 'jackson'
|
|
|
|
mapping from: /lucene-.*/, to: 'lucene'
|
2018-06-28 08:56:16 -04:00
|
|
|
mapping from: /sql-action.*/, to: 'elasticsearch'
|
|
|
|
mapping from: /sql-client.*/, to: 'elasticsearch'
|
2019-03-22 17:20:41 -04:00
|
|
|
mapping from: /jline-.*/, to: 'jline'
|
2018-01-18 11:15:02 -05:00
|
|
|
ignoreSha 'elasticsearch-cli'
|
|
|
|
ignoreSha 'elasticsearch-core'
|
|
|
|
ignoreSha 'elasticsearch'
|
2018-06-28 08:56:16 -04:00
|
|
|
ignoreSha 'sql-action'
|
|
|
|
ignoreSha 'sql-client'
|
2017-12-13 10:19:31 -05:00
|
|
|
}
|
|
|
|
|
2019-10-28 15:11:55 -04:00
|
|
|
shadowJar {
|
2018-01-18 11:15:02 -05:00
|
|
|
manifest {
|
|
|
|
attributes 'Main-Class': 'org.elasticsearch.xpack.sql.cli.Cli'
|
|
|
|
}
|
2017-12-13 10:19:31 -05:00
|
|
|
}
|
|
|
|
|
2018-12-18 17:48:30 -05:00
|
|
|
forbiddenApisMain {
|
|
|
|
//sql does not depend on server, so only jdk signatures should be checked
|
|
|
|
replaceSignatureFiles 'jdk-signatures'
|
2018-08-22 02:05:22 -04:00
|
|
|
signaturesFiles += files('src/forbidden/cli-signatures.txt')
|
2018-03-14 16:15:32 -04:00
|
|
|
}
|
|
|
|
|
2017-12-15 10:42:18 -05:00
|
|
|
task runcli {
|
2018-01-18 11:15:02 -05:00
|
|
|
description = 'Run the CLI and connect to elasticsearch running on 9200'
|
2019-10-28 15:11:55 -04:00
|
|
|
dependsOn shadowJar
|
2018-01-18 11:15:02 -05:00
|
|
|
doLast {
|
2019-11-01 14:33:11 -04:00
|
|
|
List command = ["${BuildParams.runtimeJavaHome}/bin/java"]
|
2018-01-18 11:15:02 -05:00
|
|
|
if ('true'.equals(System.getProperty('debug', 'false'))) {
|
|
|
|
command += '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000'
|
|
|
|
}
|
2019-10-28 15:11:55 -04:00
|
|
|
command += ['-jar', shadowJar.archivePath.absolutePath]
|
2018-01-18 11:15:02 -05:00
|
|
|
logger.info("running the cli with: ${command}")
|
2017-12-13 10:19:31 -05:00
|
|
|
|
2018-01-18 11:15:02 -05:00
|
|
|
new ProcessBuilder(command)
|
|
|
|
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.redirectInput(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.start()
|
|
|
|
.waitFor()
|
|
|
|
}
|
2017-12-13 10:19:31 -05:00
|
|
|
}
|