Search in sources :

Example 1 with DefaultTemporaryFileProvider

use of org.gradle.api.internal.file.temp.DefaultTemporaryFileProvider in project gradle by gradle.

the class ProjectBuilderImpl method prepareProjectDir.

public File prepareProjectDir(@Nullable final File projectDir) {
    if (projectDir != null) {
        return FileUtils.canonicalize(projectDir);
    }
    TemporaryFileProvider temporaryFileProvider = new DefaultTemporaryFileProvider(new Factory<File>() {

        @Override
        public File create() {
            String rootTmpDir = SystemProperties.getInstance().getWorkerTmpDir();
            if (rootTmpDir == null) {
                @SuppressWarnings("deprecation") String javaIoTmpDir = SystemProperties.getInstance().getJavaIoTmpDir();
                rootTmpDir = javaIoTmpDir;
            }
            return FileUtils.canonicalize(new File(rootTmpDir));
        }
    });
    File tempDirectory = temporaryFileProvider.createTemporaryDirectory("gradle", "projectDir");
    // TODO deleteOnExit won't clean up non-empty directories (and it leaks memory for long-running processes).
    tempDirectory.deleteOnExit();
    return tempDirectory;
}
Also used : DefaultTemporaryFileProvider(org.gradle.api.internal.file.temp.DefaultTemporaryFileProvider) DefaultTemporaryFileProvider(org.gradle.api.internal.file.temp.DefaultTemporaryFileProvider) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) File(java.io.File)

Aggregations

File (java.io.File)1 DefaultTemporaryFileProvider (org.gradle.api.internal.file.temp.DefaultTemporaryFileProvider)1 TemporaryFileProvider (org.gradle.api.internal.file.temp.TemporaryFileProvider)1