@Bean("GlobalTempFolder")
  public TempFolder provide(ScannerProperties scannerProps, SonarUserHome userHome) {
    var workingPathName = StringUtils.defaultIfBlank(scannerProps.property(CoreProperties.GLOBAL_WORKING_DIRECTORY), CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE);
    var workingPath = Paths.get(workingPathName);

    if (!workingPath.isAbsolute()) {
      var home = userHome.getPath();
      workingPath = home.resolve(workingPath).normalize();
    }
    try {
      cleanTempFolders(workingPath);
    } catch (IOException e) {
      LOG.error(String.format("failed to clean global working directory: %s", workingPath), e);
    }
    var tempDir = createTempFolder(workingPath);
    return new DefaultTempFolder(tempDir.toFile(), true);

  }
@Test
  void cleanUpOld(@TempDir Path workingDir) throws IOException {
    long creationTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(100);

    for (int i = 0; i < 3; i++) {
      Path tmp = workingDir.resolve(".sonartmp_" + i);
      Files.createDirectories(tmp);
      setFileCreationDate(tmp, creationTime);
      assumeCorrectFileCreationDate(tmp, creationTime);
    }

    underTest.provide(
      new ScannerProperties(Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);

    // this also checks that all other temps were deleted
    assertThat(workingDir.toFile().list()).hasSize(1);
  }