@@ -250,7 +250,20 @@ private ComposeRunningService startCompose(Executor buildExecutor, ComposeDevSer
250
250
}
251
251
252
252
// Start compose
253
- compose .startAndWaitUntilServicesReady (buildExecutor );
253
+ try {
254
+ compose .start ();
255
+ } catch (Exception e ) {
256
+ if (cfg .stopServices ) {
257
+ try {
258
+ compose .stop ();
259
+ } catch (Exception e1 ) {
260
+ log .error ("Failed to stop Compose dev services" , e1 );
261
+ }
262
+ }
263
+ throw e ;
264
+ }
265
+ // Wait for services to be ready
266
+ compose .waitUntilServicesReady (buildExecutor );
254
267
return new ComposeRunningService (compose , true );
255
268
}
256
269
@@ -294,15 +307,24 @@ static boolean isComposeFile(Path p) {
294
307
return COMPOSE_FILE .matcher (p .getFileName ().toString ()).matches ();
295
308
}
296
309
310
+ static Path getProjectRoot () {
311
+ String gradlePath = System .getProperty ("gradle.project.path" );
312
+ if (gradlePath != null ) {
313
+ return Path .of (gradlePath );
314
+ } else {
315
+ return Paths .get (System .getProperty ("user.dir" , "." )).toAbsolutePath ().normalize ();
316
+ }
317
+ }
318
+
297
319
static List <File > filesFromConfigList (List <String > l ) {
298
320
return l .stream ()
299
- .map (f -> Paths . get (f ).toAbsolutePath ().normalize ())
321
+ .map (f -> getProjectRoot (). resolve (f ).toAbsolutePath ().normalize ())
300
322
.map (Path ::toFile )
301
323
.collect (Collectors .toList ());
302
324
}
303
325
304
326
static List <File > collectComposeFilesFromProjectRoot () throws RuntimeException {
305
- try (Stream <Path > list = Files .list (Paths . get ( "." ).toAbsolutePath ().normalize ())) {
327
+ try (Stream <Path > list = Files .list (getProjectRoot ( ).toAbsolutePath ().normalize ())) {
306
328
return list
307
329
.filter (ComposeDevServicesProcessor ::isComposeFile )
308
330
.map (Path ::toFile )
0 commit comments