Search in sources :

Example 26 with ModuleIdentifier

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

the class ModuleExclusions method forExclude.

private ExcludeSpec forExclude(ExcludeMetadata r) {
    return metadataToExcludeCache.computeIfAbsent(r, rule -> {
        // For custom ivy pattern matchers, don't inspect the rule any more deeply: this prevents us from doing smart merging later
        if (!PatternMatchers.isExactMatcher(rule.getMatcher())) {
            return factory.ivyPatternExclude(rule.getModuleId(), rule.getArtifact(), rule.getMatcher());
        }
        ModuleIdentifier moduleId = rule.getModuleId();
        IvyArtifactName artifact = rule.getArtifact();
        boolean anyOrganisation = isWildcard(moduleId.getGroup());
        boolean anyModule = isWildcard(moduleId.getName());
        // Build a strongly typed (mergeable) exclude spec for each supplied rule
        if (artifact == null) {
            if (!anyOrganisation && !anyModule) {
                return factory.moduleId(moduleId);
            } else if (!anyModule) {
                return factory.module(moduleId.getName());
            } else if (!anyOrganisation) {
                return factory.group(moduleId.getGroup());
            } else {
                return factory.everything();
            }
        } else {
            return factory.ivyPatternExclude(moduleId, artifact, rule.getMatcher());
        }
    });
}
Also used : IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 27 with ModuleIdentifier

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

the class DefaultPendingDependenciesVisitor method maybeAddAsPendingDependency.

@Override
public PendingState maybeAddAsPendingDependency(NodeState node, DependencyState dependencyState) {
    ModuleIdentifier key = dependencyState.getModuleIdentifier();
    boolean isConstraint = dependencyState.getDependency().isConstraint();
    if (!isConstraint) {
        if (markNotPending(key)) {
            return PendingState.NOT_PENDING_ACTIVATING;
        } else {
            return PendingState.NOT_PENDING;
        }
    }
    // Adding an optional dependency: see if we already have a hard dependency on the same module
    ModuleResolveState module = resolveState.getModule(key);
    boolean pending = module.isPending();
    // Already have a hard dependency, this optional dependency is not pending.
    if (!pending) {
        return PendingState.NOT_PENDING;
    }
    // No hard dependency, queue up pending dependency in case we see a hard dependency later.
    module.registerConstraintProvider(node);
    return PendingState.PENDING;
}
Also used : ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 28 with ModuleIdentifier

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

the class DefaultImmutableModuleIdentifierFactory method moduleWithVersion.

@Override
public ModuleVersionIdentifier moduleWithVersion(String group, String name, String version) {
    ModuleIdentifier mi = module(group, name);
    Map<String, ModuleVersionIdentifier> byVersion = idToVersions.get(mi);
    if (byVersion == null) {
        byVersion = idToVersions.get(mi);
        if (byVersion == null) {
            byVersion = Maps.newConcurrentMap();
            idToVersions.put(mi, byVersion);
        }
    }
    ModuleVersionIdentifier identifier = byVersion.get(version);
    if (identifier == null) {
        identifier = new DefaultModuleVersionIdentifier(mi, version);
        byVersion.put(version, identifier);
    }
    return identifier;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 29 with ModuleIdentifier

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

the class DefaultAutoAppliedPluginRegistry method createGradleEnterprisePluginRequest.

private static PluginRequestInternal createGradleEnterprisePluginRequest() {
    ModuleIdentifier moduleIdentifier = DefaultModuleIdentifier.newId(AutoAppliedGradleEnterprisePlugin.GROUP, AutoAppliedGradleEnterprisePlugin.NAME);
    ModuleVersionSelector artifact = DefaultModuleVersionSelector.newSelector(moduleIdentifier, AutoAppliedGradleEnterprisePlugin.VERSION);
    return new DefaultPluginRequest(AutoAppliedGradleEnterprisePlugin.ID, AutoAppliedGradleEnterprisePlugin.VERSION, true, null, getScriptDisplayName(), artifact);
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultPluginRequest(org.gradle.plugin.management.internal.DefaultPluginRequest) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

Example 30 with ModuleIdentifier

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

the class DependenciesAwareVersionCatalogBuilder method collectConstraints.

private void collectConstraints(DependencyConstraintSet allConstraints, Set<ModuleIdentifier> seen) {
    for (DependencyConstraint constraint : allConstraints) {
        String group = constraint.getGroup();
        String name = constraint.getName();
        ModuleIdentifier id = DefaultModuleIdentifier.newId(group, name);
        if (seen.add(id)) {
            String alias = explicitAliases.get(id);
            if (alias != null) {
                library(alias, group, name).version(into -> copyConstraint(constraint.getVersionConstraint(), into));
            } else {
                tryGenericAlias(group, name, into -> copyConstraint(constraint.getVersionConstraint(), into));
            }
        } else {
            LOGGER.warn("Duplicate entry for constraint " + group + ":" + name);
        }
    }
}
Also used : DependencyConstraint(org.gradle.api.artifacts.DependencyConstraint) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

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