Skip to content

Commit f0c0f57

Browse files
authored
Build: Remove hardcoded reference to x-plugins in build (#21773)
* Build: Remove hardcoded reference to x-plugins in build The gradle build currenlty allows extra plugins to be hooked into the elasticsearch build by placing under an x-plugins directory as a sibling of the elasticsearch checkout. This change converts this directory to one called elasticsearch-extra. The subdirectories of elasticsearch-extra become first level projects in gradle (while before they would have been subprojects of `:x-plugins`. Additionally, this allows major version checkouts to be associated with extra plugins. For example, you could have elasticsearch checked out as `elasticsearch-5.x`, and a sibling `elasticsearch-5.x-extra` directory.
1 parent 80d6539 commit f0c0f57

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

TESTING.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,10 @@ gradle run --debug-jvm
474474
== Building with extra plugins
475475
Additional plugins may be built alongside elasticsearch, where their
476476
dependency on elasticsearch will be substituted with the local elasticsearch
477-
build. To add your plugin, create a directory called x-plugins as a sibling
478-
of elasticsearch. Checkout your plugin underneath x-plugins and the build
479-
will automatically pick it up. You can verify the plugin is included as part
480-
of the build by checking the projects of the build.
477+
build. To add your plugin, create a directory called elasticsearch-extra as
478+
a sibling of elasticsearch. Checkout your plugin underneath elasticsearch-extra
479+
and the build will automatically pick it up. You can verify the plugin is
480+
included as part of the build by checking the projects of the build.
481481

482482
---------------------------------------------------------------------------
483483
gradle projects

settings.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
rootProject.name = 'elasticsearch'
1+
String dirName = rootProject.projectDir.name
2+
rootProject.name = dirName
23

34
List projects = [
45
'build-tools',
@@ -86,7 +87,7 @@ if (isEclipse) {
8687
/**
8788
* Iterates over sub directories, looking for build.gradle, and adds a project if found
8889
* for that dir with the given path prefix. Note that this requires each level
89-
* of the dir hiearchy to have a build.gradle. Otherwise we would have to iterate
90+
* of the dir hierarchy to have a build.gradle. Otherwise we would have to iterate
9091
* all files/directories in the source tree to find all projects.
9192
*/
9293
void addSubProjects(String path, File dir) {
@@ -96,17 +97,18 @@ void addSubProjects(String path, File dir) {
9697

9798
String projectName = "${path}:${dir.name}"
9899
include projectName
100+
if (path.isEmpty()) {
101+
project(projectName).projectDir = dir
102+
}
99103
for (File subdir : dir.listFiles()) {
100104
addSubProjects(projectName, subdir)
101105
}
102106
}
103107

104108
// look for extra plugins for elasticsearch
105-
File xplugins = new File(rootProject.projectDir.parentFile, 'x-plugins')
106-
if (xplugins.exists()) {
107-
include ':x-plugins'
108-
project(':x-plugins').projectDir = xplugins
109-
for (File extraPluginDir : xplugins.listFiles()) {
110-
addSubProjects(':x-plugins', extraPluginDir)
109+
File extraProjects = new File(rootProject.projectDir.parentFile, "${dirName}-extra")
110+
if (extraProjects.exists()) {
111+
for (File extraProjectDir : extraProjects.listFiles()) {
112+
addSubProjects('', extraProjectDir)
111113
}
112114
}

0 commit comments

Comments
 (0)