2016-02-22 14:37:57 -05:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2016-05-09 13:45:14 -04:00
|
|
|
import org.elasticsearch.gradle.precommit.PrecommitTasks
|
2016-02-22 14:37:57 -05:00
|
|
|
|
2017-07-24 13:55:43 -04:00
|
|
|
/**
|
|
|
|
* The rest client is a shaded jar. It contains the source of the rest client, as well as all the dependencies,
|
2017-07-26 05:25:25 -04:00
|
|
|
* shaded to the `org.elasticsearch.client` package. 2 artifacts come out of this build process. The shading process
|
|
|
|
* only modifies the imports and class names and locations. It does not do any processing on the files. The classes used
|
|
|
|
* to interact with the rest client are no different from the dependencies in the shade configuration, besides in name.
|
2017-07-24 13:55:43 -04:00
|
|
|
*
|
|
|
|
* IDEs do not like removing artifacts and changing configurations on the fly, so the bits that make the build use the
|
2017-07-26 05:25:25 -04:00
|
|
|
* actual shaded jar (2) are only executed on the cli. Tests run in an IDE rely on the deps (1) jar.
|
2017-07-24 13:55:43 -04:00
|
|
|
*
|
2017-07-26 05:25:25 -04:00
|
|
|
* 1) A jar that contains *only* the `org.elasticsearch.client` shaded dependencies. This is a jar that is built before
|
|
|
|
* the src is compiled. This jar is only used by the rest client so will compile. There exists a chicken-egg
|
|
|
|
* situation where the src needs compilation and depends on `org.elasticsearch.client` shaded classes, so an
|
|
|
|
* intermediary jar needs to exist to satisfy the compile. The `deps` classifier is added to this jar.
|
|
|
|
* 2) The *actual* jar that will be used by clients. This has no classifier, contains the rest client src and
|
2017-07-24 13:55:43 -04:00
|
|
|
* `org.elasticsearch.client`. This jar is the only actual output artifact of this job.
|
|
|
|
*/
|
2017-07-27 10:22:18 -04:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
|
|
|
|
}
|
2017-07-24 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
2016-02-22 14:37:57 -05:00
|
|
|
apply plugin: 'elasticsearch.build'
|
2016-06-10 03:51:47 -04:00
|
|
|
apply plugin: 'ru.vyarus.animalsniffer'
|
2016-07-29 10:41:39 -04:00
|
|
|
apply plugin: 'nebula.maven-base-publish'
|
|
|
|
apply plugin: 'nebula.maven-scm'
|
2016-02-22 14:37:57 -05:00
|
|
|
|
2016-05-09 13:45:14 -04:00
|
|
|
targetCompatibility = JavaVersion.VERSION_1_7
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
|
|
|
|
2016-07-01 04:22:55 -04:00
|
|
|
group = 'org.elasticsearch.client'
|
2017-07-13 03:44:25 -04:00
|
|
|
archivesBaseName = 'elasticsearch-rest-client'
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
nebula {
|
|
|
|
artifactId = archivesBaseName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-01 04:22:55 -04:00
|
|
|
|
2017-07-24 13:55:43 -04:00
|
|
|
configurations {
|
|
|
|
shade {
|
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Useful for build time dependencies, as it is generated before compilation of the source in the rest client.
|
|
|
|
// This cannot be used as the final shaded jar, as it will contain the compiled source and dependencies
|
|
|
|
File shadedDir = file("${buildDir}/shaded")
|
|
|
|
// This directory exists so that the shadeDeps task would produce an output, so we can add it (below) to the source set.
|
|
|
|
File shadedSrcDir = file("${buildDir}/generated-dummy-shaded")
|
|
|
|
task shadeDeps(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
|
|
|
|
destinationDir = shadedDir
|
|
|
|
configurations = [project.configurations.shade]
|
|
|
|
classifier = 'deps'
|
|
|
|
relocate 'org.apache', 'org.elasticsearch.client'
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
shadedSrcDir.mkdir()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
2017-07-26 05:25:25 -04:00
|
|
|
from zipTree(shadeDeps.outputs.files.singleFile)
|
|
|
|
dependsOn shadeDeps
|
2017-07-24 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
2017-07-26 05:25:25 -04:00
|
|
|
// remove the deps jar from the classpath to avoid jarHell
|
2017-07-24 13:55:43 -04:00
|
|
|
if (isIdea == false && isEclipse == false) {
|
2017-07-26 05:25:25 -04:00
|
|
|
// cleanup to remove the deps jar from the classpath
|
|
|
|
if (gradle.gradleVersion == "3.3") {
|
|
|
|
configurations.runtime.extendsFrom -= [configurations.compile]
|
|
|
|
} else if (gradle.gradleVersion > "3.3") {
|
|
|
|
configurations.runtimeElements.extendsFrom = []
|
2017-07-24 13:55:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-27 11:20:53 -04:00
|
|
|
if (isEclipse) {
|
|
|
|
// in eclipse the project is under a fake root, we need to change around the source sets
|
|
|
|
sourceSets {
|
|
|
|
if (project.path == ":client:rest") {
|
|
|
|
main.java.srcDirs = ['java']
|
|
|
|
//main.resources.srcDirs = ['resources']
|
|
|
|
} else {
|
|
|
|
test.java.srcDirs = ['java']
|
|
|
|
test.resources.srcDirs = ['resources']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-24 13:55:43 -04:00
|
|
|
// adds a dependency to compile, so the -deps jar is built first
|
|
|
|
sourceSets.main.output.dir(shadedSrcDir, builtBy: 'shadeDeps')
|
|
|
|
|
2016-02-22 14:37:57 -05:00
|
|
|
dependencies {
|
2017-07-24 13:55:43 -04:00
|
|
|
shade "org.apache.httpcomponents:httpclient:${versions.httpclient}"
|
|
|
|
shade "org.apache.httpcomponents:httpcore:${versions.httpcore}"
|
|
|
|
shade "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}"
|
|
|
|
shade "org.apache.httpcomponents:httpcore-nio:${versions.httpcore}"
|
|
|
|
shade "commons-codec:commons-codec:${versions.commonscodec}"
|
|
|
|
shade "commons-logging:commons-logging:${versions.commonslogging}"
|
|
|
|
|
|
|
|
compile shadeDeps.outputs.files
|
2016-04-08 09:24:21 -04:00
|
|
|
|
2017-07-27 11:20:53 -04:00
|
|
|
if (isEclipse == false || project.path == ":client:rest-tests") {
|
|
|
|
testCompile("org.elasticsearch.client:test:${version}") {
|
|
|
|
// tests use the locally compiled version of core
|
|
|
|
exclude group: 'org.elasticsearch', module: 'elasticsearch'
|
|
|
|
}
|
|
|
|
}
|
2016-02-22 14:37:57 -05:00
|
|
|
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
|
|
|
|
testCompile "junit:junit:${versions.junit}"
|
2016-06-06 09:02:52 -04:00
|
|
|
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
|
|
|
|
testCompile "org.elasticsearch:securemock:${versions.securemock}"
|
2017-01-04 15:38:51 -05:00
|
|
|
testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
|
2016-06-10 04:11:21 -04:00
|
|
|
testCompile "org.codehaus.mojo:animal-sniffer-annotations:1.15"
|
2016-06-10 03:51:47 -04:00
|
|
|
signature "org.codehaus.mojo.signature:java17:1.0@signature"
|
2016-02-22 14:37:57 -05:00
|
|
|
}
|
|
|
|
|
2017-07-27 11:20:53 -04:00
|
|
|
// Set the exported=true for the generated rest client deps since it is used by other projects in eclipse.
|
|
|
|
// https://docs.gradle.org/3.3/userguide/eclipse_plugin.html#sec:eclipse_modify_domain_objects
|
|
|
|
eclipse.classpath.file {
|
|
|
|
whenMerged { classpath ->
|
|
|
|
classpath.entries.findAll { entry -> entry.path.contains("elasticsearch-rest-client") }*.exported = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 13:55:43 -04:00
|
|
|
dependencyLicenses.dependencies = project.configurations.shade
|
|
|
|
|
2016-02-22 14:37:57 -05:00
|
|
|
forbiddenApisMain {
|
2017-02-17 14:45:41 -05:00
|
|
|
//client does not depend on core, so only jdk and http signatures should be checked
|
|
|
|
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt'),
|
|
|
|
PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
|
2016-02-22 14:37:57 -05:00
|
|
|
}
|
|
|
|
|
2016-06-09 11:39:52 -04:00
|
|
|
forbiddenApisTest {
|
2016-06-10 06:41:49 -04:00
|
|
|
//we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
|
|
|
|
bundledSignatures -= 'jdk-non-portable'
|
|
|
|
bundledSignatures += 'jdk-internal'
|
2016-04-11 08:32:19 -04:00
|
|
|
//client does not depend on core, so only jdk signatures should be checked
|
2017-02-17 14:45:41 -05:00
|
|
|
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt'),
|
|
|
|
PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
|
2016-06-09 11:39:52 -04:00
|
|
|
}
|
2016-04-11 08:32:19 -04:00
|
|
|
|
|
|
|
//JarHell is part of es core, which we don't want to pull in
|
2017-07-24 13:55:43 -04:00
|
|
|
jarHell.enabled = false
|
2016-06-17 05:37:01 -04:00
|
|
|
|
|
|
|
namingConventions {
|
2016-06-22 13:22:48 -04:00
|
|
|
testClass = 'org.elasticsearch.client.RestClientTestCase'
|
2016-06-17 05:37:01 -04:00
|
|
|
//we don't have integration tests
|
|
|
|
skipIntegTestInDisguise = true
|
|
|
|
}
|
2016-02-22 14:37:57 -05:00
|
|
|
|
|
|
|
thirdPartyAudit.excludes = [
|
2016-04-08 09:24:21 -04:00
|
|
|
//commons-logging optional dependencies
|
2017-07-24 13:55:43 -04:00
|
|
|
'org.elasticsearch.client.avalon.framework.logger.Logger',
|
|
|
|
'org.elasticsearch.client.log.Hierarchy',
|
|
|
|
'org.elasticsearch.client.log.Logger',
|
|
|
|
'org.elasticsearch.client.log4j.Category',
|
|
|
|
'org.elasticsearch.client.log4j.Level',
|
|
|
|
'org.elasticsearch.client.log4j.Logger',
|
|
|
|
'org.elasticsearch.client.log4j.Priority',
|
2016-04-08 09:24:21 -04:00
|
|
|
//commons-logging provided dependencies
|
|
|
|
'javax.servlet.ServletContextEvent',
|
|
|
|
'javax.servlet.ServletContextListener'
|
2016-02-22 14:37:57 -05:00
|
|
|
]
|