Search in sources :

Example 36 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class DefaultConflictHandler method maybeSetReason.

private void maybeSetReason(Set<ModuleIdentifier> partifipants, ComponentResolutionState selected) {
    for (ModuleIdentifier identifier : partifipants) {
        ModuleReplacementsData.Replacement replacement = moduleReplacements.getReplacementFor(identifier);
        if (replacement != null) {
            String reason = replacement.getReason();
            ComponentSelectionDescriptorInternal moduleReplacement = ComponentSelectionReasons.SELECTED_BY_RULE.withDescription(Describables.of(identifier, "replaced with", replacement.getTarget()));
            if (reason != null) {
                moduleReplacement = moduleReplacement.withDescription(Describables.of(reason));
            }
            selected.addCause(moduleReplacement);
        }
    }
}
Also used : ModuleReplacementsData(org.gradle.api.internal.artifacts.dsl.ModuleReplacementsData) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 37 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class DefaultConflictHandler method registerCandidate.

/**
 * Registers new newModule and returns an instance of a conflict if conflict exists.
 */
@Override
@Nullable
public PotentialConflict registerCandidate(CandidateModule candidate) {
    ModuleReplacementsData.Replacement replacement = moduleReplacements.getReplacementFor(candidate.getId());
    ModuleIdentifier replacedBy = replacement == null ? null : replacement.getTarget();
    return potentialConflict(conflicts.newElement(candidate.getId(), candidate.getVersions(), replacedBy));
}
Also used : ModuleReplacementsData(org.gradle.api.internal.artifacts.dsl.ModuleReplacementsData) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) Nullable(javax.annotation.Nullable)

Example 38 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class ExternalResourceResolver method doListModuleVersions.

private void doListModuleVersions(ModuleDependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) {
    ModuleIdentifier module = dependency.getSelector().getModuleIdentifier();
    tryListingViaRule(module, result);
    if (result.hasResult() && result.isAuthoritative()) {
        return;
    }
    // TODO: Provide an abstraction for accessing resources within the same module (maven-metadata, directory listing, etc)
    // That way we can avoid passing `ivyPatterns` and `artifactPatterns` around everywhere
    ResourceVersionLister versionLister = new ResourceVersionLister(repository);
    List<ResourcePattern> completeIvyPatterns = filterComplete(this.ivyPatterns, module);
    List<ResourcePattern> completeArtifactPatterns = filterComplete(this.artifactPatterns, module);
    // Iterate over the metadata sources to see if they can provide the version list
    for (MetadataSource<?> metadataSource : metadataSources.sources()) {
        metadataSource.listModuleVersions(dependency, module, completeIvyPatterns, completeArtifactPatterns, versionLister, result);
        if (result.hasResult() && result.isAuthoritative()) {
            return;
        }
    }
    result.listed(ImmutableSet.of());
}
Also used : ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 39 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class JsonProjectDependencyRenderer method populateModulesWithChildDependencies.

private void populateModulesWithChildDependencies(RenderableDependency dependency, Set<ComponentIdentifier> visited, Set<ModuleIdentifier> modules) {
    for (RenderableDependency childDependency : dependency.getChildren()) {
        ModuleIdentifier moduleId = getModuleIdentifier(childDependency);
        if (moduleId == null) {
            continue;
        }
        modules.add(moduleId);
        boolean alreadyVisited = !visited.add((ComponentIdentifier) childDependency.getId());
        if (!alreadyVisited) {
            populateModulesWithChildDependencies(childDependency, visited, modules);
        }
    }
}
Also used : RenderableDependency(org.gradle.api.tasks.diagnostics.internal.graph.nodes.RenderableDependency) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 40 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class ComponentModuleMetadataContainer method module.

public ComponentModuleMetadataDetails module(final Object sourceModule) {
    final NotationParser<Object, ModuleIdentifier> parser = parser(moduleIdentifierFactory);
    final ModuleIdentifier source = parser.parseNotation(sourceModule);
    return new ComponentModuleMetadataDetails() {

        @Override
        public void replacedBy(Object moduleNotation) {
            replacedBy(moduleNotation, null);
        }

        @Override
        public void replacedBy(final Object targetModule, @Nullable String reason) {
            ModuleIdentifier target = parser.parseNotation(targetModule);
            detectCycles(replacements, source, target);
            replacements.put(source, new Replacement(target, reason));
            targets.add(target);
        }

        @Override
        public ModuleIdentifier getId() {
            return source;
        }

        @Override
        public ModuleIdentifier getReplacedBy() {
            return unwrap(replacements.get(source));
        }
    };
}
Also used : ComponentModuleMetadataDetails(org.gradle.api.artifacts.ComponentModuleMetadataDetails) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) Nullable(javax.annotation.Nullable)

Aggregations

ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)46 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)8 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)7 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 ExcludeSpec (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec)4 GroupExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupExclude)4 GroupSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupSetExclude)4 ModuleExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleExclude)4 ModuleIdExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude)4 ModuleIdSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude)4 ModuleSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleSetExclude)4 LinkedHashSet (java.util.LinkedHashSet)3 Action (org.gradle.api.Action)3 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)3 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)3 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3