Search in sources :

Example 26 with ProjectComponentIdentifier

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

the class CompositeBuildDependencySubstitutions method getReplacementFor.

private ProjectComponentIdentifier getReplacementFor(ModuleComponentSelector selector) {
    ModuleIdentifier candidateId = moduleIdentifierFactory.module(selector.getGroup(), selector.getModule());
    Collection<ProjectComponentIdentifier> providingProjects = replacementMap.get(candidateId);
    if (providingProjects.isEmpty()) {
        LOGGER.debug("Found no composite build substitute for module '" + candidateId + "'.");
        return null;
    }
    if (providingProjects.size() == 1) {
        ProjectComponentIdentifier match = providingProjects.iterator().next();
        LOGGER.info("Found project '" + match + "' as substitute for module '" + candidateId + "'.");
        return match;
    }
    SortedSet<String> sortedProjects = Sets.newTreeSet(CollectionUtils.collect(providingProjects, new Transformer<String, ProjectComponentIdentifier>() {

        @Override
        public String transform(ProjectComponentIdentifier projectComponentIdentifier) {
            return projectComponentIdentifier.getDisplayName();
        }
    }));
    String failureMessage = String.format("Module version '%s' is not unique in composite: can be provided by %s.", selector.getDisplayName(), sortedProjects);
    throw new ModuleVersionResolveException(selector, failureMessage);
}
Also used : Transformer(org.gradle.api.Transformer) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 27 with ProjectComponentIdentifier

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

the class DefaultIncludedBuild method registerProject.

private void registerProject(Set<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>> availableModules, ProjectInternal project) {
    LocalComponentRegistry localComponentRegistry = project.getServices().get(LocalComponentRegistry.class);
    ProjectComponentIdentifier originalIdentifier = newProjectId(project);
    DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(originalIdentifier);
    ProjectComponentIdentifier componentIdentifier = idForProjectInThisBuild(project.getPath());
    ModuleVersionIdentifier moduleId = originalComponent.getModuleVersionId();
    LOGGER.info("Registering " + project + " in composite build. Will substitute for module '" + moduleId.getModule() + "'.");
    availableModules.add(Pair.of(moduleId, componentIdentifier));
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Example 28 with ProjectComponentIdentifier

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

the class IncludedBuildDependencyMetadataBuilder method build.

public Map<ProjectComponentIdentifier, RegisteredProject> build(IncludedBuildInternal build) {
    Map<ProjectComponentIdentifier, RegisteredProject> registeredProjects = Maps.newHashMap();
    Gradle gradle = build.getConfiguredBuild();
    for (Project project : gradle.getRootProject().getAllprojects()) {
        registerProject(registeredProjects, build, (ProjectInternal) project);
    }
    return registeredProjects;
}
Also used : Project(org.gradle.api.Project) Gradle(org.gradle.api.invocation.Gradle) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

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