Search in sources :

Example 1 with DefaultProjectDescriptor

use of org.gradle.initialization.DefaultProjectDescriptor 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 StartParameter();
    File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir);
    startParameter.setGradleUserHomeDir(userHomeDir);
    NativeServices.initialize(userHomeDir);
    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(getUserHomeServices(userHomeDir), startParameter, 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);
    return project;
}
Also used : DefaultProjectDescriptorRegistry(org.gradle.initialization.DefaultProjectDescriptorRegistry) StartParameter(org.gradle.StartParameter) GradleInternal(org.gradle.api.internal.GradleInternal) IProjectFactory(org.gradle.api.internal.project.IProjectFactory) ServiceRegistryFactory(org.gradle.internal.service.scopes.ServiceRegistryFactory) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) FileResolver(org.gradle.api.internal.file.FileResolver) File(java.io.File) DefaultProjectDescriptor(org.gradle.initialization.DefaultProjectDescriptor)

Aggregations

File (java.io.File)1 StartParameter (org.gradle.StartParameter)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)1 IProjectFactory (org.gradle.api.internal.project.IProjectFactory)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 DefaultProjectDescriptor (org.gradle.initialization.DefaultProjectDescriptor)1 DefaultProjectDescriptorRegistry (org.gradle.initialization.DefaultProjectDescriptorRegistry)1 LoggingServiceRegistry (org.gradle.internal.logging.services.LoggingServiceRegistry)1 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)1 GradleUserHomeScopeServiceRegistry (org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry)1 ServiceRegistryFactory (org.gradle.internal.service.scopes.ServiceRegistryFactory)1