2015-10-29 14:40:19 -04:00
|
|
|
/*
|
2017-01-05 11:15:34 -05:00
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
2015-10-29 14:40:19 -04:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2019-05-08 10:16:13 -04:00
|
|
|
|
|
|
|
import org.apache.tools.ant.filters.FixCrLfFilter
|
2017-12-26 04:51:47 -05:00
|
|
|
import org.elasticsearch.gradle.ConcatFilesTask
|
2020-05-18 10:19:40 -04:00
|
|
|
import org.elasticsearch.gradle.DependenciesInfoTask
|
2015-12-18 15:43:47 -05:00
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
2017-02-15 12:40:16 -05:00
|
|
|
import org.elasticsearch.gradle.NoticeTask
|
2019-03-08 14:04:18 -05:00
|
|
|
import org.elasticsearch.gradle.VersionProperties
|
2020-09-04 19:34:55 -04:00
|
|
|
import org.elasticsearch.gradle.info.BuildParams
|
2018-04-24 12:10:51 -04:00
|
|
|
|
2018-09-03 03:18:34 -04:00
|
|
|
import java.nio.file.Files
|
2019-09-17 16:40:35 -04:00
|
|
|
import java.nio.file.Path
|
|
|
|
|
2020-06-02 09:33:53 -04:00
|
|
|
plugins {
|
|
|
|
id 'base'
|
|
|
|
}
|
2017-12-26 04:51:47 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Third party dependencies report *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// Concatenates the dependencies CSV files into a single file
|
2020-06-02 09:33:53 -04:00
|
|
|
tasks.register("generateDependenciesReport", ConcatFilesTask) {
|
2020-05-18 10:19:40 -04:00
|
|
|
dependsOn rootProject.allprojects.collect { it.tasks.withType(DependenciesInfoTask) }
|
2019-11-14 06:01:23 -05:00
|
|
|
files = fileTree(dir: project.rootDir, include: '**/dependencies.csv')
|
2020-05-14 16:57:42 -04:00
|
|
|
headerLine = "name,version,url,license,sourceURL"
|
2019-11-14 06:01:23 -05:00
|
|
|
target = new File(System.getProperty('csv') ?: "${project.buildDir}/reports/dependencies/es-dependencies.csv")
|
2020-06-16 18:07:28 -04:00
|
|
|
|
|
|
|
// explicitly add our dependency on the JDK
|
|
|
|
String jdkVersion = VersionProperties.versions.get('bundled_jdk')
|
|
|
|
String jdkMajorVersion = jdkVersion.split('[+.]')[0]
|
2020-07-07 13:38:53 -04:00
|
|
|
String sourceUrl = "https://hg.openjdk.java.net/jdk-updates/jdk${jdkMajorVersion}u/archive/jdk-${jdkVersion}.tar.gz"
|
2020-06-16 18:07:28 -04:00
|
|
|
additionalLines << "OpenJDK,${jdkVersion},https://openjdk.java.net/,GPL-2.0-with-classpath-exception,${sourceUrl}".toString()
|
2020-09-29 03:16:43 -04:00
|
|
|
|
|
|
|
// Explicitly add the dependency on the RHEL UBI Docker base image
|
|
|
|
String[] rhelUbiFields = [
|
|
|
|
'Red Hat Universal Base Image minimal',
|
|
|
|
'8',
|
|
|
|
'https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8',
|
|
|
|
'Custom;https://www.redhat.com/licenses/EULA_Red_Hat_Universal_Base_Image_English_20190422.pdf',
|
|
|
|
'https://oss-dependencies.elastic.co/redhat/ubi/ubi-minimal-8-source.tar.gz'
|
|
|
|
]
|
|
|
|
additionalLines << rhelUbiFields.join(',')
|
2017-12-26 04:51:47 -05:00
|
|
|
}
|
|
|
|
|
2017-02-15 12:40:16 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Notice file *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-01-11 13:30:43 -05:00
|
|
|
// integ test zip only uses server, so a different notice file is needed there
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildServerNoticeTaskProvider = tasks.register("buildServerNotice", NoticeTask)
|
2017-02-15 12:40:16 -05:00
|
|
|
|
|
|
|
// other distributions include notices from modules as well, which are added below later
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildDefaultNoticeTaskProvider = tasks.register("buildDefaultNotice", NoticeTask) {
|
2019-03-29 17:20:53 -04:00
|
|
|
licensesDir new File(project(':distribution').projectDir, 'licenses')
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2020-06-04 13:34:24 -04:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildOssNoticeTaskProvider = tasks.register("buildOssNotice", NoticeTask) {
|
2019-03-29 17:20:53 -04:00
|
|
|
licensesDir new File(project(':distribution').projectDir, 'licenses')
|
|
|
|
}
|
2020-06-04 13:34:24 -04:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildDefaultNoJdkNoticeTaskProvider = tasks.register("buildDefaultNoJdkNotice", NoticeTask)
|
2020-06-04 13:34:24 -04:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildOssNoJdkNoticeTaskProvider = tasks.register("buildOssNoJdkNotice", NoticeTask)
|
2020-06-04 13:34:24 -04:00
|
|
|
|
|
|
|
// The :server and :libs projects belong to all distributions
|
2020-07-31 07:09:04 -04:00
|
|
|
tasks.withType(NoticeTask).configureEach {
|
2020-06-04 13:34:24 -04:00
|
|
|
licensesDir project(':server').file('licenses')
|
|
|
|
source project(':server').file('src/main/java')
|
|
|
|
project(':libs').subprojects.each { Project lib ->
|
|
|
|
licensesDir lib.file('licenses')
|
|
|
|
source lib.file('src/main/java')
|
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:26 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Modules *
|
|
|
|
*****************************************************************************/
|
2018-02-23 11:03:17 -05:00
|
|
|
String ossOutputs = 'build/outputs/oss'
|
|
|
|
String defaultOutputs = 'build/outputs/default'
|
2019-07-24 01:03:48 -04:00
|
|
|
String systemdOutputs = 'build/outputs/systemd'
|
2018-02-23 11:03:17 -05:00
|
|
|
String transportOutputs = 'build/outputs/transport-only'
|
2020-09-04 19:34:55 -04:00
|
|
|
String externalTestOutputs = 'build/outputs/external-test'
|
2018-02-23 11:03:17 -05:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def processOssOutputsTaskProvider = tasks.register("processOssOutputs", Sync) {
|
2018-02-23 11:03:17 -05:00
|
|
|
into ossOutputs
|
|
|
|
}
|
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def processDefaultOutputsTaskProvider = tasks.register("processDefaultOutputs", Sync) {
|
2018-02-23 11:03:17 -05:00
|
|
|
into defaultOutputs
|
2020-10-20 06:43:17 -04:00
|
|
|
from processOssOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def processSystemdOutputsTaskProvider = tasks.register("processSystemdOutputs", Sync) {
|
2019-07-24 01:03:48 -04:00
|
|
|
into systemdOutputs
|
|
|
|
}
|
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
def processExternalTestOutputsTaskProvider = tasks.register("processExternalTestOutputs", Sync) {
|
2020-09-04 19:34:55 -04:00
|
|
|
into externalTestOutputs
|
|
|
|
}
|
|
|
|
|
2018-02-23 11:03:17 -05:00
|
|
|
// Integ tests work over the rest http layer, so we need a transport included with the integ test zip.
|
|
|
|
// All transport modules are included so that they may be randomized for testing
|
2020-10-20 06:43:17 -04:00
|
|
|
def processTransportOutputsTaskProvider = tasks.register("processTransportOutputs", Sync) {
|
2018-02-23 11:03:17 -05:00
|
|
|
into transportOutputs
|
|
|
|
}
|
|
|
|
|
|
|
|
// these are dummy tasks that can be used to depend on the relevant sub output dir
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildOssModulesTaskProvider = tasks.register("buildOssModules") {
|
|
|
|
dependsOn processOssOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${ossOutputs}/modules"
|
|
|
|
}
|
2020-06-02 09:33:53 -04:00
|
|
|
tasks.register("buildOssBin") {
|
|
|
|
dependsOn "processOssOutputs"
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${ossOutputs}/bin"
|
|
|
|
}
|
2020-06-02 09:33:53 -04:00
|
|
|
tasks.register("buildOssConfig") {
|
|
|
|
dependsOn "processOssOutputs"
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${ossOutputs}/config"
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildDefaultModulesTaskProvider = tasks.register("buildDefaultModules") {
|
|
|
|
dependsOn processDefaultOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${defaultOutputs}/modules"
|
|
|
|
}
|
2020-06-02 09:33:53 -04:00
|
|
|
tasks.register("buildDefaultBin") {
|
2020-10-20 06:43:17 -04:00
|
|
|
dependsOn processDefaultOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${defaultOutputs}/bin"
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildDefaultConfigTaskProvider = tasks.register("buildDefaultConfig") {
|
|
|
|
dependsOn processOssOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${defaultOutputs}/config"
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildSystemdModuleTaskProvider = tasks.register("buildSystemdModule") {
|
2020-06-02 09:33:53 -04:00
|
|
|
dependsOn "processSystemdOutputs"
|
2019-07-24 01:03:48 -04:00
|
|
|
outputs.dir "${systemdOutputs}/modules"
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildTransportModulesTaskProvider = tasks.register("buildTransportModules") {
|
|
|
|
dependsOn processTransportOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
outputs.dir "${transportOutputs}/modules"
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildExternalTestModulesTaskProvider = tasks.register("buildExternalTestModules") {
|
2020-09-04 19:34:55 -04:00
|
|
|
dependsOn "processExternalTestOutputs"
|
|
|
|
outputs.dir "${externalTestOutputs}/modules"
|
|
|
|
}
|
|
|
|
|
|
|
|
Configuration moduleZip(Project module) {
|
|
|
|
Dependency dep = project.dependencies.project(path: module.path, configuration: 'zip')
|
|
|
|
Configuration config = project.configurations.detachedConfiguration(dep)
|
|
|
|
return config
|
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
void copyModule(TaskProvider<Sync> copyTask, Project module) {
|
2018-02-23 11:03:17 -05:00
|
|
|
copyTask.configure {
|
2020-10-20 06:43:17 -04:00
|
|
|
Configuration moduleConfig = moduleZip(module)
|
|
|
|
|
2020-09-04 19:34:55 -04:00
|
|
|
dependsOn moduleConfig
|
|
|
|
from({ zipTree(moduleConfig.singleFile) }) {
|
2018-02-23 11:03:17 -05:00
|
|
|
includeEmptyDirs false
|
|
|
|
|
|
|
|
// these are handled separately in the log4j config tasks below
|
|
|
|
exclude '*/config/log4j2.properties'
|
|
|
|
exclude 'config/log4j2.properties'
|
|
|
|
|
|
|
|
eachFile { details ->
|
2019-11-14 06:01:23 -05:00
|
|
|
String name = module.plugins.hasPlugin('elasticsearch.esplugin') ? module.esplugin.name : module.es_meta_plugin.name
|
2018-02-23 11:03:17 -05:00
|
|
|
// Copy all non config/bin files
|
|
|
|
// Note these might be unde a subdirectory in the case of a meta plugin
|
|
|
|
if ((details.relativePath.pathString ==~ /([^\/]+\/)?(config|bin)\/.*/) == false) {
|
|
|
|
details.relativePath = details.relativePath.prepend('modules', name)
|
|
|
|
} else if ((details.relativePath.pathString ==~ /([^\/]+\/)(config|bin)\/.*/)) {
|
|
|
|
// this is the meta plugin case, in which we need to remove the intermediate dir
|
|
|
|
String[] segments = details.relativePath.segments
|
|
|
|
details.relativePath = new RelativePath(true, segments.takeRight(segments.length - 1))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 17:18:26 -05:00
|
|
|
|
2018-02-23 11:03:17 -05:00
|
|
|
// log4j config could be contained in modules, so we must join it together using these tasks
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildOssLog4jConfigTaskProvider = tasks.register("buildOssLog4jConfig") {
|
2020-06-02 09:33:53 -04:00
|
|
|
dependsOn "processOssOutputs"
|
2018-02-23 11:03:17 -05:00
|
|
|
ext.contents = []
|
|
|
|
ext.log4jFile = file("${ossOutputs}/log4j2.properties")
|
|
|
|
outputs.file log4jFile
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildDefaultLog4jConfigTaskProvider = tasks.register("buildDefaultLog4jConfig") {
|
|
|
|
dependsOn processDefaultOutputsTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
ext.contents = []
|
|
|
|
ext.log4jFile = file("${defaultOutputs}/log4j2.properties")
|
|
|
|
outputs.file log4jFile
|
|
|
|
}
|
|
|
|
|
|
|
|
Closure writeLog4jProperties = {
|
|
|
|
String mainLog4jProperties = file('src/config/log4j2.properties').getText('UTF-8')
|
|
|
|
it.log4jFile.setText(mainLog4jProperties, 'UTF-8')
|
|
|
|
for (String moduleLog4jProperties : it.contents.reverse()) {
|
|
|
|
it.log4jFile.append(moduleLog4jProperties, 'UTF-8')
|
|
|
|
}
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
buildOssLog4jConfigTaskProvider.configure {
|
2020-06-02 09:33:53 -04:00
|
|
|
doLast(writeLog4jProperties)
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
|
|
|
|
buildDefaultLog4jConfigTaskProvider.configure {
|
2020-06-02 09:33:53 -04:00
|
|
|
doLast(writeLog4jProperties)
|
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
|
|
|
|
// copy log4j2.properties from modules that have it
|
2020-10-20 06:43:17 -04:00
|
|
|
void copyLog4jProperties(TaskProvider buildTask, Project module) {
|
|
|
|
buildTask.configure {
|
|
|
|
Configuration moduleConfig = moduleZip(module)
|
|
|
|
|
|
|
|
dependsOn moduleConfig
|
|
|
|
doFirst {
|
|
|
|
FileTree tree = zipTree(moduleConfig.singleFile)
|
|
|
|
FileTree filtered = tree.matching {
|
|
|
|
include 'config/log4j2.properties'
|
|
|
|
include '*/config/log4j2.properties' // could be in a bundled plugin
|
|
|
|
}
|
|
|
|
if (filtered.isEmpty() == false) {
|
|
|
|
contents.add('\n\n' + filtered.singleFile.getText('UTF-8'))
|
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
|
2016-07-11 16:00:45 -04:00
|
|
|
}
|
|
|
|
|
2015-12-04 16:38:09 -05:00
|
|
|
ext.restTestExpansions = [
|
|
|
|
'expected.modules.count': 0,
|
|
|
|
]
|
2018-02-23 11:03:17 -05:00
|
|
|
// we create the buildOssModules task above but fill it here so we can do a single
|
2015-12-10 19:16:49 -05:00
|
|
|
// loop over modules to also setup cross task dependencies and increment our modules counter
|
2018-01-18 22:16:26 -05:00
|
|
|
project.rootProject.subprojects.findAll { it.parent.path == ':modules' }.each { Project module ->
|
2019-07-24 01:03:48 -04:00
|
|
|
if (module.name == 'systemd') {
|
|
|
|
// the systemd module is only included in the package distributions
|
|
|
|
return
|
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
File licenses = new File(module.projectDir, 'licenses')
|
|
|
|
if (licenses.exists()) {
|
2020-10-20 06:43:17 -04:00
|
|
|
buildDefaultNoticeTaskProvider.configure {
|
|
|
|
licensesDir licenses
|
|
|
|
source module.file('src/main/java')
|
|
|
|
}
|
|
|
|
buildOssNotice.configure {
|
|
|
|
licensesDir licenses
|
|
|
|
source module.file('src/main/java')
|
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
copyModule(processOssOutputsTaskProvider, module)
|
2018-02-23 11:03:17 -05:00
|
|
|
if (module.name.startsWith('transport-')) {
|
2020-10-20 06:43:17 -04:00
|
|
|
copyModule(processTransportOutputsTaskProvider, module)
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
copyLog4jProperties(buildOssLog4jConfigTaskProvider, module)
|
|
|
|
copyLog4jProperties(buildDefaultLog4jConfigTaskProvider, module)
|
2018-02-23 11:03:17 -05:00
|
|
|
|
2015-12-10 19:16:49 -05:00
|
|
|
restTestExpansions['expected.modules.count'] += 1
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2020-10-20 06:43:17 -04:00
|
|
|
copyModule(processSystemdOutputsTaskProvider, project(':modules:systemd'))
|
2019-07-24 01:03:48 -04:00
|
|
|
|
2020-09-04 19:34:55 -04:00
|
|
|
project(':test:external-modules').subprojects.each { Project testModule ->
|
2020-10-20 06:43:17 -04:00
|
|
|
copyModule(processExternalTestOutputsTaskProvider, testModule)
|
2020-09-04 19:34:55 -04:00
|
|
|
}
|
|
|
|
|
2018-02-21 20:46:40 -05:00
|
|
|
configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
2019-05-08 10:16:13 -04:00
|
|
|
|
|
|
|
apply plugin: 'elasticsearch.jdk-download'
|
2020-07-10 11:16:47 -04:00
|
|
|
apply plugin: 'elasticsearch.repositories'
|
2019-05-08 10:16:13 -04:00
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
// Setup all required JDKs
|
|
|
|
project.jdks {
|
|
|
|
['darwin', 'windows', 'linux'].each { platform ->
|
|
|
|
(platform == 'linux' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
|
|
|
|
"bundled_${platform}_${architecture}" {
|
|
|
|
it.platform = platform
|
|
|
|
it.version = VersionProperties.getBundledJdk(platform)
|
|
|
|
it.vendor = VersionProperties.bundledJdkVendor
|
|
|
|
it.architecture = architecture
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
// TODO: the map needs to be an input of the tasks, so that when it changes, the task will re-run...
|
|
|
|
/*****************************************************************************
|
|
|
|
* Properties to expand when copying packaging files *
|
|
|
|
*****************************************************************************/
|
2020-07-10 11:16:47 -04:00
|
|
|
configurations {
|
|
|
|
['libs', 'libsPluginCli', 'libsKeystoreCli', 'libsSecurityCli'].each {
|
|
|
|
create(it) {
|
|
|
|
canBeConsumed = false
|
|
|
|
canBeResolved = true
|
|
|
|
attributes {
|
|
|
|
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
|
|
|
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
|
|
|
|
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
libs project(':server')
|
|
|
|
libs project(':libs:elasticsearch-plugin-classloader')
|
|
|
|
libs project(':distribution:tools:java-version-checker')
|
|
|
|
libs project(':distribution:tools:launchers')
|
|
|
|
|
|
|
|
libsPluginCli project(':distribution:tools:plugin-cli')
|
|
|
|
libsKeystoreCli project(path: ':distribution:tools:keystore-cli')
|
|
|
|
}
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
project.ext {
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Common files in all distributions *
|
|
|
|
*****************************************************************************/
|
2018-07-20 17:03:58 -04:00
|
|
|
libFiles = { oss ->
|
|
|
|
copySpec {
|
|
|
|
// delay by using closures, since they have not yet been configured, so no jar task exists yet
|
2020-07-10 11:16:47 -04:00
|
|
|
from(configurations.libs)
|
2018-07-20 17:03:58 -04:00
|
|
|
into('tools/plugin-cli') {
|
2020-07-10 11:16:47 -04:00
|
|
|
from(configurations.libsPluginCli)
|
2018-07-20 17:03:58 -04:00
|
|
|
}
|
2020-03-30 14:20:07 -04:00
|
|
|
into('tools/keystore-cli') {
|
2020-07-10 11:16:47 -04:00
|
|
|
from(configurations.libsKeystoreCli)
|
2020-03-30 14:20:07 -04:00
|
|
|
}
|
2018-07-20 17:03:58 -04:00
|
|
|
if (oss == false) {
|
|
|
|
into('tools/security-cli') {
|
2020-07-10 11:16:47 -04:00
|
|
|
from(configurations.libsSecurityCli)
|
2018-07-20 17:03:58 -04:00
|
|
|
}
|
|
|
|
}
|
2018-05-25 07:56:35 -04:00
|
|
|
}
|
2015-12-03 17:18:26 -05:00
|
|
|
}
|
|
|
|
|
2019-04-19 14:34:16 -04:00
|
|
|
modulesFiles = { oss, platform ->
|
2018-02-23 11:03:17 -05:00
|
|
|
copySpec {
|
|
|
|
eachFile {
|
2020-04-16 04:45:52 -04:00
|
|
|
if (it.relativePath.segments[-2] == 'bin' || (platform == 'darwin-x86_64' && it.relativePath.segments[-2] == 'MacOS')) {
|
2018-02-23 11:03:17 -05:00
|
|
|
// bin files, wherever they are within modules (eg platform specific) should be executable
|
2019-09-25 07:04:48 -04:00
|
|
|
// and MacOS is an alternative to bin on macOS
|
2018-02-23 11:03:17 -05:00
|
|
|
it.mode = 0755
|
2018-05-23 23:15:19 -04:00
|
|
|
} else {
|
|
|
|
it.mode = 0644
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
|
|
|
}
|
2020-10-20 06:43:17 -04:00
|
|
|
def buildModules
|
2018-02-23 11:03:17 -05:00
|
|
|
if (oss) {
|
2020-10-20 06:43:17 -04:00
|
|
|
buildModules = buildOssModulesTaskProvider
|
2018-02-23 11:03:17 -05:00
|
|
|
} else {
|
2020-10-20 06:43:17 -04:00
|
|
|
buildModules = buildDefaultModulesTaskProvider
|
2019-04-19 14:34:16 -04:00
|
|
|
}
|
2020-04-16 04:45:52 -04:00
|
|
|
List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64']
|
2019-04-19 14:34:16 -04:00
|
|
|
if (platform != null) {
|
2019-11-14 06:01:23 -05:00
|
|
|
excludePlatforms.remove(excludePlatforms.indexOf(platform))
|
2019-04-19 14:34:16 -04:00
|
|
|
} else {
|
2019-11-14 06:01:23 -05:00
|
|
|
excludePlatforms = []
|
2019-04-19 14:34:16 -04:00
|
|
|
}
|
|
|
|
from(buildModules) {
|
|
|
|
for (String excludePlatform : excludePlatforms) {
|
2020-04-16 04:45:52 -04:00
|
|
|
exclude "**/platform/${excludePlatform}/**"
|
2019-04-19 14:34:16 -04:00
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2020-09-04 19:34:55 -04:00
|
|
|
if (BuildParams.isSnapshotBuild()) {
|
2020-10-20 06:43:17 -04:00
|
|
|
from(buildExternalTestModulesTaskProvider)
|
2020-09-04 19:34:55 -04:00
|
|
|
}
|
2019-07-24 01:03:48 -04:00
|
|
|
if (project.path.startsWith(':distribution:packages')) {
|
2020-10-20 06:43:17 -04:00
|
|
|
from(buildSystemdModuleTaskProvider)
|
2019-07-24 01:03:48 -04:00
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2016-07-12 15:13:52 -04:00
|
|
|
transportModulesFiles = copySpec {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildTransportModulesTaskProvider
|
2016-07-11 16:00:45 -04:00
|
|
|
}
|
2016-07-12 15:13:52 -04:00
|
|
|
|
2019-03-29 08:24:52 -04:00
|
|
|
configFiles = { distributionType, oss, jdk ->
|
2018-02-21 20:46:40 -05:00
|
|
|
copySpec {
|
2018-02-23 11:03:17 -05:00
|
|
|
with copySpec {
|
|
|
|
// main config files, processed with distribution specific substitutions
|
|
|
|
from '../src/config'
|
|
|
|
exclude 'log4j2.properties' // this is handled separately below
|
2019-03-29 08:24:52 -04:00
|
|
|
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
|
|
|
if (oss) {
|
|
|
|
from project(':distribution').buildOssLog4jConfig
|
|
|
|
from project(':distribution').buildOssConfig
|
|
|
|
} else {
|
|
|
|
from project(':distribution').buildDefaultLog4jConfig
|
|
|
|
from project(':distribution').buildDefaultConfig
|
|
|
|
}
|
2018-02-21 20:46:40 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2019-03-29 08:24:52 -04:00
|
|
|
binFiles = { distributionType, oss, jdk ->
|
2018-02-21 20:46:40 -05:00
|
|
|
copySpec {
|
2019-11-14 06:01:23 -05:00
|
|
|
// non-windows files, for all distributions
|
2018-02-23 11:03:17 -05:00
|
|
|
with copySpec {
|
|
|
|
from '../src/bin'
|
|
|
|
exclude '*.exe'
|
|
|
|
exclude '*.bat'
|
|
|
|
eachFile { it.setMode(0755) }
|
2019-03-29 08:24:52 -04:00
|
|
|
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2018-06-18 13:02:51 -04:00
|
|
|
// windows files, only for zip
|
|
|
|
if (distributionType == 'zip') {
|
|
|
|
with copySpec {
|
|
|
|
from '../src/bin'
|
|
|
|
include '*.bat'
|
|
|
|
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
|
2019-03-29 08:24:52 -04:00
|
|
|
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
|
2018-06-18 13:02:51 -04:00
|
|
|
}
|
|
|
|
with copySpec {
|
|
|
|
from '../src/bin'
|
|
|
|
include '*.exe'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// module provided bin files
|
2018-02-23 11:03:17 -05:00
|
|
|
with copySpec {
|
|
|
|
eachFile { it.setMode(0755) }
|
|
|
|
if (oss) {
|
|
|
|
from project(':distribution').buildOssBin
|
|
|
|
} else {
|
|
|
|
from project(':distribution').buildDefaultBin
|
|
|
|
}
|
2018-06-18 13:02:51 -04:00
|
|
|
if (distributionType != 'zip') {
|
|
|
|
exclude '*.bat'
|
|
|
|
}
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2018-02-21 20:46:40 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2016-05-26 12:19:38 -04:00
|
|
|
|
2019-03-29 17:20:53 -04:00
|
|
|
noticeFile = { oss, jdk ->
|
|
|
|
copySpec {
|
|
|
|
if (project.name == 'integ-test-zip') {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildServerNoticeTaskProvider
|
2019-03-29 17:20:53 -04:00
|
|
|
} else {
|
|
|
|
if (oss && jdk) {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildOssNoticeTaskProvider
|
2019-03-29 17:20:53 -04:00
|
|
|
} else if (oss) {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildOssNoJdkNoticeTaskProvider
|
2019-03-29 17:20:53 -04:00
|
|
|
} else if (jdk) {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildDefaultNoticeTaskProvider
|
2019-03-29 17:20:53 -04:00
|
|
|
} else {
|
2020-10-20 06:43:17 -04:00
|
|
|
from buildDefaultNoJdkNoticeTaskProvider
|
2019-03-29 17:20:53 -04:00
|
|
|
}
|
2019-11-14 06:01:23 -05:00
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
|
|
|
}
|
2019-03-08 14:04:18 -05:00
|
|
|
|
2020-03-22 11:58:11 -04:00
|
|
|
jdkFiles = { Project project, String platform, String architecture ->
|
2019-05-08 10:16:13 -04:00
|
|
|
return copySpec {
|
2020-03-22 11:58:11 -04:00
|
|
|
from project.jdks."bundled_${platform}_${architecture}"
|
2019-09-27 03:34:51 -04:00
|
|
|
exclude "demo/**"
|
2020-04-15 09:28:17 -04:00
|
|
|
/*
|
|
|
|
* The Contents/MacOS directory interferes with notarization, and is unused by our distribution, so we exclude
|
|
|
|
* it from the build.
|
|
|
|
*/
|
|
|
|
if ("darwin".equals(platform)) {
|
|
|
|
exclude "Contents/MacOS"
|
|
|
|
}
|
2019-03-08 14:04:18 -05:00
|
|
|
eachFile { FileCopyDetails details ->
|
2019-03-07 13:53:44 -05:00
|
|
|
if (details.relativePath.segments[-2] == 'bin' || details.relativePath.segments[-1] == 'jspawnhelper') {
|
2019-03-08 14:04:18 -05:00
|
|
|
details.mode = 0755
|
|
|
|
}
|
2019-06-05 13:08:30 -04:00
|
|
|
if (details.name == 'src.zip') {
|
|
|
|
details.exclude()
|
|
|
|
}
|
2019-03-08 14:04:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-05 15:47:54 -05:00
|
|
|
/**
|
|
|
|
* Build some variables that are replaced in the packages. This includes both
|
2016-02-04 10:00:55 -05:00
|
|
|
* scripts like bin/elasticsearch and bin/elasticsearch-plugin that a user might run and also
|
2015-11-05 15:47:54 -05:00
|
|
|
* scripts like postinst which are run as part of the installation.
|
|
|
|
*
|
|
|
|
* <dl>
|
|
|
|
* <dt>package.name</dt>
|
|
|
|
* <dd>The name of the project. Its sprinkled throughout the scripts.</dd>
|
|
|
|
* <dt>package.version</dt>
|
|
|
|
* <dd>The version of the project. Its mostly used to find the exact jar name.
|
|
|
|
* </dt>
|
|
|
|
* <dt>path.conf</dt>
|
|
|
|
* <dd>The default directory from which to load configuration. This is used in
|
|
|
|
* the packaging scripts, but in that context it is always
|
2016-02-04 10:00:55 -05:00
|
|
|
* /etc/elasticsearch. Its also used in bin/elasticsearch-plugin, where it is
|
2015-11-05 15:47:54 -05:00
|
|
|
* /etc/elasticsearch for the os packages but $ESHOME/config otherwise.</dd>
|
|
|
|
* <dt>path.env</dt>
|
|
|
|
* <dd>The env file sourced before bin/elasticsearch to set environment
|
|
|
|
* variables. Think /etc/defaults/elasticsearch.</dd>
|
|
|
|
* <dt>heap.min and heap.max</dt>
|
|
|
|
* <dd>Default min and max heap</dd>
|
|
|
|
* <dt>scripts.footer</dt>
|
|
|
|
* <dd>Footer appended to control scripts embedded in the distribution that is
|
|
|
|
* (almost) entirely there for cosmetic reasons.</dd>
|
|
|
|
* <dt>stopping.timeout</dt>
|
|
|
|
* <dd>RPM's init script needs to wait for elasticsearch to stop before
|
|
|
|
* returning from stop and it needs a maximum time to wait. This is it. One
|
|
|
|
* day. DEB retries forever.</dd>
|
|
|
|
* </dl>
|
|
|
|
*/
|
2018-02-21 20:46:40 -05:00
|
|
|
subprojects {
|
2019-03-29 08:24:52 -04:00
|
|
|
ext.expansionsForDistribution = { distributionType, oss, jdk ->
|
2018-02-21 20:46:40 -05:00
|
|
|
final String defaultHeapSize = "1g"
|
|
|
|
final String packagingPathData = "path.data: /var/lib/elasticsearch"
|
|
|
|
final String pathLogs = "/var/log/elasticsearch"
|
|
|
|
final String packagingPathLogs = "path.logs: ${pathLogs}"
|
|
|
|
final String packagingLoggc = "${pathLogs}/gc.log"
|
|
|
|
|
2018-04-09 18:20:01 -04:00
|
|
|
String licenseText
|
|
|
|
if (oss) {
|
2018-04-10 16:58:49 -04:00
|
|
|
licenseText = rootProject.file('licenses/APACHE-LICENSE-2.0.txt').getText('UTF-8')
|
2018-04-09 18:20:01 -04:00
|
|
|
} else {
|
2018-04-10 16:58:49 -04:00
|
|
|
licenseText = rootProject.file('licenses/ELASTIC-LICENSE.txt').getText('UTF-8')
|
2018-04-09 18:20:01 -04:00
|
|
|
}
|
|
|
|
// license text needs to be indented with a single space
|
2019-11-14 06:01:23 -05:00
|
|
|
licenseText = ' ' + licenseText.replace('\n', '\n ')
|
2018-04-09 18:20:01 -04:00
|
|
|
|
2018-02-21 20:46:40 -05:00
|
|
|
String footer = "# Built for ${project.name}-${project.version} " +
|
2019-11-14 06:01:23 -05:00
|
|
|
"(${distributionType})"
|
2018-02-21 20:46:40 -05:00
|
|
|
Map<String, Object> expansions = [
|
|
|
|
'project.name': project.name,
|
|
|
|
'project.version': version,
|
|
|
|
|
|
|
|
'path.conf': [
|
|
|
|
'deb': '/etc/elasticsearch',
|
|
|
|
'rpm': '/etc/elasticsearch',
|
|
|
|
'def': '"$ES_HOME"/config'
|
|
|
|
],
|
|
|
|
'path.data': [
|
|
|
|
'deb': packagingPathData,
|
|
|
|
'rpm': packagingPathData,
|
|
|
|
'def': '#path.data: /path/to/data'
|
|
|
|
],
|
|
|
|
'path.env': [
|
|
|
|
'deb': '/etc/default/elasticsearch',
|
|
|
|
'rpm': '/etc/sysconfig/elasticsearch',
|
|
|
|
/* There isn't one of these files for tar or zip but its important to
|
|
|
|
make an empty string here so the script can properly skip it. */
|
|
|
|
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; done',
|
|
|
|
],
|
|
|
|
'source.path.env': [
|
2019-11-14 06:01:23 -05:00
|
|
|
'deb': 'source /etc/default/elasticsearch',
|
|
|
|
'rpm': 'source /etc/sysconfig/elasticsearch',
|
|
|
|
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
|
2018-02-21 20:46:40 -05:00
|
|
|
],
|
|
|
|
'path.logs': [
|
|
|
|
'deb': packagingPathLogs,
|
|
|
|
'rpm': packagingPathLogs,
|
|
|
|
'def': '#path.logs: /path/to/logs'
|
|
|
|
],
|
|
|
|
'loggc': [
|
|
|
|
'deb': packagingLoggc,
|
|
|
|
'rpm': packagingLoggc,
|
|
|
|
'def': 'logs/gc.log'
|
|
|
|
],
|
|
|
|
|
|
|
|
'heap.min': defaultHeapSize,
|
|
|
|
'heap.max': defaultHeapSize,
|
|
|
|
|
|
|
|
'heap.dump.path': [
|
|
|
|
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
|
|
|
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
2018-03-18 15:32:37 -04:00
|
|
|
'def': "-XX:HeapDumpPath=data"
|
2018-02-21 20:46:40 -05:00
|
|
|
],
|
|
|
|
|
2018-03-13 16:32:16 -04:00
|
|
|
'error.file': [
|
|
|
|
'deb': "-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log",
|
|
|
|
'rpm': "-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log",
|
2018-03-18 15:33:17 -04:00
|
|
|
'def': "-XX:ErrorFile=logs/hs_err_pid%p.log"
|
2018-03-13 16:32:16 -04:00
|
|
|
],
|
|
|
|
|
2018-02-21 20:46:40 -05:00
|
|
|
'stopping.timeout': [
|
|
|
|
'rpm': 86400,
|
|
|
|
],
|
|
|
|
|
|
|
|
'scripts.footer': [
|
|
|
|
/* Debian needs exit 0 on these scripts so we add it here and preserve
|
|
|
|
the pretty footer. */
|
|
|
|
'deb': "exit 0\n${footer}",
|
|
|
|
'def': footer
|
|
|
|
],
|
2018-03-19 15:13:31 -04:00
|
|
|
|
|
|
|
'es.distribution.flavor': [
|
|
|
|
'def': oss ? 'oss' : 'default'
|
2018-04-09 18:20:01 -04:00
|
|
|
],
|
|
|
|
|
2018-04-11 22:37:59 -04:00
|
|
|
|
|
|
|
'es.distribution.type': [
|
|
|
|
'deb': 'deb',
|
|
|
|
'rpm': 'rpm',
|
|
|
|
'tar': 'tar',
|
|
|
|
'zip': 'zip'
|
|
|
|
],
|
|
|
|
|
2019-03-29 08:24:52 -04:00
|
|
|
'es.bundled_jdk': [
|
|
|
|
'def': jdk ? 'true' : 'false'
|
|
|
|
],
|
|
|
|
|
2018-04-09 18:20:01 -04:00
|
|
|
'license.name': [
|
|
|
|
'deb': oss ? 'ASL-2.0' : 'Elastic-License'
|
|
|
|
],
|
|
|
|
|
|
|
|
'license.text': [
|
|
|
|
'deb': licenseText,
|
|
|
|
],
|
2018-02-21 20:46:40 -05:00
|
|
|
]
|
|
|
|
Map<String, String> result = [:]
|
|
|
|
expansions = expansions.each { key, value ->
|
|
|
|
if (value instanceof Map) {
|
|
|
|
// 'def' is for default but its three characters like 'rpm' and 'deb'
|
|
|
|
value = value[distributionType] ?: value['def']
|
|
|
|
if (value == null) {
|
|
|
|
return
|
|
|
|
}
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
2018-02-21 20:46:40 -05:00
|
|
|
result[key] = value
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
2018-02-21 20:46:40 -05:00
|
|
|
return result
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
2018-09-03 03:18:34 -04:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
ext.assertLinesInFile = { Path path, List<String> expectedLines ->
|
2018-09-03 03:18:34 -04:00
|
|
|
final List<String> actualLines = Files.readAllLines(path)
|
|
|
|
int line = 0
|
|
|
|
for (final String expectedLine : expectedLines) {
|
|
|
|
final String actualLine = actualLines.get(line)
|
|
|
|
if (expectedLine != actualLine) {
|
|
|
|
throw new GradleException("expected line [${line + 1}] in [${path}] to be [${expectedLine}] but was [${actualLine}]")
|
|
|
|
}
|
|
|
|
line++
|
|
|
|
}
|
|
|
|
}
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
2019-03-07 10:25:09 -05:00
|
|
|
|
2019-11-14 06:01:23 -05:00
|
|
|
['archives:windows-zip', 'archives:oss-windows-zip',
|
2020-07-10 11:16:47 -04:00
|
|
|
'archives:darwin-tar', 'archives:oss-darwin-tar',
|
|
|
|
'archives:linux-aarch64-tar', 'archives:oss-linux-aarch64-tar',
|
|
|
|
'archives:linux-tar', 'archives:oss-linux-tar',
|
|
|
|
'archives:integ-test-zip',
|
|
|
|
'packages:rpm', 'packages:deb',
|
|
|
|
'packages:aarch64-rpm', 'packages:aarch64-deb',
|
|
|
|
'packages:oss-rpm', 'packages:oss-deb',
|
|
|
|
'packages:aarch64-oss-rpm', 'packages:aarch64-oss-deb'
|
2019-03-07 10:25:09 -05:00
|
|
|
].forEach { subName ->
|
|
|
|
Project subproject = project("${project.path}:${subName}")
|
|
|
|
Configuration configuration = configurations.create(subproject.name)
|
|
|
|
dependencies {
|
2020-09-10 02:08:50 -04:00
|
|
|
"${configuration.name}" project(path: subproject.path, configuration:'default')
|
2019-03-07 10:25:09 -05:00
|
|
|
}
|
2019-03-07 10:48:49 -05:00
|
|
|
}
|