Package org.apache.ivy.core.module.descriptor

Examples of org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor


    private void assertDependencyDescriptorHasArtifacts(DefaultDependencyDescriptor dependencyDescriptor) {
        List<DependencyArtifactDescriptor> artifactDescriptors = WrapUtil.toList(dependencyDescriptor.getDependencyArtifacts(TEST_CONF));
        assertThat(artifactDescriptors.size(), equalTo(2));

       
        DependencyArtifactDescriptor artifactDescriptorWithoutClassifier = findDescriptor(artifactDescriptors, artifact);
        assertEquals(new HashMap(), artifactDescriptorWithoutClassifier.getExtraAttributes());
        assertEquals(null, artifactDescriptorWithoutClassifier.getUrl());
        compareArtifacts(artifact, artifactDescriptorWithoutClassifier);
        assertEquals(artifact.getType(), artifactDescriptorWithoutClassifier.getExt());

        DependencyArtifactDescriptor artifactDescriptorWithClassifierAndConfs = findDescriptor(artifactDescriptors, artifactWithClassifiers);
        assertEquals(WrapUtil.toMap(Dependency.CLASSIFIER, artifactWithClassifiers.getClassifier()), artifactDescriptorWithClassifierAndConfs.getQualifiedExtraAttributes());
        compareArtifacts(artifactWithClassifiers, artifactDescriptorWithClassifierAndConfs);
        assertEquals(artifactWithClassifiers.getExtension(), artifactDescriptorWithClassifierAndConfs.getExt());
        try {
            assertEquals(new URL(artifactWithClassifiers.getUrl()), artifactDescriptorWithClassifierAndConfs.getUrl());
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here


        return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
    }

    private void addArtifactsFromOwnUsage(Set artifacts, Set dependencyArtifacts) {
        for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
            DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
            artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(), dad
                    .getUrl(), dad.getQualifiedExtraAttributes()));
        }
    }
View Full Code Here

        for (Iterator iterator = mergedUsages.values().iterator(); iterator.hasNext();) {
            IvyNodeUsage usage = (IvyNodeUsage) iterator.next();
            Set mergedDependencyArtifacts = usage.getDependencyArtifactsSet(rootModuleConf);
            if (mergedDependencyArtifacts != null) {
                for (Iterator it = mergedDependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                    Map extraAttributes = new HashMap(dad.getQualifiedExtraAttributes());
                    MDArtifact artifact = new MDArtifact(md, dad.getName(), dad.getType(),
                            dad.getExt(), dad.getUrl(), extraAttributes);

                    if (!artifacts.contains(artifact)) {
                        // this is later used to know that this is a merged artifact
                        extraAttributes.put("ivy:merged", dad.getDependencyDescriptor()
                                .getParentRevisionId() + " -> " + usage.getNode().getId());
                        artifacts.add(artifact);
                    }
                }
            }
View Full Code Here

        return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
    }

    private void addArtifactsFromOwnUsage(Set artifacts, Set dependencyArtifacts) {
        for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
            DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
            artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                    dad.getUrl(), dad.getQualifiedExtraAttributes()));
        }
    }
View Full Code Here

        for (Iterator iterator = mergedUsages.values().iterator(); iterator.hasNext();) {
            IvyNodeUsage usage = (IvyNodeUsage) iterator.next();
            Set mergedDependencyArtifacts = usage.getDependencyArtifactsSet(rootModuleConf);
            if (mergedDependencyArtifacts != null) {
                for (Iterator it = mergedDependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                    Map extraAttributes = new HashMap(dad.getQualifiedExtraAttributes());
                    // this is later used to know that this is a merged artifact
                    extraAttributes.put("ivy:merged",
                        dad.getDependencyDescriptor().getParentRevisionId()
                        + " -> " + usage.getNode().getId());
                    artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                        dad.getUrl(), extraAttributes));
                }
            }
        }
    }
View Full Code Here

            // moreover, we have dependency artifacts description
            // these descritions are thus used as if they were declared in the module
            // descriptor. If one is not really present, the error will be raised
            // at download time
            for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(), dad
                        .getUrl(), dad.getExtraAttributes()));
            }
        } else {
            Set includes = (Set) dependencyIncludes.get(rootModuleConf);

            if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
                    && (includes == null || includes.isEmpty())) {
                // no artifacts / includes: we get all artifacts as defined by the descriptor
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    artifacts.addAll(Arrays.asList(md.getArtifacts(conf)));
                }
            } else {
                // we have to get only artifacts listed as "includes"

                // first we get all artifacts as defined by the module descriptor
                // and classify them by artifact id
                Map allArtifacts = new HashMap();
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    Artifact[] arts = md.getArtifacts(conf);
                    for (int i = 0; i < arts.length; i++) {
                        allArtifacts.put(arts[i].getId().getArtifactId(), arts[i]);
                    }
                }

                // now we add caller defined ones
                for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                    artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                            dad.getUrl(), dad.getExtraAttributes()));
                }

                // and now we filter according to include rules
                for (Iterator it = includes.iterator(); it.hasNext();) {
                    IncludeRule dad = (IncludeRule) it.next();
                    Collection arts = findArtifactsMatching(dad, allArtifacts);
                    if (arts.isEmpty()) {
                        Message.error("a required artifact is not listed by module descriptor: "
                                + dad.getId());
                        // we remove it from required list to prevent message to be displayed more
                        // than once
                        it.remove();
                    } else {
                        Message.debug(this + " in " + rootModuleConf + ": including " + arts);
View Full Code Here

            // moreover, we have dependency artifacts description
            // these descritions are thus used as if they were declared in the module
            // descriptor. If one is not really present, the error will be raised
            // at download time
            for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(), dad
                        .getUrl(), dad.getExtraAttributes()));
            }
        } else {
            Set includes = (Set) dependencyIncludes.get(rootModuleConf);

            if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
                    && (includes == null || includes.isEmpty())) {
                // no artifacts / includes: we get all artifacts as defined by the descriptor
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    artifacts.addAll(Arrays.asList(md.getArtifacts(conf)));
                }
            } else {
                // we have to get only artifacts listed as "includes"

                // first we get all artifacts as defined by the module descriptor
                // and classify them by artifact id
                Map allArtifacts = new HashMap();
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    Artifact[] arts = md.getArtifacts(conf);
                    for (int i = 0; i < arts.length; i++) {
                        allArtifacts.put(arts[i].getId().getArtifactId(), arts[i]);
                    }
                }

                // now we add caller defined ones
                for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                    artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                            dad.getUrl(), dad.getExtraAttributes()));
                }

                // and now we filter according to include rules
                for (Iterator it = includes.iterator(); it.hasNext();) {
                    IncludeRule dad = (IncludeRule) it.next();
                    Collection arts = findArtifactsMatching(dad, allArtifacts);
                    if (arts.isEmpty()) {
                        Message.error("a required artifact is not listed by module descriptor: "
                                + dad.getId());
                        // we remove it from required list to prevent message to be displayed more
                        // than once
                        it.remove();
                    } else {
                        Message.debug(this + " in " + rootModuleConf + ": including " + arts);
View Full Code Here

        return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
    }

    private void addArtifactsFromOwnUsage(Set artifacts, Set dependencyArtifacts) {
        for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
            DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
            artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                    dad.getUrl(), dad.getQualifiedExtraAttributes()));
        }
    }
View Full Code Here

        for (Iterator iterator = mergedUsages.values().iterator(); iterator.hasNext();) {
            IvyNodeUsage usage = (IvyNodeUsage) iterator.next();
            Set mergedDependencyArtifacts = usage.getDependencyArtifactsSet(rootModuleConf);
            if (mergedDependencyArtifacts != null) {
                for (Iterator it = mergedDependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
                    Map extraAttributes = new HashMap(dad.getQualifiedExtraAttributes());
                    MDArtifact artifact = new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
                            dad.getUrl(), extraAttributes);
                   
                    if (!artifacts.contains(artifact)) {
                        // this is later used to know that this is a merged artifact
                        extraAttributes.put("ivy:merged",
                            dad.getDependencyDescriptor().getParentRevisionId()
                            + " -> " + usage.getNode().getId());
                        artifacts.add(artifact);
                    }
                }
            }
View Full Code Here

            // moreover, we have dependency artifacts description
            // these descritions are thus used as if they were declared in the module
            // descriptor. If one is not really present, the error will be raised
            // at download time
            for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
                artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt(), dad.getUrl(), dad.getExtraAttributes()));
            }
        } else {
            Set includes = (Set)_dependencyIncludes.get(rootModuleConf);
           
            if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
                && (includes == null || includes.isEmpty())) {
                // no artifacts / includes: we get all artifacts as defined by the descriptor
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    artifacts.addAll(Arrays.asList(_md.getArtifacts(conf)));
                }
            } else {
              // we have to get only artifacts listed as "includes"
               
                // first we get all artifacts as defined by the module descriptor
                // and classify them by artifact id
                Map allArtifacts = new HashMap();
                for (Iterator iter = confs.iterator(); iter.hasNext();) {
                    String conf = (String) iter.next();
                    Artifact[] arts = _md.getArtifacts(conf);
                    for (int i = 0; i < arts.length; i++) {
                        allArtifacts.put(arts[i].getId().getArtifactId(), arts[i]);
                    }
                }
               
                // now we add caller defined ones
                for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                    DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
                    artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt(),
                        dad.getUrl(), dad.getExtraAttributes()));
                }
               
                // and now we filter according to include rules
                for (Iterator it = includes.iterator(); it.hasNext();) {
                  IncludeRule dad = (IncludeRule)it.next();
                  Collection arts = findArtifactsMatching(dad, allArtifacts);
                  if (arts.isEmpty()) {
                    Message.error("a required artifact is not listed by module descriptor: "+dad.getId());
                    // we remove it from required list to prevent message to be displayed more than once
                    it.remove();
                  } else {
                    Message.debug(this+" in "+rootModuleConf+": including "+arts);
                    artifacts.addAll(arts);
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.