use of org.gradle.initialization.DefaultProjectDescriptorRegistry in project gradle by gradle.
the class ProjectBuilderImpl method createProject.
public Project createProject(String name, File inputProjectDir, File gradleUserHomeDir) {
File projectDir = prepareProjectDir(inputProjectDir);
final File homeDir = new File(projectDir, "gradleHome");
StartParameter startParameter = new StartParameterInternal();
File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir);
startParameter.setGradleUserHomeDir(userHomeDir);
NativeServices.initialize(userHomeDir);
BuildRequestMetaData buildRequestMetaData = new DefaultBuildRequestMetaData(Time.currentTimeMillis());
CrossBuildSessionScopeServices crossBuildSessionScopeServices = new CrossBuildSessionScopeServices(getGlobalServices(), startParameter);
ServiceRegistry userHomeServices = getUserHomeServices(userHomeDir);
BuildSessionScopeServices buildSessionScopeServices = new BuildSessionScopeServices(userHomeServices, crossBuildSessionScopeServices, startParameter, buildRequestMetaData, ClassPath.EMPTY);
BuildTreeScopeServices buildTreeScopeServices = new BuildTreeScopeServices(buildSessionScopeServices);
ServiceRegistry topLevelRegistry = new TestBuildScopeServices(buildTreeScopeServices, homeDir);
GradleInternal gradle = CLASS_GENERATOR.newInstance(DefaultGradle.class, null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));
DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(), topLevelRegistry.get(FileResolver.class));
ClassLoaderScope baseScope = gradle.getClassLoaderScope();
ClassLoaderScope rootProjectScope = baseScope.createChild("root-project");
ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);
gradle.setRootProject(project);
gradle.setDefaultProject(project);
// Take a root worker lease, it won't ever be released as ProjectBuilder has no lifecycle
ResourceLockCoordinationService coordinationService = topLevelRegistry.get(ResourceLockCoordinationService.class);
WorkerLeaseService workerLeaseService = topLevelRegistry.get(WorkerLeaseService.class);
coordinationService.withStateLock(DefaultResourceLockCoordinationService.lock(workerLeaseService.getWorkerLease()));
return project;
}
Aggregations