Skip to content

Commit fab5e21

Browse files
committed
Build: Split distributions into oss and default
This commit makes x-pack a module and adds it to the default distrubtion. It also creates distributions for zip, tar, deb and rpm which contain only oss code.
1 parent cb56bf4 commit fab5e21

File tree

117 files changed

+820
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+820
-560
lines changed

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,13 @@ subprojects {
206206
"org.elasticsearch.test:framework:${version}": ':test:framework',
207207
"org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:archives:integ-test-zip',
208208
"org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:archives:zip',
209+
"org.elasticsearch.distribution.zip:elasticsearch-oss:${version}": ':distribution:archives:oss-zip',
209210
"org.elasticsearch.distribution.tar:elasticsearch:${version}": ':distribution:archives:tar',
211+
"org.elasticsearch.distribution.tar:elasticsearch-oss:${version}": ':distribution:archives:oss-tar',
210212
"org.elasticsearch.distribution.rpm:elasticsearch:${version}": ':distribution:packages:rpm',
213+
"org.elasticsearch.distribution.rpm:elasticsearch-oss:${version}": ':distribution:packages:oss-rpm',
211214
"org.elasticsearch.distribution.deb:elasticsearch:${version}": ':distribution:packages:deb',
215+
"org.elasticsearch.distribution.deb:elasticsearch-oss:${version}": ':distribution:packages:oss-deb',
212216
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
213217
// for transport client
214218
"org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
@@ -228,6 +232,11 @@ subprojects {
228232
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${snapshot}"] = snapshotProject
229233
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${snapshot}"] = snapshotProject
230234
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${snapshot}"] = snapshotProject
235+
if (snapshot.onOrAfter('6.3.0')) {
236+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch-oss:${snapshot}"] = snapshotProject
237+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch-oss:${snapshot}"] = snapshotProject
238+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch-oss:${snapshot}"] = snapshotProject
239+
}
231240
}
232241
}
233242

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/MetaPluginBuildPlugin.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class MetaPluginBuildPlugin implements Plugin<Project> {
3737
project.plugins.apply(RestTestPlugin)
3838

3939
createBundleTask(project)
40-
boolean isModule = project.path.startsWith(':modules:')
40+
boolean isModule = project.path.startsWith(':modules:') || project.path.startsWith(':x-pack:plugin')
4141

4242
project.integTestCluster {
4343
dependsOn(project.bundlePlugin)
44+
distribution = 'integ-test-zip'
4445
}
4546
BuildPlugin.configurePomGeneration(project)
4647
project.afterEvaluate {
@@ -49,9 +50,9 @@ class MetaPluginBuildPlugin implements Plugin<Project> {
4950
if (project.integTestCluster.distribution == 'integ-test-zip') {
5051
project.integTestCluster.module(project)
5152
}
52-
} else {
53+
} else {
5354
project.integTestCluster.plugin(project.path)
54-
}
55+
}
5556
}
5657

5758
RunTask run = project.tasks.create('run', RunTask)

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class PluginBuildPlugin extends BuildPlugin {
5050
// this afterEvaluate must happen before the afterEvaluate added by integTest creation,
5151
// so that the file name resolution for installing the plugin will be setup
5252
project.afterEvaluate {
53-
boolean isModule = project.path.startsWith(':modules:')
53+
boolean isModule = project.path.startsWith(':modules:') || project.path.startsWith(':x-pack:plugin')
5454
String name = project.pluginProperties.extension.name
5555
project.archivesBaseName = name
5656

@@ -70,6 +70,7 @@ public class PluginBuildPlugin extends BuildPlugin {
7070
if (isModule) {
7171
project.integTestCluster.module(project)
7272
project.tasks.run.clusterConfig.module(project)
73+
project.tasks.run.clusterConfig.distribution = 'integ-test-zip'
7374
} else {
7475
project.integTestCluster.plugin(project.path)
7576
project.tasks.run.clusterConfig.plugin(project.path)

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,22 @@ class ClusterFormationTasks {
131131

132132
/** Adds a dependency on the given distribution */
133133
static void configureDistributionDependency(Project project, String distro, Configuration configuration, Version elasticsearchVersion) {
134+
if (elasticsearchVersion.before('6.3.0') && distro.startsWith('oss-')) {
135+
distro = distro.substring('oss-'.length())
136+
}
134137
String packaging = distro
135-
if (distro == 'tar') {
136-
packaging = 'tar.gz'
137-
} else if (distro == 'integ-test-zip') {
138+
if (distro.contains('tar')) {
139+
packaging = 'tar.gz'\
140+
} else if (distro.contains('zip')) {
138141
packaging = 'zip'
139142
}
140-
project.dependencies.add(configuration.name, "org.elasticsearch.distribution.${distro}:elasticsearch:${elasticsearchVersion}@${packaging}")
143+
String subgroup = distro
144+
String artifactName = 'elasticsearch'
145+
if (distro.contains('oss')) {
146+
artifactName += '-oss'
147+
subgroup = distro.substring('oss-'.length())
148+
}
149+
project.dependencies.add(configuration.name, "org.elasticsearch.distribution.${subgroup}:${artifactName}:${elasticsearchVersion}@${packaging}")
141150
}
142151

143152
/** Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */
@@ -260,6 +269,7 @@ class ClusterFormationTasks {
260269
switch (node.config.distribution) {
261270
case 'integ-test-zip':
262271
case 'zip':
272+
case 'oss-zip':
263273
extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
264274
from {
265275
project.zipTree(configuration.singleFile)
@@ -268,6 +278,7 @@ class ClusterFormationTasks {
268278
}
269279
break;
270280
case 'tar':
281+
case 'oss-tar':
271282
extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
272283
from {
273284
project.tarTree(project.resources.gzip(configuration.singleFile))

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ class NodeInfo {
312312
case 'integ-test-zip':
313313
case 'zip':
314314
case 'tar':
315+
case 'oss-zip':
316+
case 'oss-tar':
315317
path = "elasticsearch-${nodeVersion}"
316318
break
317319
case 'rpm':
@@ -328,7 +330,9 @@ class NodeInfo {
328330
switch (distro) {
329331
case 'integ-test-zip':
330332
case 'zip':
333+
case 'oss-zip':
331334
case 'tar':
335+
case 'oss-tar':
332336
return new File(homeDir(baseDir, distro, nodeVersion), 'config')
333337
case 'rpm':
334338
case 'deb':

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.elasticsearch.gradle.VersionProperties
2424
import org.gradle.api.DefaultTask
2525
import org.gradle.api.Project
2626
import org.gradle.api.Task
27+
import org.gradle.api.Transformer
2728
import org.gradle.api.execution.TaskExecutionAdapter
2829
import org.gradle.api.internal.tasks.options.Option
2930
import org.gradle.api.provider.Property

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantPropertiesExtension.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.gradle.vagrant
2020

21+
import org.elasticsearch.gradle.Version
2122
import org.gradle.api.tasks.Input
2223

2324
class VagrantPropertiesExtension {
@@ -26,7 +27,7 @@ class VagrantPropertiesExtension {
2627
List<String> boxes
2728

2829
@Input
29-
String upgradeFromVersion
30+
Version upgradeFromVersion
3031

3132
@Input
3233
List<String> upgradeFromVersions

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.elasticsearch.gradle.vagrant
33
import org.apache.tools.ant.taskdefs.condition.Os
44
import org.elasticsearch.gradle.FileContentsTask
55
import org.elasticsearch.gradle.LoggedExec
6+
import org.elasticsearch.gradle.Version
67
import org.gradle.api.*
78
import org.gradle.api.artifacts.dsl.RepositoryHandler
89
import org.gradle.api.execution.TaskExecutionAdapter
@@ -37,7 +38,7 @@ class VagrantTestPlugin implements Plugin<Project> {
3738
]
3839

3940
/** All onboarded archives by default, available for Bats tests even if not used **/
40-
static List<String> DISTRIBUTION_ARCHIVES = ['tar', 'rpm', 'deb']
41+
static List<String> DISTRIBUTION_ARCHIVES = ['tar', 'rpm', 'deb', 'oss-rpm', 'oss-deb']
4142

4243
/** Packages onboarded for upgrade tests **/
4344
static List<String> UPGRADE_FROM_ARCHIVES = ['rpm', 'deb']
@@ -105,12 +106,15 @@ class VagrantTestPlugin implements Plugin<Project> {
105106
private static void createPackagingConfiguration(Project project) {
106107
project.configurations.create(PACKAGING_CONFIGURATION)
107108

108-
String upgradeFromVersion = System.getProperty("tests.packaging.upgradeVersion")
109-
if (upgradeFromVersion == null) {
109+
String upgradeFromVersionRaw = System.getProperty("tests.packaging.upgradeVersion");
110+
Version upgradeFromVersion
111+
if (upgradeFromVersionRaw == null) {
110112
String firstPartOfSeed = project.rootProject.testSeed.tokenize(':').get(0)
111113
final long seed = Long.parseUnsignedLong(firstPartOfSeed, 16)
112114
final def indexCompatVersions = project.bwcVersions.indexCompatible
113115
upgradeFromVersion = indexCompatVersions[new Random(seed).nextInt(indexCompatVersions.size())]
116+
} else {
117+
upgradeFromVersion = Version.fromString(upgradeFromVersionRaw)
114118
}
115119

116120
DISTRIBUTION_ARCHIVES.each {
@@ -128,6 +132,10 @@ class VagrantTestPlugin implements Plugin<Project> {
128132
// The version of elasticsearch that we upgrade *from*
129133
project.dependencies.add(PACKAGING_CONFIGURATION,
130134
"org.elasticsearch.distribution.${it}:elasticsearch:${upgradeFromVersion}@${it}")
135+
if (upgradeFromVersion.onOrAfter('6.3.0')) {
136+
project.dependencies.add(PACKAGING_CONFIGURATION,
137+
"org.elasticsearch.distribution.${it}:elasticsearch-oss:${upgradeFromVersion}@${it}")
138+
}
131139
}
132140

133141
project.extensions.esvagrant.upgradeFromVersion = upgradeFromVersion
@@ -173,7 +181,17 @@ class VagrantTestPlugin implements Plugin<Project> {
173181
Task createUpgradeFromFile = project.tasks.create('createUpgradeFromFile', FileContentsTask) {
174182
dependsOn copyPackagingArchives
175183
file "${archivesDir}/upgrade_from_version"
176-
contents project.extensions.esvagrant.upgradeFromVersion
184+
contents project.extensions.esvagrant.upgradeFromVersion.toString()
185+
}
186+
187+
Task createUpgradeIsOssFile = project.tasks.create('createUpgradeIsOssFile', FileContentsTask) {
188+
dependsOn copyPackagingArchives
189+
doFirst {
190+
project.delete("${archivesDir}/upgrade_is_oss")
191+
}
192+
onlyIf { project.extensions.esvagrant.upgradeFromVersion.onOrAfter('6.3.0') }
193+
file "${archivesDir}/upgrade_is_oss"
194+
contents ''
177195
}
178196

179197
File batsDir = new File(packagingDir, BATS)
@@ -214,7 +232,7 @@ class VagrantTestPlugin implements Plugin<Project> {
214232

215233
Task vagrantSetUpTask = project.tasks.create('setupPackagingTest')
216234
vagrantSetUpTask.dependsOn 'vagrantCheckVersion'
217-
vagrantSetUpTask.dependsOn copyPackagingArchives, createVersionFile, createUpgradeFromFile
235+
vagrantSetUpTask.dependsOn copyPackagingArchives, createVersionFile, createUpgradeFromFile, createUpgradeIsOssFile
218236
vagrantSetUpTask.dependsOn copyBatsTests, copyBatsUtils
219237
}
220238

distribution/archives/build.gradle

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ task createPluginsDir(type: EmptyDirTask) {
4242
dirMode 0755
4343
}
4444

45-
CopySpec archiveFiles(CopySpec... innerFiles) {
45+
CopySpec archiveFiles(CopySpec modulesFiles) {
4646
return copySpec {
4747
into("elasticsearch-${version}") {
4848
with libFiles
4949
into('config') {
5050
dirMode 0750
5151
fileMode 0660
52-
with configFiles('def')
52+
with configFiles('def', false)
5353
}
5454
into('bin') {
55+
with binFiles('def', oss)
5556
with copySpec {
56-
with binFiles('def')
5757
from('../src/bin') {
5858
include '*.bat'
5959
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
@@ -78,36 +78,48 @@ CopySpec archiveFiles(CopySpec... innerFiles) {
7878
from('../src') {
7979
include 'bin/*.exe'
8080
}
81-
for (CopySpec files : innerFiles) {
82-
with files
81+
into('modules') {
82+
with modulesFiles
8383
}
8484
}
8585
}
8686
}
8787

88-
task buildIntegTestZip(type: Zip) {
88+
// common config across all zip/tar
89+
tasks.withType(AbstractArchiveTask) {
8990
dependsOn createLogsDir, createPluginsDir
90-
destinationDir = file('integ-test-zip/build/distributions')
91-
baseName = 'elasticsearch'
91+
String subdir = it.name.substring('build'.size()).replaceAll(/[A-Z]/) { '-' + it.toLowerCase() }.substring(1)
92+
destinationDir = file("${subdir}/build/distributions")
93+
baseName = "elasticsearch${ subdir.contains('oss') ? '-oss' : ''}"
94+
}
95+
96+
task buildIntegTestZip(type: Zip) {
9297
with archiveFiles(transportModulesFiles)
9398
}
9499

95100
task buildZip(type: Zip) {
96-
dependsOn createLogsDir, createPluginsDir
97-
destinationDir = file('zip/build/distributions')
98-
baseName = 'elasticsearch'
99-
with archiveFiles(modulesFiles)
101+
with archiveFiles(modulesFiles(false))
100102
}
101103

102-
task buildTar(type: Tar) {
103-
dependsOn createLogsDir, createPluginsDir
104-
destinationDir = file('tar/build/distributions')
105-
baseName = 'elasticsearch'
104+
task buildOssZip(type: Zip) {
105+
with archiveFiles(modulesFiles(true))
106+
}
107+
108+
Closure commonTarConfig = {
106109
extension = 'tar.gz'
107110
compression = Compression.GZIP
108111
dirMode 0755
109112
fileMode 0644
110-
with archiveFiles(modulesFiles)
113+
}
114+
115+
task buildTar(type: Tar) {
116+
configure(commonTarConfig)
117+
with archiveFiles(modulesFiles(false))
118+
}
119+
120+
task buildOssTar(type: Tar) {
121+
configure(commonTarConfig)
122+
with archiveFiles(modulesFiles(true))
111123
}
112124

113125
// This configures the default artifact for the distribution specific
@@ -119,8 +131,6 @@ task buildTar(type: Tar) {
119131
subprojects {
120132
apply plugin: 'distribution'
121133

122-
archivesBaseName = 'elasticsearch'
123-
124134
String buildTask = "build${it.name.replaceAll(/-[a-z]/) { it.substring(1).toUpperCase() }.capitalize()}"
125135
ext.buildDist = parent.tasks.getByName(buildTask)
126136
artifacts {
@@ -158,7 +168,7 @@ configure(subprojects.findAll { it.name == 'integ-test-zip' }) {
158168
apply plugin: 'elasticsearch.rest-test'
159169

160170
integTest {
161-
includePackaged true
171+
includePackaged = true
162172
}
163173

164174
integTestCluster {
@@ -190,12 +200,16 @@ configure(subprojects.findAll { it.name.contains('zip') }) {
190200

191201
// note: the group must be correct before applying the nexus plugin, or
192202
// it will capture the wrong value...
193-
project.group = "org.elasticsearch.distribution.${project.name}"
203+
String subgroup = project.name == 'integ-test-zip' ? 'integ-test-zip' : 'zip'
204+
project.group = "org.elasticsearch.distribution.${subgroup}"
205+
206+
// make the pom file name use elasticsearch instead of the project name
207+
archivesBaseName = "elasticsearch${it.name.contains('oss') ? '-oss' : ''}"
194208

195209
publishing {
196210
publications {
197211
nebula {
198-
artifactId 'elasticsearch'
212+
artifactId archivesBaseName
199213
artifact buildDist
200214
}
201215
/*
@@ -215,7 +229,7 @@ configure(subprojects.findAll { it.name.contains('zip') }) {
215229
* local work, since we publish to maven central externally.
216230
*/
217231
nebulaRealPom(MavenPublication) {
218-
artifactId 'elasticsearch'
232+
artifactId archivesBaseName
219233
pom.packaging = 'pom'
220234
pom.withXml { XmlProvider xml ->
221235
Node root = xml.asNode()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is intentionally blank. All configuration of the
2+
// distribution is done in the parent project.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is intentionally blank. All configuration of the
2+
// distribution is done in the parent project.

0 commit comments

Comments
 (0)