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.
|
|
|
|
*/
|
|
|
|
|
2015-12-18 15:43:47 -05:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
import org.apache.tools.ant.filters.FixCrLfFilter
|
2015-11-20 14:43:49 -05:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
2016-05-13 19:32:35 -04:00
|
|
|
import org.elasticsearch.gradle.BuildPlugin
|
2015-12-18 15:43:47 -05:00
|
|
|
import org.elasticsearch.gradle.EmptyDirTask
|
2017-12-26 04:51:47 -05:00
|
|
|
import org.elasticsearch.gradle.ConcatFilesTask
|
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
|
2015-10-29 14:40:19 -04:00
|
|
|
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
2015-12-01 20:08:27 -05:00
|
|
|
import org.elasticsearch.gradle.precommit.UpdateShasTask
|
2015-11-16 19:02:44 -05:00
|
|
|
import org.elasticsearch.gradle.test.RunTask
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
// for deb/rpm
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dependencies {
|
2016-03-21 10:38:01 -04:00
|
|
|
classpath 'com.netflix.nebula:gradle-ospackage-plugin:3.4.0'
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-24 01:32:13 -04:00
|
|
|
Collection distributions = project.subprojects.findAll {
|
2017-05-29 10:22:32 -04:00
|
|
|
it.path.contains(':tools') == false && it.path.contains(':bwc') == false }
|
2017-02-15 16:55:19 -05:00
|
|
|
|
2017-12-26 04:51:47 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Third party dependencies report *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// Concatenates the dependencies CSV files into a single file
|
|
|
|
task generateDependenciesReport(type: ConcatFilesTask) {
|
|
|
|
files = fileTree(dir: project.rootDir, include: '**/dependencies.csv' )
|
|
|
|
headerLine = "name,version,url,license"
|
|
|
|
target = new File(System.getProperty('csv')?: "${project.buildDir}/dependencies/es-dependencies.csv")
|
|
|
|
}
|
|
|
|
|
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
|
2017-02-15 12:40:16 -05:00
|
|
|
task buildCoreNotice(type: NoticeTask) {
|
2018-01-11 13:30:43 -05:00
|
|
|
licensesDir new File(project(':server').projectDir, 'licenses')
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// other distributions include notices from modules as well, which are added below later
|
|
|
|
task buildFullNotice(type: NoticeTask) {
|
2018-01-11 13:30:43 -05:00
|
|
|
licensesDir new File(project(':server').projectDir, 'licenses')
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
|
|
|
|
2015-12-03 17:18:26 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Modules *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2015-12-10 20:30:05 -05:00
|
|
|
task buildModules(type: Sync) {
|
2015-12-03 17:18:26 -05:00
|
|
|
into 'build/modules'
|
2016-07-11 16:00:45 -04:00
|
|
|
}
|
|
|
|
|
2015-12-04 16:38:09 -05:00
|
|
|
ext.restTestExpansions = [
|
|
|
|
'expected.modules.count': 0,
|
|
|
|
]
|
2015-12-03 17:18:26 -05:00
|
|
|
// we create the buildModules task above so the distribution subprojects can
|
2015-12-10 19:16:49 -05:00
|
|
|
// depend on it, but we don't actually configure it until here so we can do a single
|
|
|
|
// loop over modules to also setup cross task dependencies and increment our modules counter
|
|
|
|
project.rootProject.subprojects.findAll { it.path.startsWith(':modules:') }.each { Project module ->
|
2017-02-15 12:40:16 -05:00
|
|
|
buildFullNotice {
|
2017-04-10 07:37:42 -04:00
|
|
|
def defaultLicensesDir = new File(module.projectDir, 'licenses')
|
|
|
|
if (defaultLicensesDir.exists()) {
|
|
|
|
licensesDir defaultLicensesDir
|
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
}
|
2015-12-10 19:16:49 -05:00
|
|
|
buildModules {
|
|
|
|
dependsOn({ project(module.path).bundlePlugin })
|
|
|
|
into(module.name) {
|
|
|
|
from { zipTree(project(module.path).bundlePlugin.outputs.files.singleFile) }
|
2015-12-03 17:18:26 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2015-12-10 19:16:49 -05:00
|
|
|
// We would like to make sure integ tests for the distribution run after
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
// integ tests for the modules included in the distribution.
|
2017-03-24 01:32:13 -04:00
|
|
|
project.configure(distributions.findAll { it.name != 'integ-test-zip'}) { Project distribution ->
|
2015-12-10 19:16:49 -05:00
|
|
|
distribution.afterEvaluate({
|
2016-07-22 22:26:35 -04:00
|
|
|
// some integTest tasks will have multiple finalizers
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
distribution.integTest.mustRunAfter module.tasks.find { t -> t.name.matches(".*integTest\$") }
|
2015-12-10 19:16:49 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
// also want to make sure the module's integration tests run after the integ-test-zip (ie rest tests)
|
|
|
|
module.afterEvaluate({
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
module.integTest.mustRunAfter(':distribution:integ-test-zip:integTest')
|
2015-12-10 19:16:49 -05:00
|
|
|
})
|
|
|
|
restTestExpansions['expected.modules.count'] += 1
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2017-01-03 15:39:36 -05:00
|
|
|
// Integ tests work over the rest http layer, so we need a transport included with the integ test zip.
|
2016-07-12 15:13:52 -04:00
|
|
|
// All transport modules are included so that they may be randomized for testing
|
|
|
|
task buildTransportModules(type: Sync) {
|
|
|
|
into 'build/transport-modules'
|
2016-07-11 16:00:45 -04:00
|
|
|
}
|
|
|
|
|
2016-07-12 15:13:52 -04:00
|
|
|
project.rootProject.subprojects.findAll { it.path.startsWith(':modules:transport-') }.each { Project transport ->
|
|
|
|
buildTransportModules {
|
|
|
|
dependsOn({ project(transport.path).bundlePlugin })
|
|
|
|
into(transport.name) {
|
|
|
|
from { zipTree(project(transport.path).bundlePlugin.outputs.files.singleFile) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-11 16:00:45 -04:00
|
|
|
|
2015-12-03 17:18:26 -05:00
|
|
|
// make sure we have a clean task since we aren't a java project, but we have tasks that
|
|
|
|
// put stuff in the build dir
|
|
|
|
task clean(type: Delete) {
|
|
|
|
delete 'build'
|
|
|
|
}
|
|
|
|
|
2017-02-15 16:55:19 -05:00
|
|
|
configure(distributions) {
|
2015-11-03 01:19:29 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
* Rest test config *
|
|
|
|
*****************************************************************************/
|
2017-01-04 14:26:55 -05:00
|
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
2015-11-02 20:48:15 -05:00
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
2015-12-03 04:49:54 -05:00
|
|
|
project.integTest {
|
2015-12-10 22:05:47 -05:00
|
|
|
includePackaged project.name == 'integ-test-zip'
|
2015-12-10 19:16:49 -05:00
|
|
|
if (project.name != 'integ-test-zip') {
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
mustRunAfter ':distribution:integ-test-zip:integTest'
|
2015-12-10 19:16:49 -05:00
|
|
|
}
|
2015-11-02 20:48:15 -05:00
|
|
|
}
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
project.integTestCluster {
|
2017-04-17 19:02:46 -04:00
|
|
|
dependsOn project.assemble
|
Build: Rework integ test setup and shutdown to ensure stop runs when desired (#23304)
Gradle's finalizedBy on tasks only ensures one task runs after another,
but not immediately after. This is problematic for our integration tests
since it allows multiple project's integ test clusters to be
simultaneously. While this has not been a problem thus far (gradle 2.13
happened to keep the finalizedBy tasks close enough that no clusters
were running in parallel), with gradle 3.3 the task graph generation has
changed, and numerous clusters may be running simultaneously, causing
memory pressure, and thus generally slower tests, or even failure if the
system has a limited amount of memory (eg in a vagrant host).
This commit reworks how integ tests are configured. It adds an
`integTestCluster` extension to gradle which is equivalent to the current
`integTest.cluster` and moves the rest test runner task to
`integTestRunner`. The `integTest` task is then just a dummy task,
which depends on the cluster runner task, as well as the cluster stop
task. This means running `integTest` in one project will both run the
rest tests, and shut down the cluster, before running `integTest` in
another project.
2017-02-22 15:43:15 -05:00
|
|
|
distribution = project.name
|
|
|
|
}
|
2017-01-03 15:39:36 -05:00
|
|
|
|
2015-12-04 16:38:09 -05:00
|
|
|
processTestResources {
|
|
|
|
inputs.properties(project(':distribution').restTestExpansions)
|
|
|
|
MavenFilteringHack.filter(it, project(':distribution').restTestExpansions)
|
|
|
|
}
|
2015-11-02 20:48:15 -05:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
* Maven config *
|
|
|
|
*****************************************************************************/
|
|
|
|
// note: the group must be correct before applying the nexus plugin, or it will capture the wrong value...
|
|
|
|
project.group = "org.elasticsearch.distribution.${project.name}"
|
2016-05-13 19:32:35 -04:00
|
|
|
project.archivesBaseName = 'elasticsearch'
|
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 *
|
|
|
|
*****************************************************************************/
|
|
|
|
project.ext {
|
2015-11-05 15:47:54 -05:00
|
|
|
expansions = expansionsForDistribution(project.name)
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Common files in all distributions *
|
|
|
|
*****************************************************************************/
|
|
|
|
libFiles = copySpec {
|
|
|
|
into 'lib'
|
2018-01-11 13:30:43 -05:00
|
|
|
from { project(':server').jar }
|
|
|
|
from { project(':server').configurations.runtime }
|
2018-01-03 14:12:43 -05:00
|
|
|
from { project(':libs:plugin-classloader').jar }
|
2017-02-15 16:55:19 -05:00
|
|
|
// delay add tools using closures, since they have not yet been configured, so no jar task exists yet
|
2017-12-06 18:03:13 -05:00
|
|
|
from { project(':distribution:tools:launchers').jar }
|
2017-04-21 12:25:58 -04:00
|
|
|
from { project(':distribution:tools:plugin-cli').jar }
|
2015-12-03 17:18:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
modulesFiles = copySpec {
|
|
|
|
into 'modules'
|
|
|
|
from project(':distribution').buildModules
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2016-07-12 15:13:52 -04:00
|
|
|
transportModulesFiles = copySpec {
|
|
|
|
into "modules"
|
|
|
|
from project(':distribution').buildTransportModules
|
2016-07-11 16:00:45 -04:00
|
|
|
}
|
2016-07-12 15:13:52 -04:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
configFiles = copySpec {
|
|
|
|
from '../src/main/resources/config'
|
2016-04-11 07:15:19 -04:00
|
|
|
MavenFilteringHack.filter(it, expansions)
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2016-05-26 12:19:38 -04:00
|
|
|
binFiles = copySpec {
|
|
|
|
// everything except windows files
|
|
|
|
from '../src/main/resources/bin'
|
|
|
|
exclude '*.bat'
|
|
|
|
exclude '*.exe'
|
|
|
|
eachFile { it.setMode(0755) }
|
2015-11-05 15:47:54 -05:00
|
|
|
MavenFilteringHack.filter(it, expansions)
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2016-05-26 12:19:38 -04:00
|
|
|
|
|
|
|
commonFiles = copySpec {
|
|
|
|
from rootProject.projectDir
|
|
|
|
include 'LICENSE.txt'
|
|
|
|
include 'README.textile'
|
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
|
|
|
|
noticeFile = copySpec {
|
|
|
|
if (project.name == 'integ-test-zip') {
|
|
|
|
from buildCoreNotice
|
|
|
|
} else {
|
|
|
|
from buildFullNotice
|
|
|
|
}
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2016-05-05 20:53:01 -04:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Publishing setup *
|
|
|
|
*****************************************************************************/
|
2016-09-19 18:10:41 -04:00
|
|
|
if (['zip', 'integ-test-zip'].contains(it.name)) {
|
|
|
|
BuildPlugin.configurePomGeneration(project)
|
|
|
|
apply plugin: 'nebula.info-scm'
|
|
|
|
apply plugin: 'nebula.maven-base-publish'
|
|
|
|
apply plugin: 'nebula.maven-scm'
|
2016-05-05 20:53:01 -04:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Zip and tgz configuration *
|
|
|
|
*****************************************************************************/
|
2017-02-15 16:55:19 -05:00
|
|
|
configure(distributions.findAll { ['zip', 'tar', 'integ-test-zip'].contains(it.name) }) {
|
2016-11-02 12:14:47 -04:00
|
|
|
// CopySpec does not make it easy to create an empty director so we create the directory that we want, and then point CopySpec to its
|
|
|
|
// parent to copy to the root of the distribution
|
2017-12-03 08:33:21 -05:00
|
|
|
File logs = new File(buildDir, 'logs-hack/logs')
|
|
|
|
task createLogDir(type: EmptyDirTask) {
|
|
|
|
dir "${logs}"
|
|
|
|
dirMode 0755
|
|
|
|
}
|
2016-11-02 12:14:47 -04:00
|
|
|
File plugins = new File(buildDir, 'plugins-hack/plugins')
|
|
|
|
task createPluginsDir(type: EmptyDirTask) {
|
|
|
|
dir "${plugins}"
|
|
|
|
dirMode 0755
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
project.ext.archivesFiles = copySpec {
|
|
|
|
into("elasticsearch-${version}") {
|
|
|
|
with libFiles
|
|
|
|
into('config') {
|
2016-10-24 03:42:03 -04:00
|
|
|
dirMode 0750
|
|
|
|
fileMode 0660
|
2015-10-29 14:40:19 -04:00
|
|
|
with configFiles
|
|
|
|
}
|
2016-05-26 12:19:38 -04:00
|
|
|
into('bin') {
|
|
|
|
with copySpec {
|
|
|
|
with binFiles
|
2016-05-30 03:19:35 -04:00
|
|
|
from('../src/main/resources/bin') {
|
|
|
|
include '*.bat'
|
2016-05-26 12:19:38 -04:00
|
|
|
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
|
|
|
|
}
|
|
|
|
MavenFilteringHack.filter(it, expansions)
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
2017-12-03 08:33:21 -05:00
|
|
|
into('') {
|
|
|
|
from {
|
|
|
|
dirMode 0755
|
|
|
|
logs.getParent()
|
|
|
|
}
|
|
|
|
}
|
2016-11-01 15:14:24 -04:00
|
|
|
into('') {
|
|
|
|
from {
|
2017-05-06 13:25:10 -04:00
|
|
|
dirMode 0755
|
2016-11-01 15:14:24 -04:00
|
|
|
plugins.getParent()
|
|
|
|
}
|
|
|
|
}
|
2016-05-26 12:19:38 -04:00
|
|
|
with commonFiles
|
2017-02-15 12:40:16 -05:00
|
|
|
with noticeFile
|
2015-10-29 14:40:19 -04:00
|
|
|
from('../src/main/resources') {
|
2015-11-05 15:47:54 -05:00
|
|
|
include 'bin/*.exe'
|
|
|
|
}
|
2015-12-04 02:03:14 -05:00
|
|
|
if (project.name != 'integ-test-zip') {
|
|
|
|
with modulesFiles
|
2016-07-11 16:00:45 -04:00
|
|
|
} else {
|
2016-07-12 15:13:52 -04:00
|
|
|
with transportModulesFiles
|
2015-12-04 02:03:14 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Deb and rpm configuration *
|
2015-11-05 15:47:54 -05:00
|
|
|
*****************************************************************************
|
|
|
|
*
|
|
|
|
* The general strategy here is to build a directory on disk, packagingFiles
|
|
|
|
* that contains stuff that needs to be copied into the distributions. This is
|
|
|
|
* important for two reasons:
|
|
|
|
* 1. ospackage wants to copy the directory permissions that it sees off of the
|
|
|
|
* filesystem. If you ask it to create a directory that doesn't already
|
|
|
|
* exist on disk it petulantly creates it with 0755 permissions, no matter
|
|
|
|
* how hard you try to convince it otherwise.
|
|
|
|
* 2. Convincing ospackage to pick up an empty directory as part of a set of
|
|
|
|
* directories on disk is reasonably easy. Convincing it to just create an
|
|
|
|
* empty directory requires more wits than I have.
|
|
|
|
* 3. ospackage really wants to suck up some of the debian control scripts
|
|
|
|
* directly from the filesystem. It doesn't want to process them through
|
|
|
|
* MavenFilteringHack or any other copy-style action.
|
2016-10-24 03:42:03 -04:00
|
|
|
*
|
|
|
|
* The following commands are useful when it comes to check the user/group
|
|
|
|
* and files permissions set within the RPM and DEB packages:
|
|
|
|
*
|
|
|
|
* rpm -qlp --dump path/to/elasticsearch.rpm
|
|
|
|
* dpkg -c path/to/elasticsearch.deb
|
2015-11-05 15:47:54 -05:00
|
|
|
*/
|
2017-02-15 16:55:19 -05:00
|
|
|
configure(distributions.findAll { ['deb', 'rpm'].contains(it.name) }) {
|
2015-11-25 19:21:38 -05:00
|
|
|
integTest.enabled = Os.isFamily(Os.FAMILY_WINDOWS) == false
|
2015-11-05 15:47:54 -05:00
|
|
|
File packagingFiles = new File(buildDir, 'packaging')
|
|
|
|
project.ext.packagingFiles = packagingFiles
|
|
|
|
task processPackagingFiles(type: Copy) {
|
|
|
|
from '../src/main/packaging'
|
|
|
|
from 'src/main/packaging'
|
|
|
|
|
|
|
|
MavenFilteringHack.filter(it, expansions)
|
|
|
|
into packagingFiles
|
|
|
|
/* Explicitly declare the outputs so that gradle won't skip this task if
|
|
|
|
one of the other tasks like createEtc run first and create the packaging
|
|
|
|
directory as a side effect. */
|
|
|
|
outputs.dir("${packagingFiles}/env")
|
|
|
|
outputs.dir("${packagingFiles}/systemd")
|
|
|
|
}
|
|
|
|
|
|
|
|
task createEtc(type: EmptyDirTask) {
|
|
|
|
dir "${packagingFiles}/etc/elasticsearch"
|
|
|
|
dirMode 0750
|
2018-01-09 00:40:59 -05:00
|
|
|
outputs.dir dir
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
task fillEtc(type: Copy) {
|
2017-05-17 17:42:25 -04:00
|
|
|
dependsOn createEtc
|
2015-11-05 15:47:54 -05:00
|
|
|
with configFiles
|
|
|
|
into "${packagingFiles}/etc/elasticsearch"
|
|
|
|
/* Explicitly declare the output files so this task doesn't consider itself
|
|
|
|
up to date when the directory is created, which it would by default. And
|
|
|
|
that'll happen when createEtc runs. */
|
|
|
|
outputs.file "${packagingFiles}/etc/elasticsearch/elasticsearch.yml"
|
2016-04-11 07:15:19 -04:00
|
|
|
outputs.file "${packagingFiles}/etc/elasticsearch/jvm.options"
|
2016-08-09 13:34:23 -04:00
|
|
|
outputs.file "${packagingFiles}/etc/elasticsearch/log4j2.properties"
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
task createPidDir(type: EmptyDirTask) {
|
|
|
|
dir "${packagingFiles}/var/run/elasticsearch"
|
|
|
|
}
|
|
|
|
task createLogDir(type: EmptyDirTask) {
|
|
|
|
dir "${packagingFiles}/var/log/elasticsearch"
|
|
|
|
}
|
|
|
|
task createDataDir(type: EmptyDirTask) {
|
|
|
|
dir "${packagingFiles}/var/lib/elasticsearch"
|
|
|
|
}
|
|
|
|
task createPluginsDir(type: EmptyDirTask) {
|
|
|
|
dir "${packagingFiles}/usr/share/elasticsearch/plugins"
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the build/packaging directory to be like the target filesystem
|
|
|
|
* because ospackage will use arbitrary permissions if you try to create a
|
|
|
|
* directory that doesn't exist on the filesystem.
|
|
|
|
*/
|
|
|
|
task preparePackagingFiles {
|
|
|
|
dependsOn processPackagingFiles, fillEtc, createPidDir, createLogDir,
|
|
|
|
createDataDir, createPluginsDir
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
apply plugin: 'nebula.ospackage-base'
|
|
|
|
ospackage {
|
2015-11-05 15:47:54 -05:00
|
|
|
packageName 'elasticsearch'
|
|
|
|
maintainer 'Elasticsearch Team <info@elastic.co>'
|
|
|
|
summary '''
|
|
|
|
Elasticsearch is a distributed RESTful search engine built for the cloud.
|
|
|
|
Reference documentation can be found at
|
|
|
|
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
|
|
|
|
and the 'Elasticsearch: The Definitive Guide' book can be found at
|
|
|
|
https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html
|
|
|
|
'''.stripIndent().replace('\n', ' ').trim()
|
|
|
|
url 'https://www.elastic.co/'
|
|
|
|
|
2016-04-15 11:13:12 -04:00
|
|
|
// signing setup
|
|
|
|
if (project.hasProperty('signing.password') && System.getProperty('build.snapshot', 'true') == 'false') {
|
|
|
|
signingKeyId = project.hasProperty('signing.keyId') ? project.property('signing.keyId') : 'D88E42B4'
|
|
|
|
signingKeyPassphrase = project.property('signing.password')
|
|
|
|
signingKeyRingFile = project.hasProperty('signing.secretKeyRingFile') ?
|
|
|
|
project.file(project.property('signing.secretKeyRingFile')) :
|
|
|
|
new File(new File(System.getProperty('user.home'), '.gnupg'), 'secring.gpg')
|
|
|
|
}
|
|
|
|
|
2015-11-05 15:47:54 -05:00
|
|
|
String scripts = "${packagingFiles}/scripts"
|
|
|
|
preInstall file("${scripts}/preinst")
|
|
|
|
postInstall file("${scripts}/postinst")
|
|
|
|
preUninstall file("${scripts}/prerm")
|
|
|
|
postUninstall file("${scripts}/postrm")
|
|
|
|
|
2016-05-11 20:05:09 -04:00
|
|
|
if (project.name == 'rpm') {
|
|
|
|
requires('/bin/bash')
|
|
|
|
} else if (project.name == 'deb') {
|
|
|
|
requires('bash')
|
|
|
|
}
|
2017-12-04 21:21:57 -05:00
|
|
|
requires('coreutils')
|
2016-05-10 21:17:09 -04:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
into '/usr/share/elasticsearch'
|
2016-04-18 17:31:28 -04:00
|
|
|
fileMode 0644
|
|
|
|
dirMode 0755
|
2015-10-29 14:40:19 -04:00
|
|
|
user 'root'
|
|
|
|
permissionGroup 'root'
|
|
|
|
with libFiles
|
2015-12-03 17:18:26 -05:00
|
|
|
with modulesFiles
|
2016-05-26 12:19:38 -04:00
|
|
|
into('bin') {
|
|
|
|
with binFiles
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
with copySpec {
|
|
|
|
with commonFiles
|
2015-11-05 15:47:54 -05:00
|
|
|
if (project.name == 'deb') {
|
|
|
|
// Deb gets a copyright file instead.
|
|
|
|
exclude 'LICENSE.txt'
|
|
|
|
}
|
|
|
|
}
|
2017-02-15 12:40:16 -05:00
|
|
|
with noticeFile
|
2015-11-05 15:47:54 -05:00
|
|
|
|
|
|
|
configurationFile '/etc/elasticsearch/elasticsearch.yml'
|
2016-04-11 07:15:19 -04:00
|
|
|
configurationFile '/etc/elasticsearch/jvm.options'
|
2016-08-09 13:34:23 -04:00
|
|
|
configurationFile '/etc/elasticsearch/log4j2.properties'
|
2016-05-06 13:24:54 -04:00
|
|
|
into('/etc/elasticsearch') {
|
2016-10-24 03:42:03 -04:00
|
|
|
dirMode 0750
|
|
|
|
fileMode 0660
|
2015-11-05 15:47:54 -05:00
|
|
|
permissionGroup 'elasticsearch'
|
|
|
|
includeEmptyDirs true
|
|
|
|
createDirectoryEntry true
|
2016-05-06 13:24:54 -04:00
|
|
|
fileType CONFIG | NOREPLACE
|
|
|
|
from "${packagingFiles}/etc/elasticsearch"
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
into('/usr/lib/tmpfiles.d') {
|
|
|
|
from "${packagingFiles}/systemd/elasticsearch.conf"
|
|
|
|
}
|
|
|
|
configurationFile '/usr/lib/systemd/system/elasticsearch.service'
|
|
|
|
into('/usr/lib/systemd/system') {
|
2016-05-06 13:24:54 -04:00
|
|
|
fileType CONFIG | NOREPLACE
|
2015-11-05 15:47:54 -05:00
|
|
|
from "${packagingFiles}/systemd/elasticsearch.service"
|
|
|
|
}
|
|
|
|
into('/usr/lib/sysctl.d') {
|
2016-05-06 13:24:54 -04:00
|
|
|
fileType CONFIG | NOREPLACE
|
2015-11-05 15:47:54 -05:00
|
|
|
from "${packagingFiles}/systemd/sysctl/elasticsearch.conf"
|
|
|
|
}
|
|
|
|
configurationFile '/etc/init.d/elasticsearch'
|
|
|
|
into('/etc/init.d') {
|
2016-10-24 03:42:03 -04:00
|
|
|
fileMode 0750
|
2016-05-06 13:24:54 -04:00
|
|
|
fileType CONFIG | NOREPLACE
|
|
|
|
from "${packagingFiles}/init.d/elasticsearch"
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
|
|
|
configurationFile project.expansions['path.env']
|
|
|
|
into(new File(project.expansions['path.env']).getParent()) {
|
2016-05-06 13:24:54 -04:00
|
|
|
fileType CONFIG | NOREPLACE
|
2016-10-24 03:42:03 -04:00
|
|
|
fileMode 0660
|
2016-05-06 13:24:54 -04:00
|
|
|
from "${project.packagingFiles}/env/elasticsearch"
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2015-11-05 15:47:54 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Suck up all the empty directories that we need to install into the path.
|
|
|
|
*/
|
2016-10-24 03:42:03 -04:00
|
|
|
Closure suckUpEmptyDirectories = { path, u, g, mode ->
|
2015-11-05 15:47:54 -05:00
|
|
|
into(path) {
|
|
|
|
from "${packagingFiles}/${path}"
|
|
|
|
includeEmptyDirs true
|
|
|
|
createDirectoryEntry true
|
2016-03-17 15:35:21 -04:00
|
|
|
user u
|
|
|
|
permissionGroup g
|
2016-10-24 03:42:03 -04:00
|
|
|
dirMode mode
|
|
|
|
fileMode mode
|
2015-11-05 15:47:54 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
2016-10-24 03:42:03 -04:00
|
|
|
suckUpEmptyDirectories('/var/run', 'elasticsearch', 'elasticsearch', 0755)
|
|
|
|
suckUpEmptyDirectories('/var/log', 'elasticsearch', 'elasticsearch', 0750)
|
|
|
|
suckUpEmptyDirectories('/var/lib', 'elasticsearch', 'elasticsearch', 0750)
|
|
|
|
suckUpEmptyDirectories('/usr/share/elasticsearch', 'root', 'root', 0755)
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-13 19:36:26 -04:00
|
|
|
task run(type: RunTask) {
|
|
|
|
distribution = 'zip'
|
|
|
|
}
|
2015-11-16 19:02:44 -05: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>
|
|
|
|
*/
|
|
|
|
Map<String, String> expansionsForDistribution(distributionType) {
|
2017-07-14 12:38:08 -04:00
|
|
|
final String defaultHeapSize = "1g"
|
2017-06-26 21:43:20 -04:00
|
|
|
final String packagingPathData = "path.data: /var/lib/elasticsearch"
|
2017-12-03 08:33:21 -05:00
|
|
|
final String pathLogs = "/var/log/elasticsearch"
|
|
|
|
final String packagingPathLogs = "path.logs: ${pathLogs}"
|
|
|
|
final String packagingLoggc = "${pathLogs}/gc.log"
|
2016-08-19 11:38:46 -04:00
|
|
|
|
2015-11-05 15:47:54 -05:00
|
|
|
String footer = "# Built for ${project.name}-${project.version} " +
|
|
|
|
"(${distributionType})"
|
|
|
|
Map<String, Object> expansions = [
|
|
|
|
'project.name': project.name,
|
|
|
|
'project.version': version,
|
|
|
|
|
|
|
|
'path.conf': [
|
2017-07-20 20:38:49 -04:00
|
|
|
'tar': '"$ES_HOME"/config',
|
|
|
|
'zip': '"$ES_HOME"/config',
|
|
|
|
'integ-test-zip': '"$ES_HOME"/config',
|
2015-11-05 15:47:54 -05:00
|
|
|
'def': '/etc/elasticsearch',
|
|
|
|
],
|
2017-06-26 21:43:20 -04:00
|
|
|
'path.data': [
|
|
|
|
'deb': packagingPathData,
|
|
|
|
'rpm': packagingPathData,
|
|
|
|
'def': '#path.data: /path/to/data'
|
|
|
|
],
|
2015-11-05 15:47:54 -05:00
|
|
|
'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. */
|
2017-08-14 17:19:06 -04:00
|
|
|
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; done',
|
2017-07-20 20:38:49 -04:00
|
|
|
],
|
|
|
|
'source.path.env': [
|
2017-12-11 15:40:10 -05:00
|
|
|
'deb': 'source /etc/default/elasticsearch',
|
|
|
|
'rpm': 'source /etc/sysconfig/elasticsearch',
|
2017-08-14 17:19:06 -04:00
|
|
|
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
|
2015-11-05 15:47:54 -05:00
|
|
|
],
|
2017-06-26 21:43:20 -04:00
|
|
|
'path.logs': [
|
|
|
|
'deb': packagingPathLogs,
|
|
|
|
'rpm': packagingPathLogs,
|
|
|
|
'def': '#path.logs: /path/to/logs'
|
|
|
|
],
|
2017-12-03 08:33:21 -05:00
|
|
|
'loggc': [
|
|
|
|
'deb': packagingLoggc,
|
|
|
|
'rpm': packagingLoggc,
|
|
|
|
'def': 'logs/gc.log'
|
|
|
|
],
|
2015-11-05 15:47:54 -05:00
|
|
|
|
2016-08-19 11:38:46 -04:00
|
|
|
'heap.min': defaultHeapSize,
|
|
|
|
'heap.max': defaultHeapSize,
|
2015-11-05 15:47:54 -05:00
|
|
|
|
2017-09-22 14:22:03 -04:00
|
|
|
'heap.dump.path': [
|
|
|
|
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
|
|
|
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
|
|
|
'def': "#-XX:HeapDumpPath=/heap/dump/path"
|
|
|
|
],
|
|
|
|
|
2015-11-05 15:47:54 -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
|
|
|
|
],
|
|
|
|
]
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result[key] = value
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|