From 5a622821509bee35160c38af56c2b07d8f7c1046 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 23 Nov 2015 14:11:32 -0800 Subject: [PATCH] Build: Rework extra plugins support to be through sibling directories This change removes the subdirectory support for extra-plugins, and replaces it with an iteration of sibling directories with the prefix "extra-plugin-". --- TESTING.asciidoc | 7 ++++--- buildSrc/build.gradle | 15 ++++++++++++--- extra-plugins/build.gradle | 10 ---------- settings.gradle | 17 ++++++++++------- 4 files changed, 26 insertions(+), 23 deletions(-) delete mode 100644 extra-plugins/build.gradle diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 2b99ff67fcf..b438209196c 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -465,9 +465,10 @@ gradle run --debug-jvm == Building with extra plugins Additional plugins may be built alongside elasticsearch, where their 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, check it out as a sibling directory of +elasticsearch, with a prefix of "extra-plugin-". 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 diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 955a1f98ef2..0fa713fe371 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -17,10 +17,19 @@ * 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 apply plugin: 'idea' apply plugin: 'eclipse' diff --git a/extra-plugins/build.gradle b/extra-plugins/build.gradle deleted file mode 100644 index 12217489a43..00000000000 --- a/extra-plugins/build.gradle +++ /dev/null @@ -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') diff --git a/settings.gradle b/settings.gradle index defe174fd2e..91dc2f472bf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -61,19 +61,22 @@ if (isEclipse) { */ void addSubProjects(String path, File dir) { if (dir.isDirectory() == false) return; + if (dir.name == 'buildSrc') return; if (new File(dir, 'build.gradle').exists() == false) return; - String projectName = "${path}:${dir.name}" - include projectName - project(projectName).projectDir = dir + include path + project(path).projectDir = dir for (File subdir : dir.listFiles()) { - addSubProjects(projectName, subdir) + addSubProjects("${path}:${subdir.name}", subdir) } } -File extraPlugins = new File(rootProject.projectDir, 'extra-plugins') -for (File extraPluginDir : extraPlugins.listFiles()) { - addSubProjects('', extraPluginDir) +// look for sibling projects with the prefix "extra-plugin-" +File siblings = rootProject.projectDir.parentFile +for (File extraPluginDir : siblings.listFiles()) { + if (extraPluginDir.name.startsWith('extra-plugin-') == false) continue; + String path = ":${extraPluginDir.name.substring('extra-plugin-'.size())}" + addSubProjects(path, extraPluginDir) }