Browse Source

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.
Ryan Ernst 8 years ago
parent
commit
f0c0f571bf
2 changed files with 14 additions and 12 deletions
  1. 4 4
      TESTING.asciidoc
  2. 10 8
      settings.gradle

+ 4 - 4
TESTING.asciidoc

@@ -474,10 +474,10 @@ gradle run --debug-jvm
 == Building with extra plugins
 == Building with extra plugins
 Additional plugins may be built alongside elasticsearch, where their
 Additional plugins may be built alongside elasticsearch, where their
 dependency on elasticsearch will be substituted with the local elasticsearch
 dependency on elasticsearch will be substituted with the local elasticsearch
-build. To add your plugin, create a directory called x-plugins as a sibling
-of elasticsearch. Checkout your plugin underneath x-plugins and the build
-will automatically pick it up. You can verify the plugin is included as part
-of the build by checking the projects of the build.
+build. To add your plugin, create a directory called elasticsearch-extra as
+a sibling of elasticsearch. Checkout your plugin underneath elasticsearch-extra
+and the build will automatically pick it up. You can verify the plugin is
+included as part of the build by checking the projects of the build.
 
 
 ---------------------------------------------------------------------------
 ---------------------------------------------------------------------------
 gradle projects
 gradle projects

+ 10 - 8
settings.gradle

@@ -1,4 +1,5 @@
-rootProject.name = 'elasticsearch'
+String dirName = rootProject.projectDir.name
+rootProject.name = dirName
 
 
 List projects = [
 List projects = [
   'build-tools',
   'build-tools',
@@ -86,7 +87,7 @@ if (isEclipse) {
 /**
 /**
   * Iterates over sub directories, looking for build.gradle, and adds a project if found
   * Iterates over sub directories, looking for build.gradle, and adds a project if found
   * for that dir with the given path prefix. Note that this requires each level
   * for that dir with the given path prefix. Note that this requires each level
-  * of the dir hiearchy to have a build.gradle. Otherwise we would have to iterate
+  * of the dir hierarchy to have a build.gradle. Otherwise we would have to iterate
   * all files/directories in the source tree to find all projects.
   * all files/directories in the source tree to find all projects.
   */
   */
 void addSubProjects(String path, File dir) {
 void addSubProjects(String path, File dir) {
@@ -96,17 +97,18 @@ void addSubProjects(String path, File dir) {
 
 
   String projectName = "${path}:${dir.name}"
   String projectName = "${path}:${dir.name}"
   include projectName
   include projectName
+  if (path.isEmpty()) {
+    project(projectName).projectDir = dir
+  }
   for (File subdir : dir.listFiles()) {
   for (File subdir : dir.listFiles()) {
     addSubProjects(projectName, subdir)
     addSubProjects(projectName, subdir)
   }
   }
 }
 }
 
 
 // look for extra plugins for elasticsearch
 // look for extra plugins for elasticsearch
-File xplugins = new File(rootProject.projectDir.parentFile, 'x-plugins')
-if (xplugins.exists()) {
-  include ':x-plugins'
-  project(':x-plugins').projectDir = xplugins
-  for (File extraPluginDir : xplugins.listFiles()) {
-    addSubProjects(':x-plugins', extraPluginDir)
+File extraProjects = new File(rootProject.projectDir.parentFile, "${dirName}-extra")
+if (extraProjects.exists()) {
+  for (File extraProjectDir : extraProjects.listFiles()) {
+    addSubProjects('', extraProjectDir)
   }
   }
 }
 }