void () { if (MavenUtil.isMavenUnitTestModeEnabled()) { if (!myMavenIndices.isDisposed()) { var localIndex = myMavenIndices.getIndexHolder().getLocalIndex(); if (localIndex instanceof MavenIndexImpl impl) { impl.closeAndClean(); } } Path dir = MavenSystemIndicesManager.getInstance().getIndicesDir(); try { PathKt.delete(dir); } catch (Exception e) { // if some files haven't been deleted in the index directory, report them try (Stream<Path> stream = Files.walk(dir)) { var files = stream.map(Path::toString).toList(); var message = files.isEmpty() ? "Failed to delete the index directory" : "Failed to delete files in the index directory: " + String.join(", ", files); throw new RuntimeException(message, e); } catch (IOException ex) { throw new RuntimeException(ex); } } } }