Build: Consolidate archives and packages configuration (#28760)
This commit moves the distribution specific tasks into the respective archives and packages builds. The collocation of common and distribution specific tasks make it much easier to reason about what is expected in a particular distribution.
This commit is contained in:
parent
3dfb4b8b18
commit
014e90d903
|
@ -119,7 +119,7 @@ class VagrantTestPlugin implements Plugin<Project> {
|
|||
} else {
|
||||
it = "packages:${it}"
|
||||
}
|
||||
project.dependencies.add(BATS, project.dependencies.project(path: ":distribution:${it}", configuration: 'archives'))
|
||||
project.dependencies.add(BATS, project.dependencies.project(path: ":distribution:${it}", configuration: 'default'))
|
||||
}
|
||||
|
||||
UPGRADE_FROM_ARCHIVES.each {
|
||||
|
|
|
@ -17,70 +17,195 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.EmptyDirTask
|
||||
import org.elasticsearch.gradle.ConcatFilesTask
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.NoticeTask
|
||||
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
||||
import org.elasticsearch.gradle.precommit.UpdateShasTask
|
||||
import org.elasticsearch.gradle.test.RunTask
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
|
||||
subprojects {
|
||||
// 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
|
||||
File logs = new File(buildDir, 'logs-hack/logs')
|
||||
task createLogDir(type: EmptyDirTask) {
|
||||
dir "${logs}"
|
||||
dirMode 0755
|
||||
}
|
||||
File plugins = new File(buildDir, 'plugins-hack/plugins')
|
||||
task createPluginsDir(type: EmptyDirTask) {
|
||||
dir "${plugins}"
|
||||
dirMode 0755
|
||||
}
|
||||
project.ext.archivesFiles = copySpec {
|
||||
// need this so Zip/Tar tasks get basic defaults...
|
||||
apply plugin: 'base'
|
||||
|
||||
// CopySpec does not make it easy to create an empty directory so we
|
||||
// create the directory that we want, and then point CopySpec to its
|
||||
// parent to copy to the root of the distribution
|
||||
ext.logsDir = new File(buildDir, 'logs-hack/logs')
|
||||
task createLogsDir(type: EmptyDirTask) {
|
||||
dir "${logsDir}"
|
||||
dirMode 0755
|
||||
}
|
||||
ext.pluginsDir= new File(buildDir, 'plugins-hack/plugins')
|
||||
task createPluginsDir(type: EmptyDirTask) {
|
||||
dir "${pluginsDir}"
|
||||
dirMode 0755
|
||||
}
|
||||
|
||||
CopySpec archiveFiles(CopySpec... innerFiles) {
|
||||
return copySpec {
|
||||
into("elasticsearch-${version}") {
|
||||
with libFiles
|
||||
into('config') {
|
||||
dirMode 0750
|
||||
fileMode 0660
|
||||
with configFiles
|
||||
with configFiles('def')
|
||||
}
|
||||
into('bin') {
|
||||
with copySpec {
|
||||
with binFiles
|
||||
from('../../src/main/resources/bin') {
|
||||
with binFiles('def')
|
||||
from('../src/bin') {
|
||||
include '*.bat'
|
||||
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
|
||||
}
|
||||
MavenFilteringHack.filter(it, expansions)
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution('def'))
|
||||
}
|
||||
}
|
||||
into('') {
|
||||
from {
|
||||
dirMode 0755
|
||||
logs.getParent()
|
||||
logsDir.getParent()
|
||||
}
|
||||
}
|
||||
into('') {
|
||||
from {
|
||||
dirMode 0755
|
||||
plugins.getParent()
|
||||
pluginsDir.getParent()
|
||||
}
|
||||
}
|
||||
with commonFiles
|
||||
with noticeFile
|
||||
from('../../src/main/resources') {
|
||||
from('../src') {
|
||||
include 'bin/*.exe'
|
||||
}
|
||||
if (project.name != 'integ-test-zip') {
|
||||
with modulesFiles
|
||||
} else {
|
||||
with transportModulesFiles
|
||||
for (CopySpec files : innerFiles) {
|
||||
with files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task buildIntegTestZip(type: Zip) {
|
||||
dependsOn createLogsDir, createPluginsDir
|
||||
destinationDir = file('integ-test-zip/build/distributions')
|
||||
baseName = 'elasticsearch'
|
||||
with archiveFiles(transportModulesFiles)
|
||||
}
|
||||
|
||||
task buildZip(type: Zip) {
|
||||
dependsOn createLogsDir, createPluginsDir
|
||||
destinationDir = file('zip/build/distributions')
|
||||
baseName = 'elasticsearch'
|
||||
with archiveFiles(modulesFiles)
|
||||
}
|
||||
|
||||
task buildTar(type: Tar) {
|
||||
dependsOn createLogsDir, createPluginsDir
|
||||
destinationDir = file('tar/build/distributions')
|
||||
baseName = 'elasticsearch'
|
||||
extension = 'tar.gz'
|
||||
compression = Compression.GZIP
|
||||
dirMode 0755
|
||||
fileMode 0644
|
||||
with archiveFiles(modulesFiles)
|
||||
}
|
||||
|
||||
// This configures the default artifact for the distribution specific
|
||||
// subprojects. We have subprojects for two reasons:
|
||||
// 1. Gradle project substitutions can only bind to the default
|
||||
// configuration of a project
|
||||
// 2. The integ-test-zip and zip distributions have the exact same
|
||||
// filename, so they must be placed in different directories.
|
||||
subprojects {
|
||||
apply plugin: 'distribution'
|
||||
|
||||
archivesBaseName = 'elasticsearch'
|
||||
|
||||
String buildTask = "build${it.name.replaceAll(/-[a-z]/) { it.substring(1).toUpperCase() }.capitalize()}"
|
||||
ext.buildDist = parent.tasks.getByName(buildTask)
|
||||
artifacts {
|
||||
'default' buildDist
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Rest test config *
|
||||
*****************************************************************************/
|
||||
subprojects {
|
||||
apply plugin: 'elasticsearch.standalone-rest-test'
|
||||
apply plugin: 'elasticsearch.rest-test'
|
||||
|
||||
if (project.name == 'integ-test-zip') {
|
||||
integTest {
|
||||
includePackaged true
|
||||
}
|
||||
}
|
||||
|
||||
integTestCluster {
|
||||
dependsOn assemble
|
||||
distribution = project.name
|
||||
}
|
||||
integTestRunner {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getProperty('tests.timeoutSuite') == null) {
|
||||
// override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man
|
||||
systemProperty 'tests.timeoutSuite', '1800000!'
|
||||
}
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
inputs.properties(project(':distribution').restTestExpansions)
|
||||
MavenFilteringHack.filter(it, project(':distribution').restTestExpansions)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Maven config *
|
||||
*****************************************************************************/
|
||||
configure(subprojects.findAll { it.name.contains('zip') }) {
|
||||
// only zip distributions go to maven
|
||||
BuildPlugin.configurePomGeneration(project)
|
||||
apply plugin: 'nebula.info-scm'
|
||||
apply plugin: 'nebula.maven-base-publish'
|
||||
apply plugin: 'nebula.maven-scm'
|
||||
|
||||
// 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}"
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
nebula {
|
||||
artifactId 'elasticsearch'
|
||||
artifact buildDist
|
||||
}
|
||||
/*
|
||||
* HUGE HACK: the underlying maven publication library refuses to
|
||||
* deploy any attached artifacts when the packaging type is set to
|
||||
* 'pom'. But Sonatype's OSS repositories require source files for
|
||||
* artifacts that are of type 'zip'. We already publish the source
|
||||
* and javadoc for Elasticsearch under the various other subprojects.
|
||||
* So here we create another publication using the same name that
|
||||
* has the "real" pom, and rely on the fact that gradle will execute
|
||||
* the publish tasks in alphabetical order. This lets us publish the
|
||||
* zip file and even though the pom says the type is 'pom' instead of
|
||||
* 'zip'. We cannot setup a dependency between the tasks because the
|
||||
* publishing tasks are created *extremely* late in the configuration
|
||||
* phase, so that we cannot get ahold of the actual task. Furthermore,
|
||||
* this entire hack only exists so we can make publishing to maven
|
||||
* local work, since we publish to maven central externally.
|
||||
*/
|
||||
nebulaRealPom(MavenPublication) {
|
||||
artifactId 'elasticsearch'
|
||||
pom.packaging = 'pom'
|
||||
pom.withXml { XmlProvider xml ->
|
||||
Node root = xml.asNode()
|
||||
root.appendNode('name', 'Elasticsearch')
|
||||
root.appendNode('description', 'A Distributed RESTful Search Engine')
|
||||
root.appendNode('url', PluginBuildPlugin.urlFromOrigin(project.scminfo.origin))
|
||||
Node scmNode = root.appendNode('scm')
|
||||
scmNode.appendNode('url', project.scminfo.origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,72 +1,2 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
task buildZip(type: Zip) {
|
||||
dependsOn createLogDir, createPluginsDir
|
||||
baseName = 'elasticsearch'
|
||||
with archivesFiles
|
||||
}
|
||||
|
||||
artifacts {
|
||||
'default' buildZip
|
||||
archives buildZip
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
nebula {
|
||||
artifactId 'elasticsearch'
|
||||
artifact buildZip
|
||||
}
|
||||
/* HUGE HACK: the underlying maven publication library refuses to deploy any attached artifacts
|
||||
* when the packaging type is set to 'pom'. But Sonatype's OSS repositories require source files
|
||||
* for artifacts that are of type 'zip'. We already publish the source and javadoc for Elasticsearch
|
||||
* under the various other subprojects. So here we create another publication using the same
|
||||
* name that has the "real" pom, and rely on the fact that gradle will execute the publish tasks
|
||||
* in alphabetical order. This lets us publish the zip file and even though the pom says the
|
||||
* type is 'pom' instead of 'zip'. We cannot setup a dependency between the tasks because the
|
||||
* publishing tasks are created *extremely* late in the configuration phase, so that we cannot get
|
||||
* ahold of the actual task. Furthermore, this entire hack only exists so we can make publishing to
|
||||
* maven local work, since we publish to maven central externally. */
|
||||
nebulaRealPom(MavenPublication) {
|
||||
artifactId 'elasticsearch'
|
||||
pom.packaging = 'pom'
|
||||
pom.withXml { XmlProvider xml ->
|
||||
Node root = xml.asNode()
|
||||
root.appendNode('name', 'Elasticsearch')
|
||||
root.appendNode('description', 'A Distributed RESTful Search Engine')
|
||||
root.appendNode('url', PluginBuildPlugin.urlFromOrigin(project.scminfo.origin))
|
||||
Node scmNode = root.appendNode('scm')
|
||||
scmNode.appendNode('url', project.scminfo.origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
integTestRunner {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getProperty('tests.timeoutSuite') == null) {
|
||||
// override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man
|
||||
systemProperty 'tests.timeoutSuite', '1800000!'
|
||||
}
|
||||
}
|
||||
|
||||
integTest.dependsOn buildZip
|
||||
// This file is intentionally blank. All configuration of the
|
||||
// distribution is done in the parent project.
|
||||
|
|
|
@ -1,33 +1,2 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
task buildTar(type: Tar) {
|
||||
dependsOn createLogDir, createPluginsDir
|
||||
baseName = 'elasticsearch'
|
||||
extension = 'tar.gz'
|
||||
with archivesFiles
|
||||
compression = Compression.GZIP
|
||||
dirMode 0755
|
||||
fileMode 0644
|
||||
}
|
||||
|
||||
artifacts {
|
||||
'default' buildTar
|
||||
}
|
||||
|
||||
// This file is intentionally blank. All configuration of the
|
||||
// distribution is done in the parent project.
|
||||
|
|
|
@ -1,64 +1,2 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
|
||||
task buildZip(type: Zip) {
|
||||
dependsOn createLogDir, createPluginsDir
|
||||
baseName = 'elasticsearch'
|
||||
with archivesFiles
|
||||
}
|
||||
|
||||
artifacts {
|
||||
'default' buildZip
|
||||
archives buildZip
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
nebula {
|
||||
artifactId 'elasticsearch'
|
||||
artifact buildZip
|
||||
}
|
||||
/* HUGE HACK: the underlying maven publication library refuses to deploy any attached artifacts
|
||||
* when the packaging type is set to 'pom'. But Sonatype's OSS repositories require source files
|
||||
* for artifacts that are of type 'zip'. We already publish the source and javadoc for Elasticsearch
|
||||
* under the various other subprojects. So here we create another publication using the same
|
||||
* name that has the "real" pom, and rely on the fact that gradle will execute the publish tasks
|
||||
* in alphabetical order. This lets us publish the zip file and even though the pom says the
|
||||
* type is 'pom' instead of 'zip'. We cannot setup a dependency between the tasks because the
|
||||
* publishing tasks are created *extremely* late in the configuration phase, so that we cannot get
|
||||
* ahold of the actual task. Furthermore, this entire hack only exists so we can make publishing to
|
||||
* maven local work, since we publish to maven central externally. */
|
||||
nebulaRealPom(MavenPublication) {
|
||||
artifactId 'elasticsearch'
|
||||
pom.packaging = 'pom'
|
||||
pom.withXml { XmlProvider xml ->
|
||||
Node root = xml.asNode()
|
||||
root.appendNode('name', 'Elasticsearch')
|
||||
root.appendNode('description', 'A Distributed RESTful Search Engine')
|
||||
root.appendNode('url', PluginBuildPlugin.urlFromOrigin(project.scminfo.origin))
|
||||
Node scmNode = root.appendNode('scm')
|
||||
scmNode.appendNode('url', project.scminfo.origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
integTest.dependsOn buildZip
|
||||
// This file is intentionally blank. All configuration of the
|
||||
// distribution is done in the parent project.
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.EmptyDirTask
|
||||
import org.elasticsearch.gradle.ConcatFilesTask
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.NoticeTask
|
||||
|
@ -83,15 +82,7 @@ project.rootProject.subprojects.findAll { it.parent.path == ':modules' }.each {
|
|||
from { zipTree(project(module.path).bundlePlugin.outputs.files.singleFile) }
|
||||
}
|
||||
}
|
||||
// We would like to make sure integ tests for the distribution run after
|
||||
// integ tests for the modules included in the distribution.
|
||||
project.configure(distributions.findAll { it.name != 'integ-test-zip'}) { Project distribution ->
|
||||
distribution.afterEvaluate({
|
||||
// some integTest tasks will have multiple finalizers
|
||||
distribution.integTest.mustRunAfter module.tasks.find { t -> t.name.matches(".*integTest\$") }
|
||||
})
|
||||
}
|
||||
// also want to make sure the module's integration tests run after the integ-test-zip (ie rest tests)
|
||||
// make sure the module's integration tests run after the integ-test-zip (ie rest tests)
|
||||
module.afterEvaluate({
|
||||
module.integTest.mustRunAfter(':distribution:archives:integ-test-zip:integTest')
|
||||
})
|
||||
|
@ -119,41 +110,12 @@ task clean(type: Delete) {
|
|||
delete 'build'
|
||||
}
|
||||
|
||||
configure(distributions) {
|
||||
/*****************************************************************************
|
||||
* Rest test config *
|
||||
*****************************************************************************/
|
||||
apply plugin: 'elasticsearch.standalone-rest-test'
|
||||
apply plugin: 'elasticsearch.rest-test'
|
||||
project.integTest {
|
||||
includePackaged project.name == 'integ-test-zip'
|
||||
if (project.name != 'integ-test-zip') {
|
||||
mustRunAfter ':distribution:archives:integ-test-zip:integTest'
|
||||
}
|
||||
}
|
||||
project.integTestCluster {
|
||||
dependsOn project.assemble
|
||||
distribution = project.name
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
inputs.properties(project(':distribution').restTestExpansions)
|
||||
MavenFilteringHack.filter(it, project(':distribution').restTestExpansions)
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* 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}"
|
||||
project.archivesBaseName = 'elasticsearch'
|
||||
|
||||
configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
||||
// 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 {
|
||||
expansions = expansionsForDistribution(project.name)
|
||||
|
||||
/*****************************************************************************
|
||||
* Common files in all distributions *
|
||||
|
@ -178,18 +140,22 @@ configure(distributions) {
|
|||
from project(':distribution').buildTransportModules
|
||||
}
|
||||
|
||||
configFiles = copySpec {
|
||||
from '../../src/main/resources/config'
|
||||
MavenFilteringHack.filter(it, expansions)
|
||||
configFiles = { distributionType ->
|
||||
copySpec {
|
||||
from '../src/config'
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType))
|
||||
}
|
||||
}
|
||||
|
||||
binFiles = copySpec {
|
||||
// everything except windows files
|
||||
from '../../src/main/resources/bin'
|
||||
exclude '*.bat'
|
||||
exclude '*.exe'
|
||||
eachFile { it.setMode(0755) }
|
||||
MavenFilteringHack.filter(it, expansions)
|
||||
binFiles = { distributionType ->
|
||||
copySpec {
|
||||
// everything except windows files
|
||||
from '../src/bin'
|
||||
exclude '*.bat'
|
||||
exclude '*.exe'
|
||||
eachFile { it.setMode(0755) }
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType))
|
||||
}
|
||||
}
|
||||
|
||||
commonFiles = copySpec {
|
||||
|
@ -207,15 +173,6 @@ configure(distributions) {
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Publishing setup *
|
||||
*****************************************************************************/
|
||||
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'
|
||||
}
|
||||
}
|
||||
|
||||
task run(type: RunTask) {
|
||||
|
@ -252,83 +209,84 @@ task run(type: RunTask) {
|
|||
* day. DEB retries forever.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
Map<String, String> expansionsForDistribution(distributionType) {
|
||||
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"
|
||||
subprojects {
|
||||
ext.expansionsForDistribution = { distributionType ->
|
||||
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"
|
||||
|
||||
String footer = "# Built for ${project.name}-${project.version} " +
|
||||
"(${distributionType})"
|
||||
Map<String, Object> expansions = [
|
||||
'project.name': project.name,
|
||||
'project.version': version,
|
||||
String footer = "# Built for ${project.name}-${project.version} " +
|
||||
"(${distributionType})"
|
||||
Map<String, Object> expansions = [
|
||||
'project.name': project.name,
|
||||
'project.version': version,
|
||||
|
||||
'path.conf': [
|
||||
'tar': '"$ES_HOME"/config',
|
||||
'zip': '"$ES_HOME"/config',
|
||||
'integ-test-zip': '"$ES_HOME"/config',
|
||||
'def': '/etc/elasticsearch',
|
||||
],
|
||||
'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': [
|
||||
'deb': 'source /etc/default/elasticsearch',
|
||||
'rpm': 'source /etc/sysconfig/elasticsearch',
|
||||
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
|
||||
],
|
||||
'path.logs': [
|
||||
'deb': packagingPathLogs,
|
||||
'rpm': packagingPathLogs,
|
||||
'def': '#path.logs: /path/to/logs'
|
||||
],
|
||||
'loggc': [
|
||||
'deb': packagingLoggc,
|
||||
'rpm': packagingLoggc,
|
||||
'def': 'logs/gc.log'
|
||||
],
|
||||
'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': [
|
||||
'deb': 'source /etc/default/elasticsearch',
|
||||
'rpm': 'source /etc/sysconfig/elasticsearch',
|
||||
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
|
||||
],
|
||||
'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.min': defaultHeapSize,
|
||||
'heap.max': defaultHeapSize,
|
||||
|
||||
'heap.dump.path': [
|
||||
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
||||
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
||||
'def': "#-XX:HeapDumpPath=/heap/dump/path"
|
||||
],
|
||||
'heap.dump.path': [
|
||||
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
||||
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
|
||||
'def': "#-XX:HeapDumpPath=/heap/dump/path"
|
||||
],
|
||||
|
||||
'stopping.timeout': [
|
||||
'rpm': 86400,
|
||||
],
|
||||
'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
|
||||
'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
|
||||
}
|
||||
result[key] = value
|
||||
return result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -13,27 +13,17 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.EmptyDirTask
|
||||
import org.elasticsearch.gradle.ConcatFilesTask
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.NoticeTask
|
||||
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
||||
import org.elasticsearch.gradle.precommit.UpdateShasTask
|
||||
import org.elasticsearch.gradle.test.RunTask
|
||||
|
||||
/*****************************************************************************
|
||||
* Deb and rpm configuration *
|
||||
*****************************************************************************
|
||||
*
|
||||
* 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
|
||||
* The general strategy here is to build a directory on disk 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
|
||||
|
@ -53,7 +43,6 @@ import org.elasticsearch.gradle.test.RunTask
|
|||
* dpkg -c path/to/elasticsearch.deb
|
||||
*/
|
||||
|
||||
// for deb/rpm
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -61,140 +50,94 @@ buildscript {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.netflix.nebula:gradle-ospackage-plugin:3.4.0'
|
||||
classpath 'com.netflix.nebula:gradle-ospackage-plugin:4.7.1'
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
// TODO: remove integ test for packages
|
||||
integTest.enabled = Os.isFamily(Os.FAMILY_WINDOWS) == false
|
||||
File packagingFiles = new File(buildDir, 'packaging')
|
||||
project.ext.packagingFiles = packagingFiles
|
||||
task processPackagingFiles(type: Copy) {
|
||||
from '../../src/main/packaging'
|
||||
from 'src/main/packaging'
|
||||
void addProcessFilesTask(String type) {
|
||||
String packagingFiles = "build/packaging/${type}"
|
||||
|
||||
MavenFilteringHack.filter(it, expansions)
|
||||
task("process${type.capitalize()}Files", type: Copy) {
|
||||
from 'src/common'
|
||||
from "src/${type}"
|
||||
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
|
||||
outputs.dir dir
|
||||
}
|
||||
|
||||
task fillEtc(type: Copy) {
|
||||
dependsOn createEtc
|
||||
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"
|
||||
outputs.file "${packagingFiles}/etc/elasticsearch/jvm.options"
|
||||
outputs.file "${packagingFiles}/etc/elasticsearch/log4j2.properties"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
apply plugin: 'nebula.ospackage-base'
|
||||
ospackage {
|
||||
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/'
|
||||
|
||||
// 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')
|
||||
into('config') {
|
||||
from '../src/config'
|
||||
}
|
||||
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(type))
|
||||
|
||||
doLast {
|
||||
// create empty dirs, we set the permissions when configuring the packages
|
||||
mkdir "${packagingFiles}/var/run/elasticsearch"
|
||||
mkdir "${packagingFiles}/var/log/elasticsearch"
|
||||
mkdir "${packagingFiles}/var/lib/elasticsearch"
|
||||
mkdir "${packagingFiles}/usr/share/elasticsearch/plugins"
|
||||
}
|
||||
}
|
||||
}
|
||||
addProcessFilesTask('deb')
|
||||
addProcessFilesTask('rpm')
|
||||
|
||||
// Common configuration that is package dependent. This can't go in ospackage
|
||||
// since we have different templated files that need to be consumed, but the structure
|
||||
// is the same
|
||||
Closure commonPackageConfig(String type) {
|
||||
return {
|
||||
// Follow elasticsearch's file naming convention
|
||||
archiveName "elasticsearch-${project.version}.${type}"
|
||||
|
||||
destinationDir = file("${type}/build/distributions")
|
||||
String packagingFiles = "build/packaging/${type}"
|
||||
|
||||
String scripts = "${packagingFiles}/scripts"
|
||||
preInstall file("${scripts}/preinst")
|
||||
postInstall file("${scripts}/postinst")
|
||||
preUninstall file("${scripts}/prerm")
|
||||
postUninstall file("${scripts}/postrm")
|
||||
|
||||
if (project.name == 'rpm') {
|
||||
requires('/bin/bash')
|
||||
} else if (project.name == 'deb') {
|
||||
requires('bash')
|
||||
}
|
||||
requires('coreutils')
|
||||
|
||||
into '/usr/share/elasticsearch'
|
||||
fileMode 0644
|
||||
dirMode 0755
|
||||
user 'root'
|
||||
permissionGroup 'root'
|
||||
with libFiles
|
||||
with modulesFiles
|
||||
into('bin') {
|
||||
with binFiles
|
||||
}
|
||||
with copySpec {
|
||||
with commonFiles
|
||||
if (project.name == 'deb') {
|
||||
// Deb gets a copyright file instead.
|
||||
exclude 'LICENSE.txt'
|
||||
// top level "into" directive is not inherited from ospackage for some reason, so we must
|
||||
// specify it again explicitly for copying common files
|
||||
into('/usr/share/elasticsearch') {
|
||||
into('bin') {
|
||||
with binFiles(type)
|
||||
}
|
||||
with copySpec {
|
||||
with commonFiles
|
||||
if (type == 'deb') {
|
||||
// Deb gets a copyright file instead.
|
||||
exclude 'LICENSE.txt'
|
||||
}
|
||||
}
|
||||
}
|
||||
with noticeFile
|
||||
|
||||
// ========= config files =========
|
||||
configurationFile '/etc/elasticsearch/elasticsearch.yml'
|
||||
configurationFile '/etc/elasticsearch/jvm.options'
|
||||
configurationFile '/etc/elasticsearch/log4j2.properties'
|
||||
into('/etc/elasticsearch') {
|
||||
dirMode 0750
|
||||
//dirMode 0750
|
||||
fileMode 0660
|
||||
permissionGroup 'elasticsearch'
|
||||
includeEmptyDirs true
|
||||
createDirectoryEntry true
|
||||
fileType CONFIG | NOREPLACE
|
||||
from "${packagingFiles}/etc/elasticsearch"
|
||||
from "${packagingFiles}/config"
|
||||
}
|
||||
String envFile = expansionsForDistribution(type)['path.env']
|
||||
configurationFile envFile
|
||||
into(new File(envFile).getParent()) {
|
||||
fileType CONFIG | NOREPLACE
|
||||
fileMode 0660
|
||||
from "${packagingFiles}/env/elasticsearch"
|
||||
}
|
||||
|
||||
// ========= systemd =========
|
||||
configurationFile '/usr/lib/systemd/system/elasticsearch.service'
|
||||
into('/usr/lib/tmpfiles.d') {
|
||||
from "${packagingFiles}/systemd/elasticsearch.conf"
|
||||
}
|
||||
configurationFile '/usr/lib/systemd/system/elasticsearch.service'
|
||||
into('/usr/lib/systemd/system') {
|
||||
fileType CONFIG | NOREPLACE
|
||||
from "${packagingFiles}/systemd/elasticsearch.service"
|
||||
|
@ -203,37 +146,171 @@ subprojects {
|
|||
fileType CONFIG | NOREPLACE
|
||||
from "${packagingFiles}/systemd/sysctl/elasticsearch.conf"
|
||||
}
|
||||
|
||||
// ========= sysV init =========
|
||||
configurationFile '/etc/init.d/elasticsearch'
|
||||
into('/etc/init.d') {
|
||||
fileMode 0750
|
||||
fileType CONFIG | NOREPLACE
|
||||
from "${packagingFiles}/init.d/elasticsearch"
|
||||
}
|
||||
configurationFile project.expansions['path.env']
|
||||
into(new File(project.expansions['path.env']).getParent()) {
|
||||
fileType CONFIG | NOREPLACE
|
||||
fileMode 0660
|
||||
from "${project.packagingFiles}/env/elasticsearch"
|
||||
}
|
||||
|
||||
/**
|
||||
* Suck up all the empty directories that we need to install into the path.
|
||||
*/
|
||||
Closure suckUpEmptyDirectories = { path, u, g, mode ->
|
||||
into(path) {
|
||||
// ========= empty dirs =========
|
||||
// NOTE: these are created under packagingFiles as empty, but the permissions are set here
|
||||
Closure copyEmptyDir = { path, u, g, mode ->
|
||||
File file = new File(path)
|
||||
into(file.parent) {
|
||||
from "${packagingFiles}/${path}"
|
||||
include file.name
|
||||
includeEmptyDirs true
|
||||
createDirectoryEntry true
|
||||
user u
|
||||
permissionGroup g
|
||||
dirMode mode
|
||||
fileMode mode
|
||||
}
|
||||
}
|
||||
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)
|
||||
copyEmptyDir('/var/run/elasticsearch', 'elasticsearch', 'elasticsearch', 0755)
|
||||
copyEmptyDir('/var/log/elasticsearch', 'elasticsearch', 'elasticsearch', 0750)
|
||||
copyEmptyDir('/var/lib/elasticsearch', 'elasticsearch', 'elasticsearch', 0750)
|
||||
copyEmptyDir('/usr/share/elasticsearch/plugins', 'root', 'root', 0755)
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'nebula.ospackage-base'
|
||||
|
||||
// this is package indepdendent configuration
|
||||
ospackage {
|
||||
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/'
|
||||
|
||||
// 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')
|
||||
}
|
||||
|
||||
requires('coreutils')
|
||||
|
||||
fileMode 0644
|
||||
dirMode 0755
|
||||
user 'root'
|
||||
permissionGroup 'root'
|
||||
|
||||
into '/usr/share/elasticsearch'
|
||||
with libFiles
|
||||
with modulesFiles
|
||||
with noticeFile
|
||||
}
|
||||
|
||||
task buildDeb(type: Deb) {
|
||||
dependsOn processDebFiles
|
||||
configure(commonPackageConfig('deb'))
|
||||
|
||||
version = project.version
|
||||
packageGroup 'web'
|
||||
requires 'bash'
|
||||
requires 'libc6'
|
||||
requires 'adduser'
|
||||
|
||||
into('/usr/share/lintian/overrides') {
|
||||
from('src/deb/lintian/elasticsearch')
|
||||
}
|
||||
into('/usr/share/doc/elasticsearch') {
|
||||
from 'src/deb/copyright'
|
||||
fileMode 0644
|
||||
}
|
||||
}
|
||||
|
||||
// task that sanity checks if the Deb archive can be extracted
|
||||
task checkDeb(type: LoggedExec) {
|
||||
dependsOn buildDeb
|
||||
onlyIf { new File('/usr/bin/dpkg-deb').exists() || new File('/usr/local/bin/dpkg-deb').exists() }
|
||||
final File debExtracted = new File("${buildDir}", 'deb-extracted')
|
||||
commandLine 'dpkg-deb', '-x', "deb/build/distributions/elasticsearch-${project.version}.deb", debExtracted
|
||||
doFirst {
|
||||
debExtracted.deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
task buildRpm(type: Rpm) {
|
||||
dependsOn processRpmFiles
|
||||
configure(commonPackageConfig('rpm'))
|
||||
|
||||
packageGroup 'Application/Internet'
|
||||
requires '/bin/bash'
|
||||
|
||||
prefix '/usr'
|
||||
packager 'Elasticsearch'
|
||||
version = project.version.replace('-', '_')
|
||||
release = '1'
|
||||
arch 'NOARCH'
|
||||
os 'LINUX'
|
||||
license '2009'
|
||||
distribution 'Elasticsearch'
|
||||
vendor 'Elasticsearch'
|
||||
// TODO ospackage doesn't support icon but we used to have one
|
||||
|
||||
// without this the rpm will have parent dirs of any files we copy in, eg /etc/elasticsearch
|
||||
addParentDirs false
|
||||
|
||||
// Declare the folders so that the RPM package manager removes
|
||||
// them when upgrading or removing the package
|
||||
directory('/usr/share/elasticsearch/bin', 0755)
|
||||
directory('/usr/share/elasticsearch/lib', 0755)
|
||||
directory('/usr/share/elasticsearch/modules', 0755)
|
||||
modulesFiles.eachFile { FileCopyDetails fcp ->
|
||||
if (fcp.name == "plugin-descriptor.properties") {
|
||||
directory('/usr/share/elasticsearch/modules/' + fcp.file.parentFile.name, 0755)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// task that sanity checks if the RPM archive can be extracted
|
||||
task checkRpm(type: LoggedExec) {
|
||||
dependsOn buildRpm
|
||||
onlyIf { new File('/bin/rpm').exists() || new File('/usr/bin/rpm').exists() || new File('/usr/local/bin/rpm').exists() }
|
||||
final File rpmDatabase = new File("${buildDir}", 'rpm-database')
|
||||
final File rpmExtracted = new File("${buildDir}", 'rpm-extracted')
|
||||
commandLine 'rpm',
|
||||
'--badreloc',
|
||||
'--nodeps',
|
||||
'--noscripts',
|
||||
'--notriggers',
|
||||
'--dbpath',
|
||||
rpmDatabase,
|
||||
'--relocate',
|
||||
"/=${rpmExtracted}",
|
||||
'-i',
|
||||
"rpm/build/distributions/elasticsearch-${project.version}.rpm"
|
||||
doFirst {
|
||||
rpmDatabase.deleteDir()
|
||||
rpmExtracted.deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
// This configures the default artifact for the distribution specific
|
||||
// subprojects. We have subprojects because Gradle project substitutions
|
||||
// can only bind to the default configuration of a project
|
||||
subprojects {
|
||||
apply plugin: 'distribution'
|
||||
|
||||
String buildTask = "build${it.name.replaceAll(/-[a-z]/) { it.substring(1).toUpperCase() }.capitalize()}"
|
||||
ext.buildDist = parent.tasks.getByName(buildTask)
|
||||
artifacts {
|
||||
'default' buildDist
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn checkDeb, checkRpm
|
||||
|
||||
|
|
|
@ -1,61 +1,2 @@
|
|||
import org.elasticsearch.gradle.LoggedExec
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
task buildDeb(type: Deb) {
|
||||
dependsOn preparePackagingFiles
|
||||
baseName 'elasticsearch' // this is what pom generation uses for artifactId
|
||||
// Follow elasticsearch's deb file naming convention
|
||||
archiveName "${packageName}-${project.version}.deb"
|
||||
version = project.version
|
||||
|
||||
packageGroup 'web'
|
||||
requires 'libc6'
|
||||
requires 'adduser'
|
||||
|
||||
into('/usr/share/lintian/overrides') {
|
||||
from("${project.packagingFiles}/lintian/elasticsearch")
|
||||
}
|
||||
into('/usr/share/doc/elasticsearch') {
|
||||
from "${project.packagingFiles}/copyright"
|
||||
fileMode 0644
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
'default' buildDeb
|
||||
archives buildDeb
|
||||
}
|
||||
|
||||
integTest.enabled = false
|
||||
licenseHeaders.enabled = false
|
||||
|
||||
// task that sanity checks if the Deb archive can be extracted
|
||||
task checkDeb(type: LoggedExec) {
|
||||
onlyIf { new File('/usr/bin/dpkg-deb').exists() || new File('/usr/local/bin/dpkg-deb').exists() }
|
||||
final File debExtracted = new File("${buildDir}", 'deb-extracted')
|
||||
commandLine 'dpkg-deb', '-x', "${buildDir}/distributions/elasticsearch-${project.version}.deb", debExtracted
|
||||
doFirst {
|
||||
debExtracted.deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
checkDeb.dependsOn buildDeb
|
||||
check.dependsOn checkDeb
|
||||
// This file is intentionally blank. All configuration of the
|
||||
// distribution is done in the parent project.
|
||||
|
|
|
@ -1,85 +1,2 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
|
||||
task buildRpm(type: Rpm) {
|
||||
dependsOn preparePackagingFiles
|
||||
baseName 'elasticsearch' // this is what pom generation uses for artifactId
|
||||
// Follow elasticsearch's rpm file naming convention
|
||||
archiveName "${packageName}-${project.version}.rpm"
|
||||
packageGroup 'Application/Internet'
|
||||
prefix '/usr'
|
||||
packager 'Elasticsearch'
|
||||
version = project.version.replace('-', '_')
|
||||
release = '1'
|
||||
arch 'NOARCH'
|
||||
os 'LINUX'
|
||||
license '2009'
|
||||
distribution 'Elasticsearch'
|
||||
vendor 'Elasticsearch'
|
||||
dirMode 0755
|
||||
fileMode 0644
|
||||
addParentDirs false
|
||||
// TODO ospackage doesn't support icon but we used to have one
|
||||
|
||||
// Declare the folders so that the RPM package manager removes
|
||||
// them when upgrading or removing the package
|
||||
directory('/usr/share/elasticsearch/bin', 0755)
|
||||
directory('/usr/share/elasticsearch/lib', 0755)
|
||||
directory('/usr/share/elasticsearch/modules', 0755)
|
||||
modulesFiles.eachFile { FileCopyDetails fcp ->
|
||||
if (fcp.name == "plugin-descriptor.properties") {
|
||||
directory('/usr/share/elasticsearch/modules/' + fcp.file.parentFile.name, 0755)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
'default' buildRpm
|
||||
archives buildRpm
|
||||
}
|
||||
|
||||
integTest.enabled = false
|
||||
licenseHeaders.enabled = false
|
||||
|
||||
// task that sanity checks if the RPM archive can be extracted
|
||||
task checkRpm(type: LoggedExec) {
|
||||
onlyIf { new File('/bin/rpm').exists() || new File('/usr/bin/rpm').exists() || new File('/usr/local/bin/rpm').exists() }
|
||||
final File rpmDatabase = new File("${buildDir}", 'rpm-database')
|
||||
final File rpmExtracted = new File("${buildDir}", 'rpm-extracted')
|
||||
commandLine 'rpm',
|
||||
'--badreloc',
|
||||
'--nodeps',
|
||||
'--noscripts',
|
||||
'--notriggers',
|
||||
'--dbpath',
|
||||
rpmDatabase,
|
||||
'--relocate',
|
||||
"/=${rpmExtracted}",
|
||||
'-i',
|
||||
"${buildDir}/distributions/elasticsearch-${project.version}.rpm"
|
||||
doFirst {
|
||||
rpmDatabase.deleteDir()
|
||||
rpmExtracted.deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
checkRpm.dependsOn buildRpm
|
||||
check.dependsOn checkRpm
|
||||
// This file is intentionally blank. All configuration of the
|
||||
// distribution is done in the parent project.
|
||||
|
|
Loading…
Reference in New Issue