/* * 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.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 import org.elasticsearch.gradle.precommit.DependencyLicensesTask import org.elasticsearch.gradle.precommit.UpdateShasTask import org.elasticsearch.gradle.test.RunTask Collection distributions = project('archives').subprojects + project('packages').subprojects /***************************************************************************** * 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") } /***************************************************************************** * Notice file * *****************************************************************************/ // integ test zip only uses server, so a different notice file is needed there task buildCoreNotice(type: NoticeTask) { licensesDir new File(project(':server').projectDir, 'licenses') } // other distributions include notices from modules as well, which are added below later task buildFullNotice(type: NoticeTask) { licensesDir new File(project(':server').projectDir, 'licenses') } /***************************************************************************** * Modules * *****************************************************************************/ task buildModules(type: Sync) { into 'build/modules' } ext.restTestExpansions = [ 'expected.modules.count': 0, ] // we create the buildModules task above so the distribution subprojects can // 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.parent.path == ':modules' }.each { Project module -> buildFullNotice { def defaultLicensesDir = new File(module.projectDir, 'licenses') if (defaultLicensesDir.exists()) { licensesDir defaultLicensesDir } } buildModules { dependsOn({ project(module.path).bundlePlugin }) into(module.name) { 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) module.afterEvaluate({ module.integTest.mustRunAfter(':distribution:archives:integ-test-zip:integTest') }) restTestExpansions['expected.modules.count'] += 1 } // 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 task buildTransportModules(type: Sync) { into 'build/transport-modules' } 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) } } } } // 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' } 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' // 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 * *****************************************************************************/ libFiles = copySpec { into 'lib' from { project(':server').jar } from { project(':server').configurations.runtime } from { project(':libs:plugin-classloader').jar } // delay add tools using closures, since they have not yet been configured, so no jar task exists yet from { project(':distribution:tools:launchers').jar } from { project(':distribution:tools:plugin-cli').jar } } modulesFiles = copySpec { into 'modules' from project(':distribution').buildModules } transportModulesFiles = copySpec { into "modules" from project(':distribution').buildTransportModules } configFiles = copySpec { from '../../src/main/resources/config' MavenFilteringHack.filter(it, expansions) } binFiles = copySpec { // everything except windows files from '../../src/main/resources/bin' exclude '*.bat' exclude '*.exe' eachFile { it.setMode(0755) } MavenFilteringHack.filter(it, expansions) } commonFiles = copySpec { from rootProject.projectDir include 'LICENSE.txt' include 'README.textile' } noticeFile = copySpec { if (project.name == 'integ-test-zip') { from buildCoreNotice } else { from buildFullNotice } } } /***************************************************************************** * 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) { distribution = 'zip' } /** * Build some variables that are replaced in the packages. This includes both * scripts like bin/elasticsearch and bin/elasticsearch-plugin that a user might run and also * scripts like postinst which are run as part of the installation. * *