0
# DevServices Processing
1
2
Core build step processing that orchestrates the DevServices lifecycle, provides shared networking, and configures console commands for development-time service management.
3
4
## Capabilities
5
6
### DevServicesProcessor
7
8
Main build step processor that integrates DevServices with the Quarkus build pipeline, handles networking setup, and configures development-time tooling.
9
10
```java { .api }
11
/**
12
* Main DevServices processor providing build steps for service orchestration
13
*/
14
public class DevServicesProcessor {
15
16
/**
17
* Provides shared network ID for DevServices containers
18
* @param devServicesLauncherConfig Optional launcher configuration
19
* @param composeProjectBuildItem Optional compose project information
20
* @return Network ID build item
21
*/
22
@BuildStep
23
public DevServicesNetworkIdBuildItem networkId(
24
Optional<DevServicesLauncherConfigResultBuildItem> devServicesLauncherConfig,
25
Optional<DevServicesComposeProjectBuildItem> composeProjectBuildItem);
26
27
/**
28
* Main configuration build step that sets up DevServices descriptions and console commands
29
* @param dockerStatusBuildItem Docker availability status
30
* @param commandBuildItemBuildProducer Producer for console commands
31
* @param footerLogProducer Producer for Dev UI log streams
32
* @param launchModeBuildItem Current launch mode
33
* @param devServicesLauncherConfig Optional launcher configuration
34
* @param devServicesResults List of all DevServices results
35
* @return List of service descriptions
36
*/
37
@BuildStep(onlyIf = { IsDevelopment.class })
38
public List<DevServiceDescriptionBuildItem> config(
39
DockerStatusBuildItem dockerStatusBuildItem,
40
BuildProducer<ConsoleCommandBuildItem> commandBuildItemBuildProducer,
41
BuildProducer<FooterLogBuildItem> footerLogProducer,
42
LaunchModeBuildItem launchModeBuildItem,
43
Optional<DevServicesLauncherConfigResultBuildItem> devServicesLauncherConfig,
44
List<DevServicesResultBuildItem> devServicesResults);
45
46
/**
47
* Formats service information for console display
48
* @param builder StringBuilder to append formatted information
49
* @param devService Service description to format
50
* @param withStatus Whether to include status information
51
*/
52
public static void printDevService(
53
StringBuilder builder,
54
DevServiceDescriptionBuildItem devService,
55
boolean withStatus);
56
}
57
```
58
59
**Usage Examples:**
60
61
```java
62
// Custom build step that uses DevServices network
63
@BuildStep
64
public void configureCustomService(
65
DevServicesNetworkIdBuildItem networkId,
66
BuildProducer<DevServicesResultBuildItem> devServicesProducer) {
67
68
if (networkId.getNetworkId() != null) {
69
// Use shared network for custom service
70
String customServiceId = startCustomService(networkId.getNetworkId());
71
devServicesProducer.produce(new DevServicesResultBuildItem(
72
"Custom Service",
73
"Custom development service",
74
customServiceId,
75
Map.of("custom.service.url", "http://localhost:8080")
76
));
77
}
78
}
79
80
// Accessing service descriptions in build steps
81
@BuildStep
82
public void processServiceDescriptions(List<DevServiceDescriptionBuildItem> services) {
83
for (DevServiceDescriptionBuildItem service : services) {
84
if (service.hasContainerInfo()) {
85
String containerId = service.getContainerInfo().id();
86
Map<String, String> config = service.getConfigs();
87
// Process service information
88
}
89
}
90
}
91
```
92
93
### ComposeDevServicesProcessor
94
95
Specialized processor for Docker Compose DevServices integration that handles compose file discovery, service startup, and lifecycle management.
96
97
```java { .api }
98
/**
99
* Processor for Docker Compose DevServices integration
100
*/
101
@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
102
public class ComposeDevServicesProcessor {
103
104
/**
105
* Registers the COMPOSE feature
106
* @return Feature build item
107
*/
108
@BuildStep
109
FeatureBuildItem feature();
110
111
/**
112
* Sets up file watching for compose files
113
* @param composeBuildTimeConfig Compose configuration
114
* @param producer Producer for watched file items
115
*/
116
@BuildStep
117
public void watchComposeFiles(
118
ComposeBuildTimeConfig composeBuildTimeConfig,
119
BuildProducer<HotDeploymentWatchedFileBuildItem> producer);
120
121
/**
122
* Main configuration and lifecycle management for Compose services
123
* @param buildExecutor Executor for build operations
124
* @param composeBuildTimeConfig Compose configuration
125
* @param appInfo Application information
126
* @param launchMode Current launch mode
127
* @param consoleInstalledBuildItem Optional console installation status
128
* @param closeBuildItem Shutdown handler
129
* @param loggingSetupBuildItem Logging configuration
130
* @param devServicesConfig DevServices configuration
131
* @param dockerStatusBuildItem Docker status
132
* @return Compose project build item
133
* @throws IOException If file operations fail
134
*/
135
@BuildStep
136
public DevServicesComposeProjectBuildItem config(
137
Executor buildExecutor,
138
ComposeBuildTimeConfig composeBuildTimeConfig,
139
ApplicationInfoBuildItem appInfo,
140
LaunchModeBuildItem launchMode,
141
Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem,
142
CuratedApplicationShutdownBuildItem closeBuildItem,
143
LoggingSetupBuildItem loggingSetupBuildItem,
144
DevServicesConfig devServicesConfig,
145
DockerStatusBuildItem dockerStatusBuildItem) throws IOException;
146
147
/**
148
* Converts compose project to DevServices result
149
* @param composeBuildItem Compose project information
150
* @return DevServices result or null if no project
151
*/
152
@BuildStep
153
public DevServicesResultBuildItem toDevServicesResult(
154
DevServicesComposeProjectBuildItem composeBuildItem);
155
156
/**
157
* Checks if a file is a compose file based on naming pattern
158
* @param p Path to check
159
* @return true if file matches compose naming pattern
160
*/
161
static boolean isComposeFile(Path p);
162
163
/**
164
* Gets the project root directory
165
* @return Path to project root
166
*/
167
static Path getProjectRoot();
168
169
/**
170
* Converts list of file paths to File objects
171
* @param l List of file path strings
172
* @return List of File objects
173
*/
174
static List<File> filesFromConfigList(List<String> l);
175
176
/**
177
* Automatically discovers compose files in project root
178
* @return List of discovered compose files
179
* @throws RuntimeException If directory reading fails
180
*/
181
static List<File> collectComposeFilesFromProjectRoot() throws RuntimeException;
182
}
183
```
184
185
**Usage Examples:**
186
187
```java
188
// Custom processor that integrates with compose services
189
@BuildStep
190
public void integrateWithCompose(
191
DevServicesComposeProjectBuildItem composeProject,
192
BuildProducer<MyCustomBuildItem> producer) {
193
194
if (composeProject.getProject() != null) {
195
Map<String, List<RunningContainer>> services = composeProject.getComposeServices();
196
String networkId = composeProject.getDefaultNetworkId();
197
198
// Integrate with running compose services
199
for (Map.Entry<String, List<RunningContainer>> entry : services.entrySet()) {
200
String serviceName = entry.getKey();
201
List<RunningContainer> containers = entry.getValue();
202
203
producer.produce(new MyCustomBuildItem(serviceName, containers, networkId));
204
}
205
}
206
}
207
208
// Checking if files are compose files
209
List<Path> potentialComposeFiles = List.of(
210
Paths.get("docker-compose.yml"),
211
Paths.get("compose-dev-services.yml"),
212
Paths.get("regular-file.txt")
213
);
214
215
List<Path> composeFiles = potentialComposeFiles.stream()
216
.filter(ComposeDevServicesProcessor::isComposeFile)
217
.collect(Collectors.toList());
218
// Result: [docker-compose.yml, compose-dev-services.yml]
219
```
220
221
## Configuration Constants
222
223
```java { .api }
224
// Compose file pattern matching
225
static final Pattern COMPOSE_FILE = Pattern.compile("(^docker-compose|^compose)(-dev(-)?service).*.(yml|yaml)");
226
227
// Project naming prefix
228
static final String PROJECT_PREFIX = "quarkus-devservices";
229
```
230
231
## Configuration Options
232
233
DevServices can be configured through application properties:
234
235
```properties
236
# Global DevServices configuration
237
quarkus.devservices.enabled=true
238
quarkus.devservices.timeout=PT2M
239
240
# Compose-specific configuration
241
quarkus.compose.enabled=true
242
quarkus.compose.files=docker-compose.yml,docker-compose.override.yml
243
quarkus.compose.profiles=development,testing
244
quarkus.compose.project-name=my-devservices
245
quarkus.compose.start-services=true
246
quarkus.compose.stop-services=true
247
quarkus.compose.follow-logs=false
248
quarkus.compose.env.POSTGRES_PASSWORD=secret
249
quarkus.compose.env.REDIS_PASSWORD=redis-secret
250
251
# Service-specific wait configuration via labels
252
quarkus.compose.wait-for.logs=Server started
253
quarkus.compose.wait-for.ports.timeout=PT30S
254
quarkus.compose.wait-for.healthcheck=true
255
256
# Port configuration mapping
257
quarkus.compose.config.port.5432=DATABASE_URL
258
quarkus.compose.config.port.6379=REDIS_URL
259
```
260
261
The configuration is managed through build-time configuration classes that process these properties during the build phase.