@@ -66,38 +66,50 @@ public static void initConfigurations(Project project) {
66
66
final ConfigurationContainer configContainer = project .getConfigurations ();
67
67
68
68
// Custom configuration for dev mode
69
- configContainer .create (ToolingUtils .DEV_MODE_CONFIGURATION_NAME )
70
- .extendsFrom (configContainer .getByName (JavaPlugin .IMPLEMENTATION_CONFIGURATION_NAME ));
69
+ configContainer .register (ToolingUtils .DEV_MODE_CONFIGURATION_NAME , config -> {
70
+ config .extendsFrom (configContainer .getByName (JavaPlugin .IMPLEMENTATION_CONFIGURATION_NAME ));
71
+ config .setCanBeConsumed (false );
72
+ });
71
73
72
74
// Base runtime configurations for every launch mode
73
- configContainer .create (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .TEST ))
74
- .extendsFrom (configContainer .getByName (JavaPlugin .TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
75
+ configContainer
76
+ .register (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .TEST ), config -> {
77
+ config .extendsFrom (configContainer .getByName (JavaPlugin .TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
78
+ config .setCanBeConsumed (false );
79
+ });
75
80
76
- configContainer .create (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .NORMAL ))
77
- .extendsFrom (configContainer .getByName (JavaPlugin .RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
81
+ configContainer
82
+ .register (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .NORMAL ), config -> {
83
+ config .extendsFrom (configContainer .getByName (JavaPlugin .RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
84
+ config .setCanBeConsumed (false );
85
+ });
78
86
79
- configContainer .create (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .DEVELOPMENT ))
80
- .extendsFrom (
81
- configContainer .getByName (ToolingUtils .DEV_MODE_CONFIGURATION_NAME ),
82
- configContainer .getByName (JavaPlugin .COMPILE_CLASSPATH_CONFIGURATION_NAME ),
83
- configContainer .getByName (JavaPlugin .RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
87
+ configContainer
88
+ .register (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (LaunchMode .DEVELOPMENT ), config -> {
89
+ config .extendsFrom (
90
+ configContainer .getByName (ToolingUtils .DEV_MODE_CONFIGURATION_NAME ),
91
+ configContainer .getByName (JavaPlugin .COMPILE_CLASSPATH_CONFIGURATION_NAME ),
92
+ configContainer .getByName (JavaPlugin .RUNTIME_CLASSPATH_CONFIGURATION_NAME ));
93
+ config .setCanBeConsumed (false );
94
+ });
84
95
85
96
// enable the Panache annotation processor on the classpath, if it's found among the dependencies
86
- configContainer .getByName (JavaPlugin .ANNOTATION_PROCESSOR_CONFIGURATION_NAME )
87
- .withDependencies (annotationProcessors -> {
88
- Set <ResolvedArtifact > compileClasspathArtifacts = DependencyUtils
89
- .duplicateConfiguration (project , configContainer
90
- .getByName (JavaPlugin .COMPILE_CLASSPATH_CONFIGURATION_NAME ))
91
- .getResolvedConfiguration ()
92
- .getResolvedArtifacts ();
93
- for (ResolvedArtifact artifact : compileClasspathArtifacts ) {
94
- if ("quarkus-panache-common" .equals (artifact .getName ())
95
- && "io.quarkus" .equals (artifact .getModuleVersion ().getId ().getGroup ())) {
96
- project .getDependencies ().add (JavaPlugin .ANNOTATION_PROCESSOR_CONFIGURATION_NAME ,
97
- "io.quarkus:quarkus-panache-common:" + artifact .getModuleVersion ().getId ().getVersion ());
98
- }
97
+ configContainer .named (JavaPlugin .ANNOTATION_PROCESSOR_CONFIGURATION_NAME , config -> {
98
+ config .withDependencies (annotationProcessors -> {
99
+ Set <ResolvedArtifact > compileClasspathArtifacts = DependencyUtils
100
+ .duplicateConfiguration (project , configContainer
101
+ .getByName (JavaPlugin .COMPILE_CLASSPATH_CONFIGURATION_NAME ))
102
+ .getResolvedConfiguration ()
103
+ .getResolvedArtifacts ();
104
+ for (ResolvedArtifact artifact : compileClasspathArtifacts ) {
105
+ if ("quarkus-panache-common" .equals (artifact .getName ())
106
+ && "io.quarkus" .equals (artifact .getModuleVersion ().getId ().getGroup ())) {
107
+ project .getDependencies ().add (JavaPlugin .ANNOTATION_PROCESSOR_CONFIGURATION_NAME ,
108
+ "io.quarkus:quarkus-panache-common:" + artifact .getModuleVersion ().getId ().getVersion ());
99
109
}
100
- });
110
+ }
111
+ });
112
+ });
101
113
}
102
114
103
115
private final Project project ;
@@ -135,7 +147,7 @@ private void setUpPlatformConfiguration() {
135
147
PlatformImportsImpl platformImports = ApplicationDeploymentClasspathBuilder .platformImports
136
148
.computeIfAbsent (this .platformImportName , (ignored ) -> new PlatformImportsImpl ());
137
149
138
- project .getConfigurations ().create (this .platformConfigurationName , configuration -> {
150
+ project .getConfigurations ().register (this .platformConfigurationName , configuration -> {
139
151
// Platform configuration is just implementation, filtered to platform dependencies
140
152
ListProperty <Dependency > dependencyListProperty = project .getObjects ().listProperty (Dependency .class );
141
153
configuration .getDependencies ()
@@ -184,16 +196,16 @@ private void setUpPlatformConfiguration() {
184
196
}
185
197
186
198
private void setUpRuntimeConfiguration () {
187
- if (project .getConfigurations ().findByName ( this .runtimeConfigurationName ) == null ) {
188
- project .getConfigurations ().create (this .runtimeConfigurationName , configuration -> configuration .extendsFrom (
199
+ if (! project .getConfigurations ().getNames (). contains ( this .runtimeConfigurationName )) {
200
+ project .getConfigurations ().register (this .runtimeConfigurationName , configuration -> configuration .extendsFrom (
189
201
project .getConfigurations ()
190
202
.getByName (ApplicationDeploymentClasspathBuilder .getBaseRuntimeConfigName (mode ))));
191
203
}
192
204
}
193
205
194
206
private void setUpDeploymentConfiguration () {
195
- if (project .getConfigurations ().findByName ( this .deploymentConfigurationName ) == null ) {
196
- project .getConfigurations ().create (this .deploymentConfigurationName , configuration -> {
207
+ if (! project .getConfigurations ().getNames (). contains ( this .deploymentConfigurationName )) {
208
+ project .getConfigurations ().register (this .deploymentConfigurationName , configuration -> {
197
209
Configuration enforcedPlatforms = this .getPlatformConfiguration ();
198
210
configuration .extendsFrom (enforcedPlatforms );
199
211
ListProperty <Dependency > dependencyListProperty = project .getObjects ().listProperty (Dependency .class );
0 commit comments