@@ -99,8 +99,8 @@ class ClusterFormationTasks {
99
99
// from mirrors using gradles built-in mechanism etc.
100
100
101
101
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)
104
104
}
105
105
bwcDistro. resolutionStrategy. cacheChangingModulesFor(0 , TimeUnit . SECONDS )
106
106
bwcPlugins. resolutionStrategy. cacheChangingModulesFor(0 , TimeUnit . SECONDS )
@@ -150,10 +150,15 @@ class ClusterFormationTasks {
150
150
}
151
151
152
152
/* * 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
+ }
157
162
}
158
163
159
164
/**
@@ -210,9 +215,9 @@ class ClusterFormationTasks {
210
215
}
211
216
212
217
// 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)
216
221
}
217
222
218
223
// sets up any extra config files that need to be copied over to the ES instance;
@@ -444,31 +449,40 @@ class ClusterFormationTasks {
444
449
Copy copyPlugins = project. tasks. create(name : name, type : Copy , dependsOn : setup)
445
450
446
451
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()) {
448
453
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)
452
455
Configuration configuration = project. configurations. findByName(configurationName)
453
456
if (configuration == null ) {
454
457
configuration = project. configurations. create(configurationName)
455
458
}
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/**' )
469
479
}
470
- copyRestSpec. from(resourceDir). include(' rest-api-spec/api/**' )
480
+ } else {
481
+ project. dependencies. add(configurationName, " ${ plugin.getValue()} @zip" )
471
482
}
483
+
484
+
485
+
472
486
pluginFiles. add(configuration)
473
487
}
474
488
@@ -477,32 +491,37 @@ class ClusterFormationTasks {
477
491
return copyPlugins
478
492
}
479
493
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(' :' , ' _' )
482
496
}
483
497
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(' :' , ' _' )
486
500
}
487
501
488
502
/* * Configures task to copy a plugin based on a zip file resolved using dependencies for an older version */
489
503
static Task configureCopyBwcPluginsTask (String name , Project project , Task setup , NodeInfo node , String prefix ) {
490
504
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)
495
507
Configuration configuration = project. configurations. findByName(configurationName)
496
508
if (configuration == null ) {
497
509
configuration = project. configurations. create(configurationName)
498
510
}
499
511
500
- final String depName = findPluginName(pluginProject)
512
+ if (plugin. getValue() instanceof Project ) {
513
+ Project pluginProject = plugin. getValue()
514
+ verifyProjectHasBuildPlugin(name, node. nodeVersion, project, pluginProject)
501
515
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" )
504
524
}
505
- configuration. dependencies. add(dep)
506
525
}
507
526
508
527
Copy copyPlugins = project. tasks. create(name : name, type : Copy , dependsOn : setup) {
@@ -527,12 +546,12 @@ class ClusterFormationTasks {
527
546
return installModule
528
547
}
529
548
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 ) {
531
550
final FileCollection pluginZip;
532
551
if (node. nodeVersion != VersionProperties . elasticsearch) {
533
- pluginZip = project. configurations. getByName(pluginBwcConfigurationName(prefix, plugin ))
552
+ pluginZip = project. configurations. getByName(pluginBwcConfigurationName(prefix, pluginName ))
534
553
} else {
535
- pluginZip = project. configurations. getByName(pluginConfigurationName(prefix, plugin ))
554
+ pluginZip = project. configurations. getByName(pluginConfigurationName(prefix, pluginName ))
536
555
}
537
556
// delay reading the file location until execution time by wrapping in a closure within a GString
538
557
final Object file = " ${ -> new File(node.pluginsTmpDir, pluginZip.singleFile.getName()).toURI().toURL().toString()} "
0 commit comments