Search in sources :

Example 6 with DefaultTempFolder

use of org.sonar.api.utils.internal.DefaultTempFolder in project sonarqube by SonarSource.

the class GlobalTempFolderProvider method provide.

public TempFolder provide(GlobalProperties bootstrapProps) {
    if (tempFolder == null) {
        String workingPathName = StringUtils.defaultIfBlank(bootstrapProps.property(CoreProperties.GLOBAL_WORKING_DIRECTORY), CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE);
        Path workingPath = Paths.get(workingPathName);
        if (!workingPath.isAbsolute()) {
            Path home = findSonarHome(bootstrapProps);
            workingPath = home.resolve(workingPath).normalize();
        }
        try {
            cleanTempFolders(workingPath);
        } catch (IOException e) {
            LOG.error(String.format("failed to clean global working directory: %s", workingPath), e);
        }
        Path tempDir = createTempFolder(workingPath);
        tempFolder = new DefaultTempFolder(tempDir.toFile(), true);
    }
    return tempFolder;
}
Also used : Path(java.nio.file.Path) DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) IOException(java.io.IOException)

Example 7 with DefaultTempFolder

use of org.sonar.api.utils.internal.DefaultTempFolder in project sonarlint-core by SonarSource.

the class PartialUpdaterTest method update_file_issues_by_module.

@Test
public void update_file_issues_by_module() throws IOException {
    ServerIssue issue = ServerIssue.newBuilder().setKey("issue1").build();
    List<ServerIssue> issues = Collections.singletonList(issue);
    String moduleKey = "dummy";
    when(storagePaths.getServerIssuesPath(moduleKey)).thenReturn(temp.newFolder().toPath());
    when(downloader.apply(moduleKey)).thenReturn(issues);
    updater.updateFileIssues(moduleKey, new DefaultTempFolder(temp.newFolder()));
    verify(issueStore).save(issues);
}
Also used : DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Aggregations

DefaultTempFolder (org.sonar.api.utils.internal.DefaultTempFolder)7 IOException (java.io.IOException)6 Path (java.nio.file.Path)4 File (java.io.File)2 Test (org.junit.Test)1 ServerIssue (org.sonar.scanner.protocol.input.ScannerInput.ServerIssue)1