Search in sources :

Example 51 with ProjectInternal

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

the class EclipseModelBuilder method buildAll.

@Override
public DefaultEclipseProject buildAll(String modelName, Project project) {
    boolean includeTasks = modelName.equals("org.gradle.tooling.model.eclipse.EclipseProject");
    tasksFactory = new TasksFactory(includeTasks);
    projectDependenciesOnly = modelName.equals("org.gradle.tooling.model.eclipse.HierarchicalEclipseProject");
    currentProject = project;
    eclipseProjects = Lists.newArrayList();
    ProjectInternal root = (ProjectInternal) project.getRootProject();
    rootGradleProject = gradleProjectBuilder.buildAll(project);
    tasksFactory.collectTasks(root);
    applyEclipsePlugin(root, new ArrayList<>());
    deduplicateProjectNames(root);
    buildHierarchy(root);
    populate(root);
    return result;
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 52 with ProjectInternal

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

the class IdeaModule method resolveDependencies.

/**
 * Resolves and returns the module's dependencies.
 *
 * @return dependencies
 */
public Set<Dependency> resolveDependencies() {
    ProjectInternal projectInternal = (ProjectInternal) project;
    IdeArtifactRegistry ideArtifactRegistry = projectInternal.getServices().get(IdeArtifactRegistry.class);
    IdeaDependenciesProvider ideaDependenciesProvider = new IdeaDependenciesProvider(projectInternal, ideArtifactRegistry, new DefaultGradleApiSourcesResolver(projectInternal.newDetachedResolver()));
    return ideaDependenciesProvider.provide(this);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) IdeArtifactRegistry(org.gradle.plugins.ide.internal.IdeArtifactRegistry) IdeaDependenciesProvider(org.gradle.plugins.ide.idea.model.internal.IdeaDependenciesProvider) DefaultGradleApiSourcesResolver(org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver)

Example 53 with ProjectInternal

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

the class BuildInitPlugin method apply.

@Override
public void apply(Project project) {
    if (project.getParent() == null) {
        project.getTasks().register("init", InitBuild.class, initBuild -> {
            initBuild.setGroup("Build Setup");
            initBuild.setDescription("Initializes a new Gradle build.");
            RelativeFilePathResolver resolver = ((ProjectInternal) project).getFileResolver();
            File buildFile = project.getBuildFile();
            FileDetails buildFileDetails = FileDetails.of(buildFile, resolver);
            File settingsFile = ((ProjectInternal) project).getGradle().getSettings().getSettingsScript().getResource().getLocation().getFile();
            FileDetails settingsFileDetails = FileDetails.of(settingsFile, resolver);
            initBuild.onlyIf(new InitBuildOnlyIfSpec(buildFileDetails, settingsFileDetails, initBuild.getLogger()));
            initBuild.dependsOn(new InitBuildDependsOnCallable(buildFileDetails, settingsFileDetails));
            ProjectInternal.DetachedResolver detachedResolver = ((ProjectInternal) project).newDetachedResolver();
            initBuild.getProjectLayoutRegistry().getBuildConverter().configureClasspath(detachedResolver, project.getObjects());
            initBuild.getInsecureProtocol().convention(InsecureProtocolOption.WARN);
        });
    }
}
Also used : RelativeFilePathResolver(org.gradle.internal.file.RelativeFilePathResolver) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) File(java.io.File)

Example 54 with ProjectInternal

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

the class DefaultTaskContainer method findByPath.

@Override
public Task findByPath(String path) {
    if (Strings.isNullOrEmpty(path)) {
        throw new InvalidUserDataException("A path must be specified!");
    }
    if (!path.contains(Project.PATH_SEPARATOR)) {
        return findByName(path);
    }
    String projectPath = StringUtils.substringBeforeLast(path, Project.PATH_SEPARATOR);
    ProjectInternal project = this.project.findProject(Strings.isNullOrEmpty(projectPath) ? Project.PATH_SEPARATOR : projectPath);
    if (project == null) {
        return null;
    }
    project.getOwner().ensureTasksDiscovered();
    return project.getTasks().findByName(StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR));
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 55 with ProjectInternal

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

the class DefaultTaskSelector method getFilter.

public Spec<Task> getFilter(String path) {
    final ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, gradle.getDefaultProject());
    if (!taskPath.isQualified()) {
        ProjectInternal targetProject = taskPath.getProject();
        configurer.configure(targetProject);
        if (taskNameResolver.tryFindUnqualifiedTaskCheaply(taskPath.getTaskName(), taskPath.getProject())) {
            // An exact match in the target project - can just filter tasks by path to avoid configuring sub-projects at this point
            return new TaskPathSpec(targetProject, taskPath.getTaskName());
        }
    }
    final Set<Task> selectedTasks = getSelection(path, gradle.getDefaultProject()).getTasks();
    return new Spec<Task>() {

        @Override
        public boolean isSatisfiedBy(Task element) {
            return !selectedTasks.contains(element);
        }
    };
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) Task(org.gradle.api.Task) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Spec(org.gradle.api.specs.Spec)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)58 File (java.io.File)13 Project (org.gradle.api.Project)11 Task (org.gradle.api.Task)6 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)6 Inject (javax.inject.Inject)5 Plugin (org.gradle.api.Plugin)5 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)5 Map (java.util.Map)4 Configuration (org.gradle.api.artifacts.Configuration)4 FileResolver (org.gradle.api.internal.file.FileResolver)4 Lists (com.google.common.collect.Lists)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Callable (java.util.concurrent.Callable)3 Collectors (java.util.stream.Collectors)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3