2016-08-22 18:40:46 -04:00
|
|
|
import java.nio.charset.StandardCharsets
|
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Path
|
|
|
|
import java.nio.file.StandardCopyOption
|
2015-11-25 18:28:45 -05:00
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
2016-01-18 18:20:33 -05:00
|
|
|
import org.elasticsearch.gradle.test.NodeInfo
|
2016-06-14 13:13:31 -04:00
|
|
|
|
2016-03-24 04:02:41 -04:00
|
|
|
group 'org.elasticsearch.plugin'
|
|
|
|
|
2015-11-25 18:28:45 -05:00
|
|
|
apply plugin: 'elasticsearch.esplugin'
|
|
|
|
esplugin {
|
2016-03-30 03:07:57 -04:00
|
|
|
name 'x-pack'
|
2015-11-25 18:28:45 -05:00
|
|
|
description 'Elasticsearch Expanded Pack Plugin'
|
|
|
|
classname 'org.elasticsearch.xpack.XPackPlugin'
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.versions = [
|
2016-04-22 03:45:46 -04:00
|
|
|
okhttp: '2.7.5'
|
2015-11-25 18:28:45 -05:00
|
|
|
]
|
|
|
|
|
2015-12-01 14:16:29 -05:00
|
|
|
// TODO: fix this! https://github.com/elastic/x-plugins/issues/1066
|
|
|
|
ext.compactProfile = 'full'
|
|
|
|
|
2016-07-25 21:06:16 -04:00
|
|
|
dependencyLicenses.enabled = false
|
|
|
|
|
2016-07-25 20:09:54 -04:00
|
|
|
licenseHeaders {
|
|
|
|
approvedLicenses << 'BCrypt (BSD-like)'
|
|
|
|
additionalLicense 'BCRYP', 'BCrypt (BSD-like)', 'Copyright (c) 2006 Damien Miller <djm@mindrot.org>'
|
|
|
|
}
|
2015-12-03 11:16:41 -05:00
|
|
|
|
2015-11-25 18:28:45 -05:00
|
|
|
dependencies {
|
2016-06-17 11:53:55 -04:00
|
|
|
// security deps
|
2016-07-14 22:03:29 -04:00
|
|
|
compile project(path: ':modules:transport-netty3', configuration: 'runtime')
|
2016-08-02 13:42:48 -04:00
|
|
|
compile project(path: ':modules:transport-netty4', configuration: 'runtime')
|
2015-11-25 18:28:45 -05:00
|
|
|
compile 'dk.brics.automaton:automaton:1.11-8'
|
2016-06-16 14:34:04 -04:00
|
|
|
compile 'com.unboundid:unboundid-ldapsdk:3.1.1'
|
2016-08-25 09:41:12 -04:00
|
|
|
compile 'org.bouncycastle:bcprov-jdk15on:1.55'
|
|
|
|
compile 'org.bouncycastle:bcpkix-jdk15on:1.55'
|
2016-06-27 05:07:15 -04:00
|
|
|
testCompile 'com.google.jimfs:jimfs:1.1'
|
2015-11-25 18:28:45 -05:00
|
|
|
|
|
|
|
// watcher deps
|
|
|
|
compile 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:r239'
|
2016-06-17 11:53:55 -04:00
|
|
|
compile 'com.google.guava:guava:16.0.1' // needed by watcher for the html sanitizer and security tests for jimfs
|
2015-11-25 18:28:45 -05:00
|
|
|
compile 'com.sun.mail:javax.mail:1.5.3'
|
2016-05-21 14:54:09 -04:00
|
|
|
// HACK: java 9 removed javax.activation from the default modules, so instead of trying to add modules, which would have
|
|
|
|
// to be conditionalized for java 8/9, we pull in the classes directly
|
|
|
|
compile 'javax.activation:activation:1.1'
|
|
|
|
|
2015-11-25 18:28:45 -05:00
|
|
|
testCompile 'org.subethamail:subethasmtp:3.1.7'
|
2016-04-22 03:45:46 -04:00
|
|
|
// needed for subethasmtp, has @GuardedBy annotation
|
|
|
|
testCompile 'com.google.code.findbugs:jsr305:3.0.1'
|
2015-11-25 18:28:45 -05:00
|
|
|
|
2016-08-22 20:29:31 -04:00
|
|
|
// monitoring deps
|
|
|
|
compile "org.elasticsearch.client:rest:${version}"
|
|
|
|
compile "org.elasticsearch.client:sniffer:${version}"
|
|
|
|
|
2015-11-25 18:28:45 -05:00
|
|
|
// common test deps
|
2015-12-10 15:26:05 -05:00
|
|
|
testCompile 'org.elasticsearch:securemock:1.2'
|
2015-11-25 18:28:45 -05:00
|
|
|
testCompile 'org.slf4j:slf4j-log4j12:1.6.2'
|
|
|
|
testCompile 'org.slf4j:slf4j-api:1.6.2'
|
|
|
|
|
|
|
|
// mock web server
|
|
|
|
testCompile "com.squareup.okhttp:mockwebserver:${versions.okhttp}"
|
|
|
|
testCompile "com.squareup.okhttp:okhttp:${versions.okhttp}"
|
|
|
|
testCompile "com.squareup.okhttp:okhttp-ws:${versions.okhttp}"
|
2016-04-22 03:45:46 -04:00
|
|
|
testCompile 'com.squareup.okio:okio:1.6.0'
|
2015-11-25 18:28:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// we keep the source directories in the original structure of split plugins,
|
|
|
|
// in order to facilitate backports to 2.x. TODO: remove after 5.0 release
|
2016-06-28 04:57:24 -04:00
|
|
|
for (String module : ['', 'license-plugin/', 'security/', 'watcher/', 'monitoring/', 'graph/']) {
|
2015-11-25 18:28:45 -05:00
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java.srcDir("${module}src/main/java")
|
|
|
|
resources.srcDir("${module}src/main/resources")
|
|
|
|
}
|
|
|
|
test {
|
|
|
|
java.srcDir("${module}src/test/java")
|
|
|
|
resources.srcDir("${module}src/test/resources")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-28 01:38:18 -04:00
|
|
|
// make LicenseSigner available for testing signed licenses
|
|
|
|
sourceSets.test.java {
|
|
|
|
srcDir '../license-tools/src/main/java'
|
|
|
|
}
|
|
|
|
|
2015-11-25 18:28:45 -05:00
|
|
|
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
|
|
|
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
|
|
|
|
|
|
|
ext.expansions = [
|
|
|
|
'project.version': version,
|
|
|
|
]
|
|
|
|
|
|
|
|
processResources {
|
2015-12-01 07:23:32 -05:00
|
|
|
from(sourceSets.main.resources.srcDirs) {
|
|
|
|
exclude '**/public.key'
|
|
|
|
inputs.properties(expansions)
|
|
|
|
MavenFilteringHack.filter(it, expansions)
|
|
|
|
}
|
2016-09-19 18:46:04 -04:00
|
|
|
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
|
|
|
|
if (snapshot) {
|
|
|
|
from 'license-plugin/keys/dev/public.key'
|
|
|
|
} else {
|
|
|
|
from 'license-plugin/keys/prod/public.key'
|
2015-12-17 17:01:32 -05:00
|
|
|
}
|
2015-11-25 18:28:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
forbiddenPatterns {
|
|
|
|
exclude '**/*.key'
|
|
|
|
exclude '**/*.p12'
|
2016-04-12 09:19:07 -04:00
|
|
|
exclude '**/*.der'
|
2016-08-29 12:00:19 -04:00
|
|
|
exclude '**/*.zip'
|
2015-11-25 18:28:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: standardize packaging config for plugins
|
|
|
|
bundlePlugin {
|
2016-07-25 08:02:39 -04:00
|
|
|
from(project(':x-plugins').projectDir) {
|
2015-11-25 18:28:45 -05:00
|
|
|
include 'LICENSE.txt'
|
2016-07-25 08:02:39 -04:00
|
|
|
}
|
|
|
|
from(projectDir) {
|
2015-11-25 18:28:45 -05:00
|
|
|
include 'NOTICE.txt'
|
|
|
|
}
|
2016-03-30 03:07:57 -04:00
|
|
|
from('bin/x-pack') {
|
2016-02-21 16:56:44 -05:00
|
|
|
into 'bin'
|
|
|
|
}
|
2016-06-17 11:53:55 -04:00
|
|
|
from('security/bin/x-pack') {
|
2015-11-25 18:28:45 -05:00
|
|
|
into 'bin'
|
|
|
|
}
|
2016-06-17 11:53:55 -04:00
|
|
|
from('security/config/x-pack') {
|
2015-11-25 18:28:45 -05:00
|
|
|
into 'config'
|
|
|
|
}
|
2016-03-30 03:07:57 -04:00
|
|
|
from('watcher/bin/x-pack') {
|
2015-11-25 18:28:45 -05:00
|
|
|
into 'bin'
|
|
|
|
}
|
2015-12-11 21:23:01 -05:00
|
|
|
}
|
2015-12-01 09:57:01 -05:00
|
|
|
|
2016-08-22 18:40:46 -04:00
|
|
|
// add api jar for extension authors to compile against
|
|
|
|
// note this is just the normal x-pack jar for now, with a different name
|
|
|
|
project.afterEvaluate {
|
|
|
|
task apiJar {
|
|
|
|
dependsOn('generatePomFileForApijarPublication', project.jar)
|
|
|
|
doFirst {
|
|
|
|
Path jarFile = project.jar.outputs.files.singleFile.toPath()
|
|
|
|
String apiFileName = jarFile.fileName.toString().replace(project.version, "api-${project.version}")
|
2016-08-29 12:00:19 -04:00
|
|
|
Files.copy(jarFile, jarFile.resolveSibling(apiFileName), StandardCopyOption.REPLACE_EXISTING)
|
2016-08-22 18:40:46 -04:00
|
|
|
|
|
|
|
String pomFileName = jarFile.fileName.toString().replace('.jar', '.pom')
|
|
|
|
String apiPomFileName = apiFileName.replace('.jar', '.pom')
|
|
|
|
Files.copy(jarFile.resolveSibling(pomFileName), jarFile.resolveSibling(apiPomFileName),
|
|
|
|
StandardCopyOption.REPLACE_EXISTING)
|
|
|
|
}
|
|
|
|
}
|
2016-08-30 14:23:22 -04:00
|
|
|
assemble.dependsOn(apiJar)
|
2016-08-22 18:40:46 -04:00
|
|
|
project.publishing {
|
|
|
|
publications {
|
|
|
|
apijar(MavenPublication) {
|
|
|
|
from project.components.java
|
|
|
|
artifactId = artifactId + '-api'
|
|
|
|
pom.withXml { XmlProvider xml ->
|
|
|
|
Node root = xml.asNode()
|
|
|
|
root.appendNode('name', project.pluginProperties.extension.name)
|
|
|
|
root.appendNode('description', project.pluginProperties.extension.description)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 21:23:01 -05:00
|
|
|
integTest {
|
2015-12-11 21:24:27 -05:00
|
|
|
// TODO: fix this rest test to not depend on a hardcoded port!
|
2016-05-09 07:27:54 -04:00
|
|
|
systemProperty 'tests.rest.blacklist', 'getting_started/10_monitor_cluster_health/*,bulk/10_basic/*'
|
2015-12-11 21:23:01 -05:00
|
|
|
cluster {
|
2016-07-07 17:59:39 -04:00
|
|
|
setting 'xpack.monitoring.collection.interval', '3s'
|
2016-01-18 18:20:33 -05:00
|
|
|
waitCondition = { NodeInfo node, AntBuilder ant ->
|
|
|
|
File tmpFile = new File(node.cwd, 'wait.success')
|
2016-06-14 13:13:31 -04:00
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
// we use custom wait logic here as the elastic user is not available immediately and ant.get will fail when a 401 is returned
|
|
|
|
HttpURLConnection httpURLConnection = null;
|
|
|
|
try {
|
2016-08-30 12:57:42 -04:00
|
|
|
httpURLConnection = (HttpURLConnection) new URL("http://${node.httpUri()}/_cluster/health?wait_for_nodes=${numNodes}").openConnection();
|
2016-06-14 13:13:31 -04:00
|
|
|
httpURLConnection.setRequestProperty("Authorization", "Basic " +
|
|
|
|
Base64.getEncoder().encodeToString("elastic:changeme".getBytes(StandardCharsets.UTF_8)));
|
|
|
|
httpURLConnection.setRequestMethod("GET");
|
|
|
|
httpURLConnection.connect();
|
|
|
|
if (httpURLConnection.getResponseCode() == 200) {
|
|
|
|
tmpFile.withWriter StandardCharsets.UTF_8.name(), {
|
|
|
|
it.write(httpURLConnection.getInputStream().getText(StandardCharsets.UTF_8.name()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2016-08-30 12:57:42 -04:00
|
|
|
if (i == 9) {
|
|
|
|
logger.error("final attempt of calling cluster health failed", e)
|
|
|
|
} else {
|
|
|
|
logger.debug("failed to call cluster health", e)
|
|
|
|
}
|
2016-06-14 13:13:31 -04:00
|
|
|
} finally {
|
|
|
|
if (httpURLConnection != null) {
|
|
|
|
httpURLConnection.disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// did not start, so wait a bit before trying again
|
|
|
|
Thread.sleep(500L);
|
|
|
|
}
|
2016-01-18 18:20:33 -05:00
|
|
|
return tmpFile.exists()
|
|
|
|
}
|
2015-12-01 09:57:01 -05:00
|
|
|
}
|
2015-11-25 18:28:45 -05:00
|
|
|
}
|
2015-12-01 14:16:29 -05:00
|
|
|
|
|
|
|
// TODO: don't publish test artifacts just to run messy tests, fix the tests!
|
|
|
|
// https://github.com/elastic/x-plugins/issues/724
|
|
|
|
configurations {
|
|
|
|
testArtifacts.extendsFrom testRuntime
|
|
|
|
}
|
|
|
|
task testJar(type: Jar) {
|
|
|
|
classifier "test"
|
|
|
|
from sourceSets.test.output
|
|
|
|
}
|
|
|
|
artifacts {
|
2016-04-13 11:38:23 -04:00
|
|
|
// normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions
|
|
|
|
archives jar
|
2015-12-01 14:16:29 -05:00
|
|
|
testArtifacts testJar
|
|
|
|
}
|
2015-12-16 18:57:05 -05:00
|
|
|
|
|
|
|
// classes are missing, e.g. com.ibm.icu.lang.UCharacter
|
|
|
|
thirdPartyAudit.excludes = [
|
|
|
|
// uses internal java api: sun.misc.Unsafe
|
|
|
|
'com.google.common.cache.Striped64',
|
|
|
|
'com.google.common.cache.Striped64$1',
|
|
|
|
'com.google.common.cache.Striped64$Cell',
|
|
|
|
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
|
|
|
|
'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1',
|
2016-05-22 01:42:15 -04:00
|
|
|
|
|
|
|
// pulled in as external dependency to work on java 9
|
|
|
|
'com.sun.activation.registries.LineTokenizer',
|
|
|
|
'com.sun.activation.registries.LogSupport',
|
|
|
|
'com.sun.activation.registries.MailcapFile',
|
|
|
|
'com.sun.activation.registries.MailcapParseException',
|
|
|
|
'com.sun.activation.registries.MailcapTokenizer',
|
|
|
|
'com.sun.activation.registries.MimeTypeEntry',
|
|
|
|
'com.sun.activation.registries.MimeTypeFile',
|
|
|
|
'javax.activation.ActivationDataFlavor',
|
|
|
|
'javax.activation.CommandInfo',
|
|
|
|
'javax.activation.CommandMap',
|
|
|
|
'javax.activation.CommandObject',
|
|
|
|
'javax.activation.DataContentHandler',
|
|
|
|
'javax.activation.DataContentHandlerFactory',
|
|
|
|
'javax.activation.DataHandler$1',
|
|
|
|
'javax.activation.DataHandler',
|
|
|
|
'javax.activation.DataHandlerDataSource',
|
|
|
|
'javax.activation.DataSource',
|
|
|
|
'javax.activation.DataSourceDataContentHandler',
|
|
|
|
'javax.activation.FileDataSource',
|
|
|
|
'javax.activation.FileTypeMap',
|
|
|
|
'javax.activation.MailcapCommandMap',
|
|
|
|
'javax.activation.MimeType',
|
|
|
|
'javax.activation.MimeTypeParameterList',
|
|
|
|
'javax.activation.MimeTypeParseException',
|
|
|
|
'javax.activation.MimetypesFileTypeMap',
|
|
|
|
'javax.activation.ObjectDataContentHandler',
|
|
|
|
'javax.activation.SecuritySupport$1',
|
|
|
|
'javax.activation.SecuritySupport$2',
|
|
|
|
'javax.activation.SecuritySupport$3',
|
|
|
|
'javax.activation.SecuritySupport$4',
|
|
|
|
'javax.activation.SecuritySupport$5',
|
|
|
|
'javax.activation.SecuritySupport',
|
|
|
|
'javax.activation.URLDataSource',
|
2016-08-29 12:00:19 -04:00
|
|
|
'javax.activation.UnsupportedDataTypeException'
|
2015-12-16 18:57:05 -05:00
|
|
|
]
|