Search in sources :

Example 1 with TemporaryFileProvider

use of org.gradle.api.internal.file.temp.TemporaryFileProvider 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)

Example 2 with TemporaryFileProvider

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

the class Groovydoc method getAntGroovydoc.

@Internal
public AntGroovydoc getAntGroovydoc() {
    if (antGroovydoc == null) {
        IsolatedAntBuilder antBuilder = getServices().get(IsolatedAntBuilder.class);
        TemporaryFileProvider temporaryFileProvider = getServices().get(TemporaryFileProvider.class);
        antGroovydoc = new AntGroovydoc(antBuilder, temporaryFileProvider);
    }
    return antGroovydoc;
}
Also used : IsolatedAntBuilder(org.gradle.api.internal.project.IsolatedAntBuilder) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) AntGroovydoc(org.gradle.api.internal.tasks.AntGroovydoc) Internal(org.gradle.api.tasks.Internal)

Example 3 with TemporaryFileProvider

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

the class AvailableJavaHomes method discoverLocalInstallations.

private static List<JvmInstallationMetadata> discoverLocalInstallations() {
    ExecHandleFactory execHandleFactory = TestFiles.execHandleFactory();
    TemporaryFileProvider temporaryFileProvider = TestFiles.tmpDirTemporaryFileProvider(new File(SystemProperties.getInstance().getJavaIoTmpDir()));
    DefaultJvmMetadataDetector defaultJvmMetadataDetector = new DefaultJvmMetadataDetector(execHandleFactory, temporaryFileProvider);
    JvmMetadataDetector metadataDetector = new CachingJvmMetadataDetector(defaultJvmMetadataDetector);
    final List<JvmInstallationMetadata> jvms = new JavaInstallationRegistry(defaultInstallationSuppliers(), new TestBuildOperationExecutor(), OperatingSystem.current()).listInstallations().stream().map(InstallationLocation::getLocation).map(metadataDetector::getMetadata).filter(JvmInstallationMetadata::isValidInstallation).sorted(Comparator.comparing(JvmInstallationMetadata::getDisplayName).thenComparing(JvmInstallationMetadata::getLanguageVersion)).collect(Collectors.toList());
    System.out.println("Found the following JVMs:");
    for (JvmInstallationMetadata jvm : jvms) {
        String name = jvm.getDisplayName() + " " + jvm.getImplementationVersion() + " ";
        System.out.println("    " + name + " - " + jvm.getJavaHome());
    }
    return jvms;
}
Also used : TestBuildOperationExecutor(org.gradle.internal.operations.TestBuildOperationExecutor) InstallationLocation(org.gradle.jvm.toolchain.internal.InstallationLocation) JvmInstallationMetadata(org.gradle.internal.jvm.inspection.JvmInstallationMetadata) ExecHandleFactory(org.gradle.process.internal.ExecHandleFactory) DefaultJvmMetadataDetector(org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector) CachingJvmMetadataDetector(org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector) JvmMetadataDetector(org.gradle.internal.jvm.inspection.JvmMetadataDetector) DefaultJvmMetadataDetector(org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) CachingJvmMetadataDetector(org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector) JavaInstallationRegistry(org.gradle.jvm.toolchain.internal.JavaInstallationRegistry) File(java.io.File)

Example 4 with TemporaryFileProvider

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

the class DefaultExecActionFactory method root.

// Do not use this. It's here because some of the services this type needs are not easily accessed in certain cases and will be removed ay some point. Use one of the other methods instead
@Deprecated
public static DefaultExecActionFactory root(File gradleUserHome) {
    requireNonNull(gradleUserHome, "gradleUserHome");
    Factory<PatternSet> patternSetFactory = PatternSets.getNonCachingPatternSetFactory();
    FileResolver resolver = new DefaultFileLookup().getFileResolver();
    DefaultFileCollectionFactory fileCollectionFactory = new DefaultFileCollectionFactory(resolver, DefaultTaskDependencyFactory.withNoAssociatedProject(), new DefaultDirectoryFileTreeFactory(), patternSetFactory, PropertyHost.NO_OP, FileSystems.getDefault());
    GradleUserHomeDirProvider userHomeDirProvider = () -> gradleUserHome;
    TemporaryFileProvider temporaryFileProvider = new GradleUserHomeTemporaryFileProvider(userHomeDirProvider);
    return of(resolver, fileCollectionFactory, new InstantiatorBackedObjectFactory(DirectInstantiator.INSTANCE), new DefaultExecutorFactory(), new DefaultBuildCancellationToken(), temporaryFileProvider);
}
Also used : InstantiatorBackedObjectFactory(org.gradle.api.internal.model.InstantiatorBackedObjectFactory) DefaultFileLookup(org.gradle.api.internal.file.DefaultFileLookup) GradleUserHomeDirProvider(org.gradle.initialization.GradleUserHomeDirProvider) DefaultBuildCancellationToken(org.gradle.initialization.DefaultBuildCancellationToken) DefaultDirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory) GradleUserHomeTemporaryFileProvider(org.gradle.api.internal.file.temp.GradleUserHomeTemporaryFileProvider) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) GradleUserHomeTemporaryFileProvider(org.gradle.api.internal.file.temp.GradleUserHomeTemporaryFileProvider) FileResolver(org.gradle.api.internal.file.FileResolver) PatternSet(org.gradle.api.tasks.util.PatternSet) DefaultFileCollectionFactory(org.gradle.api.internal.file.DefaultFileCollectionFactory) DefaultExecutorFactory(org.gradle.internal.concurrent.DefaultExecutorFactory)

Aggregations

TemporaryFileProvider (org.gradle.api.internal.file.temp.TemporaryFileProvider)4 File (java.io.File)2 DefaultFileCollectionFactory (org.gradle.api.internal.file.DefaultFileCollectionFactory)1 DefaultFileLookup (org.gradle.api.internal.file.DefaultFileLookup)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 DefaultDirectoryFileTreeFactory (org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory)1 DefaultTemporaryFileProvider (org.gradle.api.internal.file.temp.DefaultTemporaryFileProvider)1 GradleUserHomeTemporaryFileProvider (org.gradle.api.internal.file.temp.GradleUserHomeTemporaryFileProvider)1 InstantiatorBackedObjectFactory (org.gradle.api.internal.model.InstantiatorBackedObjectFactory)1 IsolatedAntBuilder (org.gradle.api.internal.project.IsolatedAntBuilder)1 AntGroovydoc (org.gradle.api.internal.tasks.AntGroovydoc)1 Internal (org.gradle.api.tasks.Internal)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 DefaultBuildCancellationToken (org.gradle.initialization.DefaultBuildCancellationToken)1 GradleUserHomeDirProvider (org.gradle.initialization.GradleUserHomeDirProvider)1 DefaultExecutorFactory (org.gradle.internal.concurrent.DefaultExecutorFactory)1 CachingJvmMetadataDetector (org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector)1 DefaultJvmMetadataDetector (org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector)1 JvmInstallationMetadata (org.gradle.internal.jvm.inspection.JvmInstallationMetadata)1 JvmMetadataDetector (org.gradle.internal.jvm.inspection.JvmMetadataDetector)1