Search in sources :

Example 6 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class GradleBuildBuilder method convert.

private BasicGradleProject convert(BuildState owner, ProjectState project, Map<ProjectState, BasicGradleProject> convertedProjects) {
    DefaultProjectIdentifier id = new DefaultProjectIdentifier(owner.getBuildRootDir(), project.getProjectPath().getPath());
    BasicGradleProject converted = new BasicGradleProject().setName(project.getName()).setProjectIdentifier(id);
    converted.setProjectDirectory(project.getProjectDir());
    if (project.getBuildParent() != null) {
        converted.setParent(convertedProjects.get(project.getBuildParent()));
    }
    convertedProjects.put(project, converted);
    for (ProjectState child : project.getChildProjects()) {
        converted.addChild(convert(owner, child, convertedProjects));
    }
    return converted;
}
Also used : BasicGradleProject(org.gradle.plugins.ide.internal.tooling.model.BasicGradleProject) ProjectState(org.gradle.api.internal.project.ProjectState) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 7 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class DefaultUniqueProjectNameProvider method getUniqueName.

@Override
public String getUniqueName(Project project) {
    ProjectState projectState = projectRegistry.stateFor(project);
    String uniqueName = getDeduplicatedNames().get(projectState);
    if (uniqueName != null) {
        return uniqueName;
    }
    return project.getName();
}
Also used : ProjectState(org.gradle.api.internal.project.ProjectState)

Example 8 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class TestExecutionBuildConfigurationAction method configureBuildForInternalJvmTestRequest.

private List<Test> configureBuildForInternalJvmTestRequest(GradleInternal gradle, TestExecutionRequestAction testExecutionRequest) {
    final Collection<InternalJvmTestRequest> internalJvmTestRequests = testExecutionRequest.getInternalJvmTestRequests();
    if (internalJvmTestRequests.isEmpty()) {
        return Collections.emptyList();
    }
    List<Test> tasksToExecute = new ArrayList<Test>();
    gradle.getOwner().ensureProjectsConfigured();
    for (ProjectState projectState : gradle.getOwner().getProjects().getAllProjects()) {
        projectState.ensureConfigured();
        projectState.applyToMutableState(project -> {
            final Collection<Test> testTasks = project.getTasks().withType(Test.class);
            for (Test testTask : testTasks) {
                for (InternalJvmTestRequest jvmTestRequest : internalJvmTestRequests) {
                    final TestFilter filter = testTask.getFilter();
                    filter.includeTest(jvmTestRequest.getClassName(), jvmTestRequest.getMethodName());
                }
            }
            tasksToExecute.addAll(testTasks);
        });
    }
    return tasksToExecute;
}
Also used : InternalJvmTestRequest(org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest) Test(org.gradle.api.tasks.testing.Test) ArrayList(java.util.ArrayList) ProjectState(org.gradle.api.internal.project.ProjectState) TestFilter(org.gradle.api.tasks.testing.TestFilter)

Example 9 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class DefaultBuildController method getTarget.

private ToolingModelScope getTarget(@Nullable Object target, ModelIdentifier modelIdentifier, boolean parameter) {
    if (target == null) {
        return controller.locateBuilderForDefaultTarget(modelIdentifier.getName(), parameter);
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity projectIdentity = (GradleProjectIdentity) target;
        BuildState build = findBuild(projectIdentity);
        ProjectState project = findProject(build, projectIdentity);
        return controller.locateBuilderForTarget(project, modelIdentifier.getName(), parameter);
    } else if (target instanceof GradleBuildIdentity) {
        GradleBuildIdentity buildIdentity = (GradleBuildIdentity) target;
        BuildState build = findBuild(buildIdentity);
        return controller.locateBuilderForTarget(build, modelIdentifier.getName(), parameter);
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
}
Also used : GradleBuildIdentity(org.gradle.tooling.internal.gradle.GradleBuildIdentity) GradleProjectIdentity(org.gradle.tooling.internal.gradle.GradleProjectIdentity) ProjectState(org.gradle.api.internal.project.ProjectState) BuildState(org.gradle.internal.build.BuildState)

Example 10 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class DefaultBuildToolingModelController method locateBuilderForTarget.

@Override
public ToolingModelScope locateBuilderForTarget(String modelName, boolean param) {
    // Look for a build scoped builder
    ToolingModelBuilderLookup.Builder builder = buildScopeLookup.maybeLocateForBuildScope(modelName, param, buildState);
    if (builder != null) {
        return new BuildToolingScope(builder);
    }
    // Force configuration of the build and locate builder for default project
    ProjectState targetProject = buildController.withProjectsConfigured(gradle -> gradle.getDefaultProject().getOwner());
    return doLocate(targetProject, modelName, param);
}
Also used : ToolingModelBuilderLookup(org.gradle.tooling.provider.model.internal.ToolingModelBuilderLookup) ProjectState(org.gradle.api.internal.project.ProjectState)

Aggregations

ProjectState (org.gradle.api.internal.project.ProjectState)20 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)4 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)3 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 FileResolver (org.gradle.api.internal.file.FileResolver)2 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)2 DefaultProjectDescriptor (org.gradle.initialization.DefaultProjectDescriptor)2 ProjectDescriptorRegistry (org.gradle.initialization.ProjectDescriptorRegistry)2 BuildState (org.gradle.internal.build.BuildState)2 DefaultResourceLockCoordinationService (org.gradle.internal.resources.DefaultResourceLockCoordinationService)2 ResourceLockCoordinationService (org.gradle.internal.resources.ResourceLockCoordinationService)2 BasicGradleProject (org.gradle.plugins.ide.internal.tooling.model.BasicGradleProject)2 LinkedHashMap (java.util.LinkedHashMap)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 ResolvedProjectConfiguration (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration)1 AttributesSchemaInternal (org.gradle.api.internal.attributes.AttributesSchemaInternal)1