Merge pull request #14912 from rjernst/extra_plugins

Change project attachment into special extra-plugins dir
This commit is contained in:
Ryan Ernst 2015-11-22 08:45:24 -08:00
commit 8e2b670b28
9 changed files with 69 additions and 21 deletions

View File

@ -461,3 +461,15 @@ supports a remote debugging option:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
gradle run --debug-jvm 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.
---------------------------------------------------------------------------
gradle projects
---------------------------------------------------------------------------

View File

@ -72,12 +72,6 @@ subprojects {
} }
} }
if (hasProperty('projectsPrefix') == false) {
allprojects {
project.ext['projectsPrefix'] = ''
}
}
allprojects { allprojects {
// injecting groovy property variables into all projects // injecting groovy property variables into all projects
project.ext { project.ext {
@ -108,11 +102,11 @@ subprojects {
} }
ext.projectSubstitutions = [ ext.projectSubstitutions = [
"org.elasticsearch:rest-api-spec:${version}": "${projectsPrefix}:rest-api-spec", "org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
"org.elasticsearch:elasticsearch:${version}": "${projectsPrefix}:core", "org.elasticsearch:elasticsearch:${version}": ':core',
"org.elasticsearch:test-framework:${version}": "${projectsPrefix}:test-framework", "org.elasticsearch:test-framework:${version}": ':test-framework',
"org.elasticsearch.distribution.zip:elasticsearch:${version}": "${projectsPrefix}:distribution:zip", "org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:zip',
"org.elasticsearch.distribution.tar:elasticsearch:${version}": "${projectsPrefix}:distribution:tar" "org.elasticsearch.distribution.tar:elasticsearch:${version}": ':distribution:tar'
] ]
configurations.all { configurations.all {
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs -> resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
@ -169,12 +163,19 @@ allprojects {
apply plugin: 'idea' apply plugin: 'idea'
} }
<<<<<<< HEAD
if (projectsPrefix.isEmpty()) { if (projectsPrefix.isEmpty()) {
idea { idea {
project { project {
languageLevel = org.elasticsearch.gradle.BuildPlugin.minimumJava.toString() languageLevel = org.elasticsearch.gradle.BuildPlugin.minimumJava.toString()
vcs = 'Git' vcs = 'Git'
} }
=======
idea {
project {
languageLevel = org.elasticsearch.gradle.BuildPlugin.minimumJava
vcs = 'Git'
>>>>>>> Build: Change project attachment into special extra-plugins dir
} }
} }

View File

@ -87,7 +87,7 @@ dependencies {
compile "net.java.dev.jna:jna:${versions.jna}", optional compile "net.java.dev.jna:jna:${versions.jna}", optional
if (isEclipse == false || project.path == "${projectsPrefix}:core-tests") { if (isEclipse == false || project.path == ":core-tests") {
testCompile("org.elasticsearch:test-framework:${version}") { testCompile("org.elasticsearch:test-framework:${version}") {
// tests use the locally compiled version of core // tests use the locally compiled version of core
exclude group: 'org.elasticsearch', module: 'elasticsearch' exclude group: 'org.elasticsearch', module: 'elasticsearch'
@ -98,7 +98,7 @@ dependencies {
if (isEclipse) { if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets // in eclipse the project is under a fake root, we need to change around the source sets
sourceSets { sourceSets {
if (project.path == "${projectsPrefix}:core") { if (project.path == ":core") {
main.java.srcDirs = ['java'] main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources'] main.resources.srcDirs = ['resources']
} else { } else {
@ -117,7 +117,7 @@ forbiddenPatterns {
exclude '**/org/elasticsearch/cluster/routing/shard_routes.txt' exclude '**/org/elasticsearch/cluster/routing/shard_routes.txt'
} }
if (isEclipse == false || project.path == "${projectsPrefix}:core-tests") { if (isEclipse == false || project.path == ":core-tests") {
task integTest(type: RandomizedTestingTask, task integTest(type: RandomizedTestingTask,
group: JavaBasePlugin.VERIFICATION_GROUP, group: JavaBasePlugin.VERIFICATION_GROUP,
description: 'Multi-node tests', description: 'Multi-node tests',

View File

@ -3,5 +3,5 @@
apply from: '../../build.gradle' apply from: '../../build.gradle'
dependencies { dependencies {
testCompile project("${projectsPrefix}:core") testCompile project(':core')
} }

View File

@ -41,7 +41,7 @@ buildscript {
allprojects { allprojects {
project.ext { project.ext {
// this is common configuration for distributions, but we also add it here for the license check to use // this is common configuration for distributions, but we also add it here for the license check to use
dependencyFiles = project("${projectsPrefix}:core").configurations.runtime.copyRecursive().exclude(module: 'slf4j-api') dependencyFiles = project(':core').configurations.runtime.copyRecursive().exclude(module: 'slf4j-api')
} }
} }
@ -79,7 +79,7 @@ subprojects {
*****************************************************************************/ *****************************************************************************/
libFiles = copySpec { libFiles = copySpec {
into 'lib' into 'lib'
from project("${projectsPrefix}:core").jar from project(':core').jar
from dependencyFiles from dependencyFiles
} }

1
extra-plugins/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*/

View File

@ -0,0 +1,10 @@
// 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

@ -42,14 +42,14 @@ repositories {
} }
dependencies { dependencies {
test project(path: "${projectsPrefix}:distribution:tar", configuration: 'archives') test project(path: ':distribution:tar', configuration: 'archives')
test project(path: "${projectsPrefix}:distribution:rpm", configuration: 'archives') test project(path: ':distribution:rpm', configuration: 'archives')
test project(path: "${projectsPrefix}:distribution:deb", configuration: 'archives') test project(path: ':distribution:deb', configuration: 'archives')
// Collect all the plugins // Collect all the plugins
for (Project subproj : project.rootProject.subprojects) { for (Project subproj : project.rootProject.subprojects) {
if (subproj.path.startsWith(':plugins:')) { if (subproj.path.startsWith(':plugins:')) {
test project("${projectsPrefix}${subproj.path}") test project("${subproj.path}")
} }
} }

View File

@ -52,3 +52,27 @@ if (isEclipse) {
project(":core-tests").buildFileName = 'eclipse-build.gradle' project(":core-tests").buildFileName = 'eclipse-build.gradle'
} }
/**
* 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
* of the dir hiearchy to have a build.gradle. Otherwise we would have to iterate
* all files/directories in the source tree to find all projects.
*/
void addSubProjects(String path, File dir) {
if (dir.isDirectory() == false) return;
if (new File(dir, 'build.gradle').exists() == false) return;
String projectName = "${path}:${dir.name}"
include projectName
project(projectName).projectDir = dir
for (File subdir : dir.listFiles()) {
addSubProjects(projectName, subdir)
}
}
File extraPlugins = new File(rootProject.projectDir, 'extra-plugins')
for (File extraPluginDir : extraPlugins.listFiles()) {
addSubProjects('', extraPluginDir)
}