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

116 lines
3.7 KiB
Groovy

/*
* This project is named sql-cli because it is in the "org.elasticsearch.plugin"
* 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.
*/
apply plugin: 'elasticsearch.build'
/* We don't use the 'application' plugin because it builds a zip and tgz which
* we don't want. */
archivesBaseName = 'elasticsearch-sql-cli'
description = 'Command line interface to Elasticsearch that speaks SQL'
dependencies {
// 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}"
compile xpackProject('plugin:sql:sql-client')
compile xpackProject('plugin:sql:sql-action')
compile "org.elasticsearch:elasticsearch-cli:${version}"
runtime "org.elasticsearch:jna:${versions.jna}"
testCompile "org.elasticsearch.test:framework:${version}"
}
dependencyLicenses {
mapping from: /elasticsearch-cli.*/, to: 'elasticsearch'
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
mapping from: /jackson-.*/, to: 'jackson'
mapping from: /lucene-.*/, to: 'lucene'
mapping from: /sql-action.*/, to: 'elasticsearch'
mapping from: /sql-client.*/, to: 'elasticsearch'
mapping from: /jline-.*/, to: 'jline'
ignoreSha 'elasticsearch-cli'
ignoreSha 'elasticsearch-core'
ignoreSha 'elasticsearch'
ignoreSha 'sql-action'
ignoreSha 'sql-client'
}
/*
* Bundle all dependencies into the main jar and mark it as executable it
* can be easily shipped around and used.
*/
jar {
from({
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}) {
// We don't need the META-INF from the things we bundle. For now.
exclude 'META-INF/*'
}
manifest {
attributes 'Main-Class': 'org.elasticsearch.xpack.sql.cli.Cli'
}
}
/*
* Build a jar that doesn't include the dependencies bundled that we can
* include with QA tests along side Elasticsearch without breaking
* jarhell.
*/
configurations {
nodeps
}
task nodepsJar(type: Jar) {
appendix 'nodeps'
from sourceSets.main.output
}
artifacts {
nodeps nodepsJar
}
forbiddenApisMain {
//sql does not depend on server, so only jdk signatures should be checked
replaceSignatureFiles 'jdk-signatures'
signaturesFiles += files('src/forbidden/cli-signatures.txt')
}
task runcli {
description = 'Run the CLI and connect to elasticsearch running on 9200'
dependsOn 'assemble'
doLast {
List command = [new File(project.runtimeJavaHome, 'bin/java').absolutePath]
if ('true'.equals(System.getProperty('debug', 'false'))) {
command += '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000'
}
command += ['-jar', jar.archivePath.absolutePath]
logger.info("running the cli with: ${command}")
new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectInput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
.waitFor()
}
}
// Use the jar for testing so we can get the proper version information
unitTest {
classpath -= compileJava.outputs.files
classpath -= configurations.compile
classpath -= configurations.runtime
classpath += jar.outputs.files
dependsOn jar
}