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-".
This commit is contained in:
Ryan Ernst 2015-11-23 14:11:32 -08:00
parent bc0a840a9c
commit 5a62282150
4 changed files with 26 additions and 23 deletions

View File

@ -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

View File

@ -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'

View File

@ -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')

View File

@ -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)
}