0
# Configuration
1
2
ArC deployment provides comprehensive build-time configuration interfaces for customizing CDI container behavior, bean discovery, optimization settings, and development features.
3
4
## Capabilities
5
6
### Main Configuration
7
8
Primary configuration interface controlling core CDI behavior and optimization settings.
9
10
```java { .api }
11
/**
12
* Main configuration interface for ArC CDI settings at build time
13
*/
14
public interface ArcConfig {
15
/**
16
* Controls bean removal strategy during optimization
17
* Values: "all", "none", "fwk", "framework-only"
18
*/
19
String removeUnusedBeans();
20
21
/**
22
* Enable automatic field injection without @Inject
23
*/
24
boolean autoInjectFields();
25
26
/**
27
* Transform classes that cannot be proxied by CDI
28
*/
29
boolean transformUnproxyableClasses();
30
31
/**
32
* Transform private fields for injection
33
*/
34
boolean transformPrivateInjectedFields();
35
36
/**
37
* Fail build if intercepted private methods are detected
38
*/
39
boolean failOnInterceptedPrivateMethod();
40
41
/**
42
* List of selected alternative bean classes
43
*/
44
Optional<List<String>> selectedAlternatives();
45
46
/**
47
* Enable automatic producer method generation
48
*/
49
boolean autoProducerMethods();
50
51
/**
52
* Type exclusion patterns for bean discovery
53
*/
54
Optional<List<String>> excludeTypes();
55
56
/**
57
* Patterns for beans that should never be removed
58
*/
59
Optional<List<String>> unremovableTypes();
60
61
/**
62
* Dependency exclusion configuration by artifact
63
*/
64
Map<String, IndexDependencyConfig> excludeDependency();
65
66
/**
67
* Detect false positives in unused bean detection
68
*/
69
boolean detectUnusedFalsePositives();
70
71
/**
72
* Detect wrong usage of annotations (e.g., wrong @Singleton)
73
*/
74
boolean detectWrongAnnotations();
75
76
/**
77
* Enable strict CDI compatibility mode
78
*/
79
boolean strictCompatibility();
80
81
/**
82
* Development mode specific configuration
83
*/
84
ArcDevModeConfig devMode();
85
86
/**
87
* Test mode specific configuration
88
*/
89
ArcTestConfig test();
90
91
/**
92
* Split packages to ignore during validation
93
*/
94
Optional<List<String>> ignoredSplitPackages();
95
96
/**
97
* Context propagation configuration
98
*/
99
ArcContextPropagationConfig contextPropagation();
100
101
/**
102
* Context optimization settings
103
*/
104
OptimizeContexts optimizeContexts();
105
106
/**
107
* Validate removeUnusedBeans configuration value
108
*/
109
boolean isRemoveUnusedBeansFieldValid();
110
111
/**
112
* Check if bean removal should be enabled based on configuration
113
*/
114
boolean shouldEnableBeanRemoval();
115
116
/**
117
* Check if only application beans should be kept
118
*/
119
boolean shouldOnlyKeepAppBeans();
120
}
121
```
122
123
**Usage Examples:**
124
125
```java
126
// Access configuration in build step
127
@BuildStep
128
void configureBeanRemoval(ArcConfig config, BuildProducer<UnremovableBeanBuildItem> unremovable) {
129
if (!config.shouldEnableBeanRemoval()) {
130
// Disable bean removal for all beans
131
unremovable.produce(UnremovableBeanBuildItem.beanTypes(Object.class));
132
}
133
134
// Process unremovable type patterns
135
config.unremovableTypes().ifPresent(patterns -> {
136
for (String pattern : patterns) {
137
unremovable.produce(new UnremovableBeanBuildItem(
138
beanInfo -> beanInfo.getBeanClass().toString().matches(pattern)
139
));
140
}
141
});
142
}
143
```
144
145
### Development Mode Configuration
146
147
Configuration specific to development mode for enhanced debugging and hot reload capabilities.
148
149
```java { .api }
150
/**
151
* Configuration for development mode features
152
*/
153
public interface ArcDevModeConfig {
154
/**
155
* Enable monitoring of file changes for hot reload
156
*/
157
boolean monitoringEnabled();
158
159
/**
160
* Enable lifecycle event debugging
161
*/
162
boolean lifecycleEvents();
163
}
164
```
165
166
### Test Configuration
167
168
Configuration for test-specific CDI behavior and test-related bean handling.
169
170
```java { .api }
171
/**
172
* Configuration for test mode
173
*/
174
public interface ArcTestConfig {
175
/**
176
* Enable test-specific bean discovery
177
*/
178
boolean disableApplicationIndex();
179
180
/**
181
* Configure test bean transformation
182
*/
183
boolean transformTestClasses();
184
}
185
```
186
187
### Context Propagation Configuration
188
189
Configuration for context propagation across different execution contexts.
190
191
```java { .api }
192
/**
193
* Configuration for context propagation features
194
*/
195
public interface ArcContextPropagationConfig {
196
/**
197
* Enable context propagation support
198
*/
199
boolean enabled();
200
201
/**
202
* Configure which contexts to propagate
203
*/
204
Optional<List<String>> propagatedContexts();
205
}
206
```
207
208
### Index Dependency Configuration
209
210
Configuration for controlling which dependencies are included in the bean archive index.
211
212
```java { .api }
213
/**
214
* Configuration for index dependency exclusions
215
*/
216
public interface IndexDependencyConfig {
217
/**
218
* Maven group ID to exclude
219
*/
220
Optional<String> groupId();
221
222
/**
223
* Maven artifact ID to exclude
224
*/
225
Optional<String> artifactId();
226
227
/**
228
* Maven classifier to exclude
229
*/
230
Optional<String> classifier();
231
}
232
```
233
234
### Configuration Build Items
235
236
Build items that provide configuration data to the build process.
237
238
```java { .api }
239
/**
240
* Configuration properties for CDI
241
*/
242
public class ConfigPropertyBuildItem extends MultiBuildItem {
243
public ConfigPropertyBuildItem(String propertyName, String defaultValue);
244
public ConfigPropertyBuildItem(String propertyName, String defaultValue, String configPhase);
245
246
public String getPropertyName();
247
public String getDefaultValue();
248
public String getConfigPhase();
249
}
250
251
/**
252
* Custom scope annotations discovered in configuration
253
*/
254
public class CustomScopeAnnotationsBuildItem extends SimpleBuildItem {
255
public CustomScopeAnnotationsBuildItem(Set<DotName> scopes);
256
public Set<DotName> getScopes();
257
}
258
```
259
260
**Usage Examples:**
261
262
```java
263
// Register configuration properties
264
@BuildStep
265
ConfigPropertyBuildItem addConfigProperty() {
266
return new ConfigPropertyBuildItem(
267
"quarkus.arc.remove-unused-beans",
268
"all",
269
"BUILD_TIME"
270
);
271
}
272
273
// Provide custom scope annotations
274
@BuildStep
275
CustomScopeAnnotationsBuildItem customScopes() {
276
return new CustomScopeAnnotationsBuildItem(
277
Set.of(
278
DotName.createSimple("com.example.TenantScoped"),
279
DotName.createSimple("com.example.RequestScoped")
280
)
281
);
282
}
283
```
284
285
### Configuration Enums
286
287
Enumeration types used in configuration interfaces.
288
289
```java { .api }
290
/**
291
* Context optimization strategies
292
*/
293
public enum OptimizeContexts {
294
/**
295
* Automatically determine optimization based on usage
296
*/
297
AUTO,
298
299
/**
300
* Force enable context optimization
301
*/
302
ENABLED,
303
304
/**
305
* Disable context optimization
306
*/
307
DISABLED
308
}
309
310
/**
311
* Bean removal strategies
312
*/
313
public interface RemoveUnusedBeansStrategy {
314
String ALL = "all"; // Remove all unused beans
315
String NONE = "none"; // Keep all beans
316
String FWK = "fwk"; // Remove only framework beans
317
String FRAMEWORK_ONLY = "framework-only"; // Alias for fwk
318
}
319
```
320
321
## Configuration Usage Patterns
322
323
### Build-Time Configuration Access
324
325
```java
326
@BuildStep
327
void processConfiguration(ArcConfig arcConfig) {
328
// Access configuration values
329
String removalStrategy = arcConfig.removeUnusedBeans();
330
boolean autoInject = arcConfig.autoInjectFields();
331
332
// Process conditional configuration
333
if (arcConfig.strictCompatibility()) {
334
// Enable strict CDI compatibility checks
335
}
336
337
// Handle optional configuration
338
arcConfig.selectedAlternatives().ifPresent(alternatives -> {
339
// Process selected alternatives
340
for (String alternative : alternatives) {
341
// Register alternative beans
342
}
343
});
344
}
345
```
346
347
### Configuration-Driven Build Steps
348
349
```java
350
@BuildStep
351
@Record(ExecutionTime.STATIC_INIT)
352
void configureBeanContainer(ArcConfig config,
353
ArcRecorder recorder,
354
BuildProducer<BeanContainerListenerBuildItem> listeners) {
355
356
if (config.devMode().monitoringEnabled()) {
357
listeners.produce(new BeanContainerListenerBuildItem(
358
recorder.createDevModeListener()
359
));
360
}
361
362
if (config.detectWrongAnnotations()) {
363
listeners.produce(new BeanContainerListenerBuildItem(
364
recorder.createAnnotationValidator()
365
));
366
}
367
}
368
```
369
370
### Dynamic Configuration
371
372
Configuration can be accessed and used dynamically during build steps to customize behavior based on user settings, detected project characteristics, or environmental conditions.