OpenSearch/sql/cli/build.gradle

92 lines
3.2 KiB
Groovy
Raw Normal View History

apply plugin: 'elasticsearch.build'
/* We don't use the 'application' plugin because it builds a zip and tgz which
* we don't want. */
description = 'Command line interface to Elasticsearch that speaks SQL'
dependencies {
compile "org.jline:jline:3.3.1"
compile project(':x-pack-elasticsearch:sql:net-client')
compile project(':x-pack-elasticsearch:sql:cli-proto')
compile project(':x-pack-elasticsearch:sql:shared-proto')
runtime "org.fusesource.jansi:jansi:1.16"
runtime "org.elasticsearch:jna:4.4.0-1"
}
dependencyLicenses {
mapping from: /cli-proto.*/, to: 'elasticsearch'
mapping from: /shared-proto.*/, to: 'elasticsearch'
mapping from: /net.*/, to: 'elasticsearch'
ignoreSha 'cli-proto'
ignoreSha 'shared-proto'
ignoreSha 'net-client'
}
forbiddenApisMain {
// does not depend on core, so only jdk and http signatures should be checked
signaturesURLs = [this.class.getResource('/forbidden/jdk-signatures.txt')]
}
jar {
// Bundle all dependencies into the jar.
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
// Make the jar "executable" with `java -jar`
manifest {
attributes 'Main-Class': 'org.elasticsearch.xpack.sql.cli.Cli'
}
}
// Needed so we can launch graphviz if it is installed
project.compactProfile = 'full'
thirdPartyAudit.excludes = [
'org.apache.sshd.client.SshClient',
'org.apache.sshd.client.auth.keyboard.UserInteraction',
'org.apache.sshd.client.channel.ChannelShell',
'org.apache.sshd.client.channel.ClientChannel',
'org.apache.sshd.client.channel.ClientChannelEvent',
'org.apache.sshd.client.future.AuthFuture',
'org.apache.sshd.client.future.ConnectFuture',
'org.apache.sshd.client.future.OpenFuture',
'org.apache.sshd.client.session.ClientSession',
'org.apache.sshd.common.Factory',
'org.apache.sshd.common.channel.PtyMode',
'org.apache.sshd.common.config.keys.FilePasswordProvider',
'org.apache.sshd.common.util.io.NoCloseInputStream',
'org.apache.sshd.common.util.io.NoCloseOutputStream',
'org.apache.sshd.server.Command',
'org.apache.sshd.server.Environment',
'org.apache.sshd.server.ExitCallback',
'org.apache.sshd.server.SessionAware',
'org.apache.sshd.server.Signal',
'org.apache.sshd.server.SshServer',
'org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider',
'org.apache.sshd.server.scp.ScpCommandFactory$Builder',
'org.apache.sshd.server.session.ServerSession',
'org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory$Builder',
'org.mozilla.universalchardet.UniversalDetector'
]
task run {
Move all sql integration tests into qa (elastic/x-pack-elasticsearch#2432) Builds on elastic/x-pack-elasticsearch#2403 to move all of sql's integration testing into qa modules with different running server configurations. The big advantage of this is that it allows us to test the cli and jdbc with security present. Creating a project that depends on both cli and jdbc and the server has some prickly jar hell issues because cli and jdbc package their dependencies in the jar. This works around it in a few days: 1. Include only a single copy of the JDBC dependencies with careful gradle work. 2. Do not include the CLI on the classpath at all and instead run it externally. I say "run it externally" rather than "fork it" because Elasticsearch tests aren't allowed to fork other processes. This is forbidden by seccomp on linux and seatbelt on osx and cannot be explicitly requested like additional security manager settings. So instead of forking the CLI process directly the tests interact with a test fixture that isn't bound by Elasticsearch's rules and *can* fork it. This forking of the CLI has a nice side effect: it forces us to make sure that things like security and connection strings other than `localhost:9200` work. The old test could and did work around missing features like that. The new tests cannot so I added the ability to set the connection string. Configuring usernames and passwords was also not supported but I did not add support for that, only created the failing test and marked it as `@AwaitsFix`. Original commit: elastic/x-pack-elasticsearch@560c6815e3e03306270a2affd758763f34613891
2017-09-21 09:58:52 -04:00
description = 'Run the CLI and connect to elasticsearch running on 9200'
doLast {
List command = [new File(project.javaHome, '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]
Move all sql integration tests into qa (elastic/x-pack-elasticsearch#2432) Builds on elastic/x-pack-elasticsearch#2403 to move all of sql's integration testing into qa modules with different running server configurations. The big advantage of this is that it allows us to test the cli and jdbc with security present. Creating a project that depends on both cli and jdbc and the server has some prickly jar hell issues because cli and jdbc package their dependencies in the jar. This works around it in a few days: 1. Include only a single copy of the JDBC dependencies with careful gradle work. 2. Do not include the CLI on the classpath at all and instead run it externally. I say "run it externally" rather than "fork it" because Elasticsearch tests aren't allowed to fork other processes. This is forbidden by seccomp on linux and seatbelt on osx and cannot be explicitly requested like additional security manager settings. So instead of forking the CLI process directly the tests interact with a test fixture that isn't bound by Elasticsearch's rules and *can* fork it. This forking of the CLI has a nice side effect: it forces us to make sure that things like security and connection strings other than `localhost:9200` work. The old test could and did work around missing features like that. The new tests cannot so I added the ability to set the connection string. Configuring usernames and passwords was also not supported but I did not add support for that, only created the failing test and marked it as `@AwaitsFix`. Original commit: elastic/x-pack-elasticsearch@560c6815e3e03306270a2affd758763f34613891
2017-09-21 09:58:52 -04:00
logger.info("running the cli with: ${command}")
new ProcessBuilder(command)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectInput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
.waitFor()
}
}