2222import org .elasticsearch .gradle .info .BuildParams ;
2323import org .gradle .api .Plugin ;
2424import org .gradle .api .Project ;
25+ import org .gradle .api .artifacts .Configuration ;
2526import org .gradle .api .artifacts .Dependency ;
2627import org .gradle .api .provider .Provider ;
2728
@@ -87,20 +88,22 @@ public void apply(Project project) {
8788 RestResourcesExtension extension = project .getExtensions ().create (EXTENSION_NAME , RestResourcesExtension .class );
8889
8990 // tests
91+ Configuration testConfig = project .getConfigurations ().create ("restTestConfig" );
92+ Configuration xpackTestConfig = project .getConfigurations ().create ("restXpackTest" );
93+ project .getConfigurations ().create ("restTests" );
94+ project .getConfigurations ().create ("restXpackTests" );
9095 Provider <CopyRestTestsTask > copyRestYamlTestTask = project .getTasks ()
9196 .register ("copyYamlTestsTask" , CopyRestTestsTask .class , task -> {
9297 task .includeCore .set (extension .restTests .getIncludeCore ());
9398 task .includeXpack .set (extension .restTests .getIncludeXpack ());
94- task .coreConfig = project .getConfigurations ().create ("restTestConfig" );
95- project .getConfigurations ().maybeCreate ("restTests" );
96- project .getConfigurations ().maybeCreate ("restXpackTests" );
99+ task .coreConfig = testConfig ;
97100 if (BuildParams .isInternal ()) {
98101 // core
99102 Dependency restTestdependency = project .getDependencies ()
100103 .project (Map .of ("path" , ":rest-api-spec" , "configuration" , "restTests" ));
101104 project .getDependencies ().add (task .coreConfig .getName (), restTestdependency );
102105 // x-pack
103- task .xpackConfig = project . getConfigurations (). create ( "restXpackTest" ) ;
106+ task .xpackConfig = xpackTestConfig ;
104107 Dependency restXPackTestdependency = project .getDependencies ()
105108 .project (Map .of ("path" , ":x-pack:plugin" , "configuration" , "restXpackTests" ));
106109 project .getDependencies ().add (task .xpackConfig .getName (), restXPackTestdependency );
@@ -118,20 +121,21 @@ public void apply(Project project) {
118121 });
119122
120123 // api
124+ Configuration specConfig = project .getConfigurations ().create ("restSpec" ); // name chosen for passivity
125+ Configuration xpackSpecConfig = project .getConfigurations ().create ("restXpackSpec" );
126+ project .getConfigurations ().create ("restSpecs" );
127+ project .getConfigurations ().create ("restXpackSpecs" );
121128 Provider <CopyRestApiTask > copyRestYamlSpecTask = project .getTasks ()
122129 .register ("copyRestApiSpecsTask" , CopyRestApiTask .class , task -> {
123130 task .includeCore .set (extension .restApi .getIncludeCore ());
124131 task .includeXpack .set (extension .restApi .getIncludeXpack ());
125132 task .dependsOn (copyRestYamlTestTask );
126- task .coreConfig = project .getConfigurations ().create ("restSpec" ); // name chosen for passivity
127- project .getConfigurations ().maybeCreate ("restSpecs" );
128- project .getConfigurations ().maybeCreate ("restXpackSpecs" );
133+ task .coreConfig = specConfig ;
129134 if (BuildParams .isInternal ()) {
130135 Dependency restSpecDependency = project .getDependencies ()
131136 .project (Map .of ("path" , ":rest-api-spec" , "configuration" , "restSpecs" ));
132137 project .getDependencies ().add (task .coreConfig .getName (), restSpecDependency );
133-
134- task .xpackConfig = project .getConfigurations ().create ("restXpackSpec" );
138+ task .xpackConfig = xpackSpecConfig ;
135139 Dependency restXpackSpecDependency = project .getDependencies ()
136140 .project (Map .of ("path" , ":x-pack:plugin" , "configuration" , "restXpackSpecs" ));
137141 project .getDependencies ().add (task .xpackConfig .getName (), restXpackSpecDependency );
0 commit comments