浏览代码

Merge pull request #14952 from rjernst/attach_without_subdir

Rework extra plugins support to be through sibling directories
Ryan Ernst 10 年之前
父节点
当前提交
321606d3aa
共有 5 个文件被更改,包括 25 次插入22 次删除
  1. 4 3
      TESTING.asciidoc
  2. 12 3
      buildSrc/build.gradle
  3. 0 1
      extra-plugins/.gitignore
  4. 0 10
      extra-plugins/build.gradle
  5. 9 5
      settings.gradle

+ 4 - 3
TESTING.asciidoc

@@ -465,9 +465,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, check it out into the extra-plugins directory.
-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 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.
 
 
 ---------------------------------------------------------------------------
 ---------------------------------------------------------------------------
 gradle projects
 gradle projects

+ 12 - 3
buildSrc/build.gradle

@@ -17,10 +17,19 @@
  * under the License.
  * under the License.
  */
  */
 
 
-plugins {
-  id 'groovy'
-  id 'com.bmuschko.nexus' version '2.3.1'
+// we must use buildscript + apply so that an external plugin
+// can apply this file, since the plugins directive is not
+// supported through file includes
+buildscript {
+  repositories {
+    jcenter()
+  }
+  dependencies {
+    classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
+  }
 }
 }
+apply plugin: 'groovy'
+apply plugin: 'com.bmuschko.nexus'
 // TODO: move common IDE configuration to a common file to include
 // TODO: move common IDE configuration to a common file to include
 apply plugin: 'idea'
 apply plugin: 'idea'
 apply plugin: 'eclipse'
 apply plugin: 'eclipse'

+ 0 - 1
extra-plugins/.gitignore

@@ -1 +0,0 @@
-*/

+ 0 - 10
extra-plugins/build.gradle

@@ -1,10 +0,0 @@
-
-// This file exists solely for the purpose of allowing a nice error message
-// if someone tries running a gradle command from within the extra-plugins dir.
-
-println '''
-  Gradle commands are not supported from within the extra-plugins dir.
-  Please run your command either at the root of the elasticsearch checkout
-  or within a specific extra-plugins project.
-'''
-throw new GradleException('Cannot run commands in extra-plugins dir')

+ 9 - 5
settings.gradle

@@ -61,19 +61,23 @@ if (isEclipse) {
   */
   */
 void addSubProjects(String path, File dir) {
 void addSubProjects(String path, File dir) {
   if (dir.isDirectory() == false) return;
   if (dir.isDirectory() == false) return;
+  if (dir.name == 'buildSrc') return;
   if (new File(dir, 'build.gradle').exists() == false) return;
   if (new File(dir, 'build.gradle').exists() == false) return;
 
 
   String projectName = "${path}:${dir.name}"
   String projectName = "${path}:${dir.name}"
   include projectName
   include projectName
-  project(projectName).projectDir = dir
-
   for (File subdir : dir.listFiles()) {
   for (File subdir : dir.listFiles()) {
     addSubProjects(projectName, subdir)
     addSubProjects(projectName, subdir)
   }
   }
 }
 }
 
 
-File extraPlugins = new File(rootProject.projectDir, 'extra-plugins')
-for (File extraPluginDir : extraPlugins.listFiles()) {
-  addSubProjects('', extraPluginDir)
+// 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)
+  }
 }
 }