Search in sources :

Example 1 with DefaultTempFolder

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

the class AnalysisTempFolderProvider method provide.

public TempFolder provide(ProjectReactor projectReactor) {
    if (projectTempFolder == null) {
        Path workingDir = projectReactor.getRoot().getWorkDir().toPath();
        Path tempDir = workingDir.normalize().resolve(TMP_NAME);
        try {
            Files.deleteIfExists(tempDir);
            Files.createDirectories(tempDir);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to create root temp directory " + tempDir, e);
        }
        projectTempFolder = new DefaultTempFolder(tempDir.toFile(), true);
    }
    return projectTempFolder;
}
Also used : Path(java.nio.file.Path) DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) IOException(java.io.IOException)

Example 2 with DefaultTempFolder

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

the class AnalysisTempFolderProvider method provide.

public TempFolder provide(StandaloneAnalysisConfiguration analysisConfig) {
    if (projectTempFolder == null) {
        Path workingDir = analysisConfig.workDir();
        Path tempDir = workingDir.normalize().resolve(TMP_NAME);
        try {
            Files.deleteIfExists(tempDir);
            Files.createDirectories(tempDir);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to create root temp directory " + tempDir, e);
        }
        projectTempFolder = new DefaultTempFolder(tempDir.toFile(), true);
    }
    return projectTempFolder;
}
Also used : Path(java.nio.file.Path) DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) IOException(java.io.IOException)

Example 3 with DefaultTempFolder

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

the class GlobalTempFolderProvider method provide.

public TempFolder provide(AbstractGlobalConfiguration globalConfiguration) {
    if (tempFolder == null) {
        Path workingPath = globalConfiguration.getWorkDir();
        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 4 with DefaultTempFolder

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

the class TempFolderProvider method provide.

public TempFolder provide(ServerFileSystem fs) {
    if (tempFolder == null) {
        File tempDir = new File(fs.getTempDir(), "tmp");
        try {
            FileUtils.forceMkdir(tempDir);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to create temp directory " + tempDir, e);
        }
        tempFolder = new DefaultTempFolder(tempDir);
    }
    return tempFolder;
}
Also used : DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) IOException(java.io.IOException) File(java.io.File)

Example 5 with DefaultTempFolder

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

the class ComputationTempFolderProvider method provide.

public TempFolder provide(ServerFileSystem fs) {
    if (this.tempFolder == null) {
        File tempDir = new File(fs.getTempDir(), "ce");
        try {
            FileUtils.forceMkdir(tempDir);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to create computation temp directory " + tempDir, e);
        }
        File computationDir = new DefaultTempFolder(tempDir).newDir();
        this.tempFolder = new DefaultTempFolder(computationDir, true);
    }
    return this.tempFolder;
}
Also used : DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) IOException(java.io.IOException) File(java.io.File)

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