Search in sources :

Example 41 with ProjectComponentIdentifier

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

the class DefaultProjectLocalComponentProvider method getLocalComponentMetadata.

private LocalComponentMetadata getLocalComponentMetadata(ProjectState projectState, ProjectInternal project) {
    Module module = project.getDependencyMetaDataProvider().getModule();
    ModuleVersionIdentifier moduleVersionIdentifier = moduleIdentifierFactory.moduleWithVersion(module.getGroup(), module.getName(), module.getVersion());
    ProjectComponentIdentifier componentIdentifier = projectState.getComponentIdentifier();
    DefaultLocalComponentMetadata metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), (AttributesSchemaInternal) project.getDependencies().getAttributesSchema());
    for (ConfigurationInternal configuration : project.getConfigurations().withType(ConfigurationInternal.class)) {
        metadataBuilder.addConfiguration(metaData, configuration);
    }
    return metaData;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) Module(org.gradle.api.internal.artifacts.Module) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Example 42 with ProjectComponentIdentifier

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

the class ModuleResolveState method maybeSkipSelectionChange.

private boolean maybeSkipSelectionChange(ComponentState newSelected) {
    if (selectionChangedCounter == MAX_SELECTION_CHANGE + 1) {
        LOGGER.warn("The dependency resolution engine wasn't able to find a version of module {} which satisfied all requirements because the graph wasn't stable enough. " + "The highest version was selected in order to stabilize selection.\n" + "Features available in a stable graph like version alignment are not guaranteed in this case.", id);
    }
    boolean newSelectedIsProject = false;
    if (conflictResolution == ConflictResolution.preferProjectModules) {
        if (newSelected.getComponentId() instanceof ProjectComponentIdentifier) {
            // Keep the project selected
            newSelectedIsProject = true;
        }
    }
    Version newVersion = versionParser.transform(newSelected.getVersion());
    Version currentVersion = versionParser.transform(selected.getVersion());
    return !newSelectedIsProject && versionComparator.compare(newVersion, currentVersion) <= 0;
}
Also used : Version(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.Version) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 43 with ProjectComponentIdentifier

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

the class DefaultProjectComponentSelector method newSelector.

public static ProjectComponentSelector newSelector(Project project, ImmutableAttributes attributes, List<Capability> requestedCapabilities) {
    ProjectInternal projectInternal = (ProjectInternal) project;
    ProjectComponentIdentifier projectComponentIdentifier = projectInternal.getOwner().getComponentIdentifier();
    return new DefaultProjectComponentSelector(projectComponentIdentifier.getBuild(), projectInternal.getIdentityPath(), projectInternal.getProjectPath(), project.getName(), attributes, requestedCapabilities);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.api.internal.artifacts.DefaultProjectComponentIdentifier)

Example 44 with ProjectComponentIdentifier

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

the class IdeaPlugin method visitAllImlArtifactsInComposite.

private void visitAllImlArtifactsInComposite(ProjectInternal project, IdeaProject ideaProject, TaskDependencyResolveContext context) {
    ProjectComponentIdentifier thisProjectId = projectPathRegistry.stateFor(project).getComponentIdentifier();
    for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeProjects(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;
            }
        }
        reference.visitDependencies(context);
    }
}
Also used : 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 45 with ProjectComponentIdentifier

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

the class IncludedBuildDependencyMetadataBuilder method build.

public LocalComponentMetadata build(CompositeBuildParticipantBuildState build, ProjectComponentIdentifier projectIdentifier) {
    GradleInternal gradle = build.getMutableModel();
    LocalComponentRegistry localComponentRegistry = gradle.getServices().get(LocalComponentRegistry.class);
    DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(projectIdentifier);
    ProjectComponentIdentifier foreignIdentifier = build.idToReferenceProjectFromAnotherBuild(projectIdentifier);
    return createCompositeCopy(foreignIdentifier, originalComponent);
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Aggregations

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