Search in sources :

Example 16 with ProjectComponentIdentifier

use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.

the class IdeaPlugin method allImlArtifactsInComposite.

private List<TaskDependency> allImlArtifactsInComposite(ProjectInternal project, IdeaProject ideaProject) {
    List<TaskDependency> dependencies = Lists.newArrayList();
    ProjectComponentIdentifier thisProjectId = projectPathRegistry.getProjectComponentIdentifier(project.getIdentityPath());
    for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeArtifactMetadata(IdeaModuleMetadata.class)) {
        BuildIdentifier otherBuildId = reference.getOwningProject().getBuild();
        if (thisProjectId.getBuild().equals(otherBuildId)) {
            // IDEA Module for project in current build: don't include any module that has been excluded from project
            boolean found = false;
            for (IdeaModule ideaModule : ideaProject.getModules()) {
                if (reference.get().getFile().equals(ideaModule.getOutputFile())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                continue;
            }
        }
        dependencies.add(reference.getBuildDependencies());
    }
    return dependencies;
}
Also used : TaskDependency(org.gradle.api.tasks.TaskDependency) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) IdeaModuleMetadata(org.gradle.plugins.ide.idea.internal.IdeaModuleMetadata) IdeArtifactRegistry(org.gradle.plugins.ide.internal.IdeArtifactRegistry) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 17 with ProjectComponentIdentifier

use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.

the class IdeaProject method configureModulePaths.

private void configureModulePaths(Project xmlProject) {
    ProjectComponentIdentifier thisProjectId = projectPathRegistry.getProjectComponentIdentifier(((ProjectInternal) project).getIdentityPath());
    for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeArtifactMetadata(IdeaModuleMetadata.class)) {
        BuildIdentifier otherBuildId = reference.getOwningProject().getBuild();
        if (thisProjectId.getBuild().equals(otherBuildId)) {
            // IDEA Module for project in current build: handled via `modules` model elements.
            continue;
        }
        xmlProject.addModulePath(reference.get().getFile());
    }
}
Also used : IdeaModuleMetadata(org.gradle.plugins.ide.idea.internal.IdeaModuleMetadata) IdeArtifactRegistry(org.gradle.plugins.ide.internal.IdeArtifactRegistry) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 18 with ProjectComponentIdentifier

use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.

the class DefaultIdeArtifactRegistry method registerIdeArtifact.

@Override
public void registerIdeArtifact(final IdeProjectMetadata ideProjectMetadata) {
    ProjectComponentIdentifier projectId = newProjectId(buildIdentity.getCurrentBuild(), domainObjectContext.getProjectPath().getPath());
    store.put(projectId, ideProjectMetadata);
}
Also used : ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 19 with ProjectComponentIdentifier

use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.

the class CompositeBuildDependencySubstitutions method execute.

@Override
public void execute(DependencySubstitution sub) {
    DependencySubstitutionInternal dependencySubstitution = (DependencySubstitutionInternal) sub;
    // Use the result of previous rules as the input for dependency substitution
    ComponentSelector requested = dependencySubstitution.getTarget();
    if (requested instanceof ModuleComponentSelector) {
        ModuleComponentSelector selector = (ModuleComponentSelector) requested;
        ProjectComponentIdentifier replacement = getReplacementFor(selector);
        if (replacement != null) {
            dependencySubstitution.useTarget(DefaultProjectComponentSelector.newSelector(replacement), VersionSelectionReasons.COMPOSITE_BUILD);
        }
    }
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DependencySubstitutionInternal(org.gradle.api.internal.artifacts.DependencySubstitutionInternal) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 20 with ProjectComponentIdentifier

use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.

the class DefaultIdeDependencyResolver method getIdeProjectDependencies.

/**
     * Gets IDE project dependencies.
     *
     * @param configuration Configuration
     * @param project Project
     * @return IDE project dependencies
     */
public List<IdeProjectDependency> getIdeProjectDependencies(Configuration configuration, Project project) {
    ResolutionResult result = getIncomingResolutionResult(configuration);
    final Set<ResolvedComponentResult> projectComponents = CollectionUtils.filter(result.getAllComponents(), new Spec<ResolvedComponentResult>() {

        @Override
        public boolean isSatisfiedBy(ResolvedComponentResult element) {
            return element.getId() instanceof ProjectComponentIdentifier;
        }
    });
    List<IdeProjectDependency> ideProjectDependencies = new ArrayList<IdeProjectDependency>();
    ProjectComponentIdentifier thisProjectId = DefaultProjectComponentIdentifier.newProjectId(project);
    for (ResolvedComponentResult projectComponent : projectComponents) {
        ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) projectComponent.getId();
        if (thisProjectId.equals(projectId)) {
            continue;
        }
        if (!projectId.getBuild().isCurrentBuild()) {
            // Don't have access to the ProjectInstance: we can't use it to determine the name.
            ideProjectDependencies.add(new IdeProjectDependency(projectId));
        } else {
            Project resolvedProject = project.project(projectId.getProjectPath());
            ideProjectDependencies.add(new IdeProjectDependency(projectId, resolvedProject.getName()));
        }
    }
    return ideProjectDependencies;
}
Also used : IdeProjectDependency(org.gradle.plugins.ide.internal.resolver.model.IdeProjectDependency) Project(org.gradle.api.Project) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) ArrayList(java.util.ArrayList) ResolvedComponentResult(org.gradle.api.artifacts.result.ResolvedComponentResult) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Aggregations

ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)28 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)7 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)6 File (java.io.File)5 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)5 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)4 ResolvedComponentResult (org.gradle.api.artifacts.result.ResolvedComponentResult)4 LocalComponentRegistry (org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry)4 DefaultLocalComponentMetadata (org.gradle.internal.component.local.model.DefaultLocalComponentMetadata)4 DefaultProjectComponentIdentifier (org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)4 Project (org.gradle.api.Project)3 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)3 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)3 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)3 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)3 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)3 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)3 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)3 ArrayList (java.util.ArrayList)2