Search in sources :

Example 41 with ModuleIdentifier

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

the class DefaultComponentMetadataHandler method createSpecRuleActionForModule.

private SpecRuleAction<? super ComponentMetadataDetails> createSpecRuleActionForModule(Object id, RuleAction<? super ComponentMetadataDetails> ruleAction) {
    ModuleIdentifier moduleIdentifier;
    try {
        moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
    } catch (UnsupportedNotationException e) {
        throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
    }
    Spec<ComponentMetadataDetails> spec = new ComponentMetadataDetailsMatchingSpec(moduleIdentifier);
    return new SpecRuleAction<>(ruleAction, spec);
}
Also used : InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) SpecRuleAction(org.gradle.internal.rules.SpecRuleAction) UnsupportedNotationException(org.gradle.internal.typeconversion.UnsupportedNotationException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ComponentMetadataDetails(org.gradle.api.artifacts.ComponentMetadataDetails)

Example 42 with ModuleIdentifier

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

the class DefaultComponentMetadataHandler method createModuleSpecConfigurableRule.

private SpecConfigurableRule createModuleSpecConfigurableRule(Object id, ConfigurableRule<ComponentMetadataContext> instantiatingAction) {
    ModuleIdentifier moduleIdentifier;
    try {
        moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
    } catch (UnsupportedNotationException e) {
        throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
    }
    Spec<ModuleVersionIdentifier> spec = new ModuleVersionIdentifierSpec(moduleIdentifier);
    return new SpecConfigurableRule(instantiatingAction, spec);
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) UnsupportedNotationException(org.gradle.internal.typeconversion.UnsupportedNotationException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 43 with ModuleIdentifier

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

the class CompositeBuildDependencySubstitutions method getReplacementFor.

private ProjectComponentIdentifier getReplacementFor(ModuleComponentSelector selector) {
    ModuleIdentifier candidateId = selector.getModuleIdentifier();
    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 '{}' as substitute for module '{}'.", match, candidateId);
        return match;
    }
    throw new ModuleVersionResolveException(selector, () -> {
        SortedSet<String> sortedProjects = providingProjects.stream().map(ComponentIdentifier::getDisplayName).collect(Collectors.toCollection(TreeSet::new));
        return String.format("Module version '%s' is not unique in composite: can be provided by %s.", selector.getDisplayName(), sortedProjects);
    });
}
Also used : ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 44 with ModuleIdentifier

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

the class DefaultImmutableModuleIdentifierFactory method module.

@Override
public ModuleIdentifier module(String group, String name) {
    Map<String, ModuleIdentifier> byName = groupIdToModules.get(group);
    if (byName == null) {
        byName = groupIdToModules.computeIfAbsent(group, k -> Maps.newConcurrentMap());
    }
    ModuleIdentifier moduleIdentifier = byName.get(name);
    if (moduleIdentifier == null) {
        moduleIdentifier = DefaultModuleIdentifier.newId(group, name);
        byName.put(name, moduleIdentifier);
    }
    return moduleIdentifier;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) Map(java.util.Map) Maps(com.google.common.collect.Maps) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 45 with ModuleIdentifier

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

the class DefaultImmutableModuleIdentifierFactory method moduleWithVersion.

@Override
public ModuleVersionIdentifier moduleWithVersion(ModuleIdentifier mi, String version) {
    Map<String, ModuleVersionIdentifier> byVersion = idToVersions.get(mi);
    if (byVersion == null) {
        byVersion = idToVersions.computeIfAbsent(mi, k -> Maps.newConcurrentMap());
    }
    ModuleVersionIdentifier identifier = byVersion.get(version);
    if (identifier == null) {
        identifier = DefaultModuleVersionIdentifier.newId(mi, version);
        byVersion.put(version, identifier);
    }
    return identifier;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) Map(java.util.Map) Maps(com.google.common.collect.Maps)

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