Search in sources :

Example 1 with ModuleRevisionId

use of org.apache.ivy.core.module.id.ModuleRevisionId in project gradle by gradle.

the class AbstractMavenResolver method publish.

public void publish(IvyModulePublishMetadata moduleVersion) {
    for (IvyModuleArtifactPublishMetadata artifactMetadata : moduleVersion.getArtifacts()) {
        IvyArtifactName artifact = artifactMetadata.getArtifactName();
        ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(artifactMetadata.getId().getComponentIdentifier());
        Map<String, String> attributes = Collections.singletonMap("classifier", artifact.getClassifier());
        Artifact ivyArtifact = new DefaultArtifact(moduleRevisionId, null, artifact.getName(), artifact.getType(), artifact.getExtension(), attributes);
        collectArtifact(ivyArtifact, artifactMetadata.getFile());
    }
    publish();
}
Also used : IvyModuleArtifactPublishMetadata(org.gradle.internal.component.external.model.IvyModuleArtifactPublishMetadata) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact)

Example 2 with ModuleRevisionId

use of org.apache.ivy.core.module.id.ModuleRevisionId in project gradle by gradle.

the class IvyModuleDescriptorConverter method addDependency.

private void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
    ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
    ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());
    ListMultimap<String, String> configMappings = ArrayListMultimap.create();
    for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
        configMappings.putAll(entry.getKey(), entry.getValue());
    }
    List<Artifact> artifacts = Lists.newArrayList();
    for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
        IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
        artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
    }
    List<Exclude> excludes = Lists.newArrayList();
    for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
        excludes.add(forIvyExclude(excludeRule));
    }
    result.add(new IvyDependencyMetadata(requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) Exclude(org.gradle.internal.component.model.Exclude) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) IvyDependencyMetadata(org.gradle.internal.component.external.model.IvyDependencyMetadata) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) Artifact(org.gradle.internal.component.external.descriptor.Artifact) DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) List(java.util.List) Map(java.util.Map)

Example 3 with ModuleRevisionId

use of org.apache.ivy.core.module.id.ModuleRevisionId in project lucene-solr by apache.

the class IvyNodeElementAdapter method adapt.

/**
   * Adapt all dependencies and evictions from the ResolveReport.
   * @return the root node adapted from the ResolveReport
   */
public static IvyNodeElement adapt(ResolveReport report) {
    Map<ModuleRevisionId, IvyNodeElement> resolvedNodes = new HashMap<>();
    IvyNodeElement root = new IvyNodeElement();
    root.setModuleRevisionId(report.getModuleDescriptor().getModuleRevisionId());
    resolvedNodes.put(report.getModuleDescriptor().getModuleRevisionId(), root);
    @SuppressWarnings("unchecked") List<IvyNode> dependencies = report.getDependencies();
    // First pass - build the map of resolved nodes by revision id
    for (Iterator<IvyNode> iter = dependencies.iterator(); iter.hasNext(); ) {
        IvyNode node = iter.next();
        if (node.getAllEvictingNodes() != null) {
            // We map them as evictions rather than dependencies.
            continue;
        }
        IvyNodeElement nodeElement = new IvyNodeElement();
        nodeElement.setModuleRevisionId(node.getResolvedId());
        resolvedNodes.put(node.getResolvedId(), nodeElement);
    }
    // Second pass - establish relationships between the resolved nodes
    for (Iterator<IvyNode> iter = dependencies.iterator(); iter.hasNext(); ) {
        IvyNode node = iter.next();
        if (node.getAllEvictingNodes() != null) {
            // see note above
            continue;
        }
        IvyNodeElement nodeElement = resolvedNodes.get(node.getResolvedId());
        IvyNodeCallers.Caller[] callers = node.getAllRealCallers();
        for (int i = 0; i < callers.length; i++) {
            IvyNodeElement caller = resolvedNodes.get(callers[i].getModuleRevisionId());
            if (caller != null) {
                nodeElement.addCaller(caller);
                nodeElement.setCallerConfigurations(caller, callers[i].getCallerConfigurations());
            }
        }
    }
    IvyNode[] evictions = report.getEvictedNodes();
    for (int i = 0; i < evictions.length; i++) {
        IvyNode eviction = evictions[i];
        IvyNodeElement evictionElement = new IvyNodeElement();
        evictionElement.setModuleRevisionId(eviction.getResolvedId());
        evictionElement.setEvicted(true);
        IvyNodeCallers.Caller[] callers = eviction.getAllCallers();
        for (int j = 0; j < callers.length; j++) {
            IvyNodeElement caller = resolvedNodes.get(callers[j].getModuleRevisionId());
            if (caller != null) {
                evictionElement.addCaller(caller);
                evictionElement.setCallerConfigurations(caller, callers[j].getCallerConfigurations());
            }
        }
    }
    // Recursively set depth starting at root
    root.setDepth(0);
    findConflictsBeneathNode(root);
    return root;
}
Also used : HashMap(java.util.HashMap) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 4 with ModuleRevisionId

use of org.apache.ivy.core.module.id.ModuleRevisionId in project gradle by gradle.

the class IvyModuleDescriptorConverter method forIvyModuleDescriptor.

public ModuleDescriptorState forIvyModuleDescriptor(ModuleDescriptor ivyDescriptor) {
    ModuleRevisionId moduleRevisionId = ivyDescriptor.getModuleRevisionId();
    ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision());
    MutableModuleDescriptorState state = new MutableModuleDescriptorState(componentIdentifier, ivyDescriptor.getStatus(), ivyDescriptor.isDefault());
    state.setBranch(moduleRevisionId.getBranch());
    state.setDescription(ivyDescriptor.getDescription());
    state.setPublicationDate(ivyDescriptor.getPublicationDate());
    Map<NamespaceId, String> extraInfo = Cast.uncheckedCast(ivyDescriptor.getExtraInfo());
    state.getExtraInfo().putAll(extraInfo);
    for (ExcludeRule excludeRule : ivyDescriptor.getAllExcludeRules()) {
        addExcludeRule(state, excludeRule);
    }
    return state;
}
Also used : MutableModuleDescriptorState(org.gradle.internal.component.external.descriptor.MutableModuleDescriptorState) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) NamespaceId(org.gradle.api.internal.artifacts.ivyservice.NamespaceId) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule)

Aggregations

ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)4 ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Artifact (org.apache.ivy.core.module.descriptor.Artifact)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)1 IvyNode (org.apache.ivy.core.resolve.IvyNode)1 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)1 NamespaceId (org.gradle.api.internal.artifacts.ivyservice.NamespaceId)1 Artifact (org.gradle.internal.component.external.descriptor.Artifact)1 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)1 MutableModuleDescriptorState (org.gradle.internal.component.external.descriptor.MutableModuleDescriptorState)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 IvyDependencyMetadata (org.gradle.internal.component.external.model.IvyDependencyMetadata)1