@@ -99,8 +99,8 @@ class ClusterFormationTasks {
9999 // from mirrors using gradles built-in mechanism etc.
100100
101101 configureDistributionDependency(project, config. distribution, bwcDistro, config. bwcVersion)
102- for (Map.Entry < String , Project > entry : config. plugins. entrySet()) {
103- configureBwcPluginDependency(" ${ prefix } _elasticsearchBwcPlugins " , project, entry. getValue(), bwcPlugins, config. bwcVersion)
102+ for (Map.Entry < String , Object > entry : config. plugins. entrySet()) {
103+ configureBwcPluginDependency(project, entry. getValue(), bwcPlugins, config. bwcVersion)
104104 }
105105 bwcDistro. resolutionStrategy. cacheChangingModulesFor(0 , TimeUnit . SECONDS )
106106 bwcPlugins. resolutionStrategy. cacheChangingModulesFor(0 , TimeUnit . SECONDS )
@@ -150,10 +150,15 @@ class ClusterFormationTasks {
150150 }
151151
152152 /* * Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */
153- static void configureBwcPluginDependency (String name , Project project , Project pluginProject , Configuration configuration , Version elasticsearchVersion ) {
154- verifyProjectHasBuildPlugin(name, elasticsearchVersion, project, pluginProject)
155- final String pluginName = findPluginName(pluginProject)
156- project. dependencies. add(configuration. name, " org.elasticsearch.plugin:${ pluginName} :${ elasticsearchVersion} @zip" )
153+ static void configureBwcPluginDependency (Project project , Object plugin , Configuration configuration , Version elasticsearchVersion ) {
154+ if (plugin instanceof Project ) {
155+ Project pluginProject = (Project )plugin
156+ verifyProjectHasBuildPlugin(configuration. name, elasticsearchVersion, project, pluginProject)
157+ final String pluginName = findPluginName(pluginProject)
158+ project. dependencies. add(configuration. name, " org.elasticsearch.plugin:${ pluginName} :${ elasticsearchVersion} @zip" )
159+ } else {
160+ project. dependencies. add(configuration. name, " ${ plugin} @zip" )
161+ }
157162 }
158163
159164 /**
@@ -210,9 +215,9 @@ class ClusterFormationTasks {
210215 }
211216
212217 // install plugins
213- for (Map.Entry < String , Project > plugin : node. config. plugins. entrySet ()) {
214- String actionName = pluginTaskName(' install' , plugin . getKey() , ' Plugin' )
215- setup = configureInstallPluginTask(taskName(prefix, node, actionName), project, setup, node, plugin . getValue() , prefix)
218+ for (String pluginName : node. config. plugins. keySet ()) {
219+ String actionName = pluginTaskName(' install' , pluginName , ' Plugin' )
220+ setup = configureInstallPluginTask(taskName(prefix, node, actionName), project, setup, node, pluginName , prefix)
216221 }
217222
218223 // sets up any extra config files that need to be copied over to the ES instance;
@@ -444,31 +449,40 @@ class ClusterFormationTasks {
444449 Copy copyPlugins = project. tasks. create(name : name, type : Copy , dependsOn : setup)
445450
446451 List<FileCollection > pluginFiles = []
447- for (Map.Entry < String , Project > plugin : node. config. plugins. entrySet()) {
452+ for (Map.Entry < String , Object > plugin : node. config. plugins. entrySet()) {
448453
449- Project pluginProject = plugin. getValue()
450- verifyProjectHasBuildPlugin(name, node. nodeVersion, project, pluginProject)
451- String configurationName = pluginConfigurationName(prefix, pluginProject)
454+ String configurationName = pluginConfigurationName(prefix, plugin. key)
452455 Configuration configuration = project. configurations. findByName(configurationName)
453456 if (configuration == null ) {
454457 configuration = project. configurations. create(configurationName)
455458 }
456- project. dependencies. add(configurationName, project. dependencies. project(path : pluginProject. path, configuration : ' zip' ))
457- setup. dependsOn(pluginProject. tasks. bundlePlugin)
458-
459- // also allow rest tests to use the rest spec from the plugin
460- String copyRestSpecTaskName = pluginTaskName(' copy' , plugin. getKey(), ' PluginRestSpec' )
461- Copy copyRestSpec = project. tasks. findByName(copyRestSpecTaskName)
462- for (File resourceDir : pluginProject. sourceSets. test. resources. srcDirs) {
463- File restApiDir = new File (resourceDir, ' rest-api-spec/api' )
464- if (restApiDir. exists() == false ) continue
465- if (copyRestSpec == null ) {
466- copyRestSpec = project. tasks. create(name : copyRestSpecTaskName, type : Copy )
467- copyPlugins. dependsOn(copyRestSpec)
468- copyRestSpec. into(project. sourceSets. test. output. resourcesDir)
459+
460+ if (plugin. getValue() instanceof Project ) {
461+ Project pluginProject = plugin. getValue()
462+ verifyProjectHasBuildPlugin(name, node. nodeVersion, project, pluginProject)
463+
464+ project. dependencies. add(configurationName, project. dependencies. project(path : pluginProject. path, configuration : ' zip' ))
465+ setup. dependsOn(pluginProject. tasks. bundlePlugin)
466+
467+ // also allow rest tests to use the rest spec from the plugin
468+ String copyRestSpecTaskName = pluginTaskName(' copy' , plugin. getKey(), ' PluginRestSpec' )
469+ Copy copyRestSpec = project. tasks. findByName(copyRestSpecTaskName)
470+ for (File resourceDir : pluginProject. sourceSets. test. resources. srcDirs) {
471+ File restApiDir = new File (resourceDir, ' rest-api-spec/api' )
472+ if (restApiDir. exists() == false ) continue
473+ if (copyRestSpec == null ) {
474+ copyRestSpec = project. tasks. create(name : copyRestSpecTaskName, type : Copy )
475+ copyPlugins. dependsOn(copyRestSpec)
476+ copyRestSpec. into(project. sourceSets. test. output. resourcesDir)
477+ }
478+ copyRestSpec. from(resourceDir). include(' rest-api-spec/api/**' )
469479 }
470- copyRestSpec. from(resourceDir). include(' rest-api-spec/api/**' )
480+ } else {
481+ project. dependencies. add(configurationName, " ${ plugin.getValue()} @zip" )
471482 }
483+
484+
485+
472486 pluginFiles. add(configuration)
473487 }
474488
@@ -477,32 +491,37 @@ class ClusterFormationTasks {
477491 return copyPlugins
478492 }
479493
480- private static String pluginConfigurationName (final String prefix , final Project project ) {
481- return " _plugin_${ prefix} _${ project.path } " . replace(' :' , ' _' )
494+ private static String pluginConfigurationName (final String prefix , final String name ) {
495+ return " _plugin_${ prefix} _${ name } " . replace(' :' , ' _' )
482496 }
483497
484- private static String pluginBwcConfigurationName (final String prefix , final Project project ) {
485- return " _plugin_bwc_${ prefix} _${ project.path } " . replace(' :' , ' _' )
498+ private static String pluginBwcConfigurationName (final String prefix , final String name ) {
499+ return " _plugin_bwc_${ prefix} _${ name } " . replace(' :' , ' _' )
486500 }
487501
488502 /* * Configures task to copy a plugin based on a zip file resolved using dependencies for an older version */
489503 static Task configureCopyBwcPluginsTask (String name , Project project , Task setup , NodeInfo node , String prefix ) {
490504 Configuration bwcPlugins = project. configurations. getByName(" ${ prefix} _elasticsearchBwcPlugins" )
491- for (Map.Entry < String , Project > plugin : node. config. plugins. entrySet()) {
492- Project pluginProject = plugin. getValue()
493- verifyProjectHasBuildPlugin(name, node. nodeVersion, project, pluginProject)
494- String configurationName = pluginBwcConfigurationName(prefix, pluginProject)
505+ for (Map.Entry < String , Object > plugin : node. config. plugins. entrySet()) {
506+ String configurationName = pluginBwcConfigurationName(prefix, plugin. key)
495507 Configuration configuration = project. configurations. findByName(configurationName)
496508 if (configuration == null ) {
497509 configuration = project. configurations. create(configurationName)
498510 }
499511
500- final String depName = findPluginName(pluginProject)
512+ if (plugin. getValue() instanceof Project ) {
513+ Project pluginProject = plugin. getValue()
514+ verifyProjectHasBuildPlugin(name, node. nodeVersion, project, pluginProject)
501515
502- Dependency dep = bwcPlugins. dependencies. find {
503- it. name == depName
516+ final String depName = findPluginName(pluginProject)
517+
518+ Dependency dep = bwcPlugins. dependencies. find {
519+ it. name == depName
520+ }
521+ configuration. dependencies. add(dep)
522+ } else {
523+ project. dependencies. add(configurationName, " ${ plugin.getValue()} @zip" )
504524 }
505- configuration. dependencies. add(dep)
506525 }
507526
508527 Copy copyPlugins = project. tasks. create(name : name, type : Copy , dependsOn : setup) {
@@ -527,12 +546,12 @@ class ClusterFormationTasks {
527546 return installModule
528547 }
529548
530- static Task configureInstallPluginTask (String name , Project project , Task setup , NodeInfo node , Project plugin , String prefix ) {
549+ static Task configureInstallPluginTask (String name , Project project , Task setup , NodeInfo node , String pluginName , String prefix ) {
531550 final FileCollection pluginZip;
532551 if (node. nodeVersion != VersionProperties . elasticsearch) {
533- pluginZip = project. configurations. getByName(pluginBwcConfigurationName(prefix, plugin ))
552+ pluginZip = project. configurations. getByName(pluginBwcConfigurationName(prefix, pluginName ))
534553 } else {
535- pluginZip = project. configurations. getByName(pluginConfigurationName(prefix, plugin ))
554+ pluginZip = project. configurations. getByName(pluginConfigurationName(prefix, pluginName ))
536555 }
537556 // delay reading the file location until execution time by wrapping in a closure within a GString
538557 final Object file = " ${ -> new File(node.pluginsTmpDir, pluginZip.singleFile.getName()).toURI().toURL().toString()} "
0 commit comments