use of org.gradle.api.internal.file.FileResolver in project gradle by gradle.
the class Wrapper method generate.
@TaskAction
void generate() {
File jarFileDestination = getJarFile();
File unixScript = getScriptFile();
FileResolver resolver = getFileLookup().getFileResolver(unixScript.getParentFile());
String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);
writeProperties(getPropertiesFile());
writeWrapperTo(jarFileDestination);
StartScriptGenerator generator = new StartScriptGenerator();
generator.setApplicationName("Gradle");
generator.setMainClassName(GradleWrapperMain.class.getName());
generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
generator.setOptsEnvironmentVar("GRADLE_OPTS");
generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
generator.setAppNameSystemProperty("org.gradle.appname");
generator.setScriptRelPath(unixScript.getName());
generator.setDefaultJvmOpts(ImmutableList.of("-Xmx64m", "-Xms64m"));
generator.generateUnixScript(unixScript);
generator.generateWindowsScript(getBatchScript());
}
use of org.gradle.api.internal.file.FileResolver 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);
}
use of org.gradle.api.internal.file.FileResolver in project gradle by gradle.
the class DefaultScript method init.
@Override
public void init(final Object target, ServiceRegistry services) {
super.init(target, services);
this.scriptServices = services;
loggingManager = services.get(LoggingManager.class);
if (target instanceof HasScriptServices) {
HasScriptServices scriptServices = (HasScriptServices) target;
fileOperations = scriptServices.getFileOperations();
processOperations = scriptServices.getProcessOperations();
} else {
Instantiator instantiator = services.get(Instantiator.class);
FileLookup fileLookup = services.get(FileLookup.class);
FileCollectionFactory fileCollectionFactory = services.get(FileCollectionFactory.class);
File sourceFile = getScriptSource().getResource().getLocation().getFile();
if (sourceFile != null) {
FileResolver resolver = fileLookup.getFileResolver(sourceFile.getParentFile());
FileCollectionFactory fileCollectionFactoryWithBase = fileCollectionFactory.withResolver(resolver);
fileOperations = DefaultFileOperations.createSimple(resolver, fileCollectionFactoryWithBase, services);
processOperations = services.get(ExecFactory.class).forContext().withFileResolver(resolver).withFileCollectionFactory(fileCollectionFactoryWithBase).withInstantiator(instantiator).withObjectFactory(new InstantiatorBackedObjectFactory(instantiator)).build();
} else {
fileOperations = DefaultFileOperations.createSimple(fileLookup.getFileResolver(), fileCollectionFactory, services);
processOperations = services.get(ExecFactory.class);
}
}
providerFactory = services.get(ProviderFactory.class);
}
Aggregations