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

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


        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
            "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");

        ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(
            new DefaultDependencyDescriptor(mrid, false), data);
        assertNotNull(rmr);
        assertEquals(mrid, rmr.getId());

        assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
View Full Code Here


        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
            "org.apache.ant", "1.8.3.v20120321-1730");

        ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(
            new DefaultDependencyDescriptor(mrid, false), data);
        assertNotNull(rmr);
        assertEquals(mrid, rmr.getId());

        assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
View Full Code Here

        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit",
            "4.10.0.v4_10_0_v20120426-0900");

        ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(
            new DefaultDependencyDescriptor(mrid, false), data);
        assertNotNull(rmr);
        assertEquals(mrid, rmr.getId());

        assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
View Full Code Here

    }

    private DependencyDescriptor addDependency(DefaultModuleDescriptor parent, String moduleName,
            String revision) {
        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", moduleName, revision);
        DependencyDescriptor depDescr = new DefaultDependencyDescriptor(parent, mrid, false, false,
                true);
        parent.addDependency(depDescr);
        return depDescr;
    }
View Full Code Here

        data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
    }

    private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid)
            throws ParseException {
        ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
                false), data);
        assertNotNull(rmr);
        assertEquals(mrid, rmr.getId());

        Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
View Full Code Here

    public void testArtifactRef() throws ParseException {

        // Simple Dependency for ibiblio
        ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("log4j", "log4j", "1.2.16");
        ResolvedModuleRevision rmr1 = chain.getDependency(new DefaultDependencyDescriptor(mrid1,
                false), data);

        // Simple Dependency for updatesite
        ModuleRevisionId mrid2 = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
            "org.apache.ivy", "2.0.0.final_20090108225011");
        ResolvedModuleRevision rmr2 = chain.getDependency(new DefaultDependencyDescriptor(mrid2,
                false), data);

        assertNotNull(rmr1);
        assertNotNull(rmr2);
View Full Code Here

                    qualifier = qualifier.substring(1);
                }
                ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
                ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev,
                    otherAtts);
                DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
                try {
                    DependencyResolver resolver = ivy.getSettings().getResolver(mrid);
                    if (resolver == null) {
                        return null;
                    }
                    ResolvedModuleRevision dep = resolver.getDependency(ddd, data);
                    if (dep == null) {
                        return null;
                    }
                    String[] confs = dep.getDescriptor().getConfigurationsNames();
                    for (int i = 0; i < confs.length; i++) {
                        confs[i] = base + confs[i];
                    }
                    List ret = new ArrayList(Arrays.asList(confs));
                    ret.add("*");
                    return (String[]) ret.toArray(new String[ret.size()]);
                } catch (ParseException e) {
                    IvyPlugin.log(IStatus.ERROR, "The dependencies of " + mrid
                            + " could not be parsed", e);
                    return null;
                }
            }

        });
        IvyTag conf3 = new IvyTag("conf", "defines configuration mapping has sub element");
        conf3
                .addAttribute(new IvyTagAttribute(
                        "name",
                        "the name of the master configuration to map. \n'*' wildcard can be used to designate all configurations of this module",
                        true, masterConfValueProvider));
        conf3
                .addAttribute(new IvyTagAttribute(
                        "mapped",
                        "a comma separated list of dependency configurations \nto which this master configuration should be mapped",
                        false, new IValueProvider() {
                            public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                                Ivy ivy = getIvy();
                                int[] indexes = ivyFile.getParentTagIndex();
                                if (indexes != null && ivy != null) {
                                    Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
                                    String org = ivyFile.getDependencyOrganisation(otherAttValues);
                                    if (org != null && otherAttValues != null
                                            && otherAttValues.get("name") != null
                                            && otherAttValues.get("rev") != null) {
                                        StringBuffer base = new StringBuffer();
                                        String qualifier = ivyFile.getAttributeValueQualifier();
                                        // search for word after last comma
                                        int comma = qualifier.lastIndexOf(",") + 1;
                                        base.append(qualifier.substring(0, comma));
                                        qualifier = qualifier.substring(comma);
                                        while (qualifier.length() > 0 && qualifier.charAt(0) == ' ') {
                                            base.append(' ');
                                            qualifier = qualifier.substring(1);
                                        }
                                        ResolveData data = new ResolveData(ivy.getResolveEngine(),
                                                new ResolveOptions());
                                        ModuleRevisionId mrid = ModuleRevisionId.newInstance(org,
                                            (String) otherAttValues.get("name"),
                                            (String) otherAttValues.get("rev"));
                                        DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(
                                                mrid, false);
                                        try {
                                            String[] confs = ivy.getSettings().getResolver(mrid)
                                                    .getDependency(ddd, data).getDescriptor()
                                                    .getConfigurationsNames();
                                            for (int i = 0; i < confs.length; i++) {
                                                confs[i] = base + confs[i];
                                            }
                                            List ret = new ArrayList(Arrays.asList(confs));
                                            ret.add("*");
                                            return (String[]) ret.toArray(new String[ret.size()]);
                                        } catch (ParseException e) {
                                            IvyPlugin.log(IStatus.ERROR, "The dependencies of "
                                                    + mrid + " could not be parsed", e);
                                            return new String[] {"*"};
                                        }
                                    }
                                }
                                return new String[] {"*"};
                            }

                        }));
        allConf.add(conf3);
        IvyTag mapped = new IvyTag("mapped",
                "map dependency configurations for this master configuration");
        mapped
                .addAttribute(new IvyTagAttribute(
                        "name",
                        "the name of the dependency configuration mapped. \n'*' wildcard can be used to designate all configurations of this module",
                        true, new IValueProvider() {
                            public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                                Ivy ivy = getIvy();
                                int[] indexes = ivyFile.getParentTagIndex();
                                if (indexes != null && ivy != null) {
                                    indexes = ivyFile.getParentTagIndex(indexes[0]);
                                    if (indexes != null) {
                                        Map otherAttValues = ivyFile
                                                .getAllAttsValues(indexes[0] + 1);
                                        String org = ivyFile
                                                .getDependencyOrganisation(otherAttValues);
                                        if (org != null && otherAttValues != null
                                                && otherAttValues.get("name") != null
                                                && otherAttValues.get("rev") != null) {
                                            ResolveData data = new ResolveData(ivy
                                                    .getResolveEngine(), new ResolveOptions());
                                            ModuleRevisionId mrid = ModuleRevisionId.newInstance(
                                                org, (String) otherAttValues.get("name"),
                                                (String) otherAttValues.get("rev"));
                                            DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(
                                                    mrid, false);
                                            try {
                                                String[] confs = ivy.getSettings()
                                                        .getResolver(mrid).getDependency(ddd, data)
                                                        .getDescriptor().getConfigurationsNames();
View Full Code Here

                ivyfile = File.createTempFile("ivy", ".xml");
                ivyfile.deleteOnExit();
                DefaultModuleDescriptor md = DefaultModuleDescriptor
                        .newDefaultInstance(ModuleRevisionId.newInstance(dep[0],
                            dep[1] + "-caller", "working"));
                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
                        ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
                for (int i = 0; i < confs.length; i++) {
                    dd.addDependencyConfiguration("default", confs[i]);
                }
                md.addDependency(dd);
                XmlModuleDescriptorWriter.write(md, ivyfile);
                confs = new String[] {"default"};
            } else {
View Full Code Here

       
        String version = dep.getVersion();
        version = (version == null || version.length() == 0) ? getDefaultVersion(dep) : version;
        ModuleRevisionId moduleRevId = ModuleRevisionId.newInstance(dep.getGroupId(), dep
                .getArtifactId(), version);
        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ivyModuleDescriptor,
                moduleRevId, true, false, true);
        scope = (scope == null || scope.length() == 0) ? getDefaultScope(dep) : scope;
        ConfMapper mapping = (ConfMapper) MAVEN2_CONF_MAPPING.get(scope);
        mapping.addMappingConfs(dd, dep.isOptional());
        Map extraAtt = new HashMap();
        if ((dep.getClassifier() != null) || (dep.getType() != null)) {
            String type = "jar";
            if (dep.getType() != null) {
                type = dep.getType();
            }
            // we deal with classifiers by setting an extra attribute and forcing the
            // dependency to assume such an artifact is published
            if (dep.getClassifier() != null) {
                extraAtt.put("m:classifier", dep.getClassifier());
            }
            DefaultDependencyArtifactDescriptor depArtifact =
                    new DefaultDependencyArtifactDescriptor(dd, dd.getDependencyId().getName(),
                        type, type, null, extraAtt);
            // here we have to assume a type and ext for the artifact, so this is a limitation
            // compared to how m2 behave with classifiers
            String optionalizedScope = dep.isOptional() ? "optional" : scope;
            dd.addDependencyArtifact(optionalizedScope, depArtifact);
        }
       
        // experimentation shows the following, excluded modules are
        // inherited from parent POMs if either of the following is true:
        // the <exclusions> element is missing or the <exclusions> element
        // is present, but empty.
        List /*<ModuleId>*/ excluded = dep.getExcludedModules();
        if (excluded.isEmpty()) {
            excluded = getDependencyMgtExclusions(ivyModuleDescriptor, dep.getGroupId(), dep.getArtifactId());
        }
        for (Iterator itExcl = excluded.iterator(); itExcl.hasNext();) {
            ModuleId excludedModule = (ModuleId) itExcl.next();
            String[] confs = dd.getModuleConfigurations();
            for (int k = 0; k < confs.length; k++) {
                dd.addExcludeRule(confs[k], new DefaultExcludeRule(new ArtifactId(
                    excludedModule, PatternMatcher.ANY_EXPRESSION,
                                PatternMatcher.ANY_EXPRESSION,
                                PatternMatcher.ANY_EXPRESSION),
                                ExactPatternMatcher.INSTANCE, null));
            }
View Full Code Here

                ivyfile = File.createTempFile("ivy", ".xml");
                ivyfile.deleteOnExit();
                DefaultModuleDescriptor md = DefaultModuleDescriptor
                        .newDefaultInstance(ModuleRevisionId.newInstance(dep[0],
                            dep[1] + "-caller", "working"));
                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
                        ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
                for (int i = 0; i < confs.length; i++) {
                    dd.addDependencyConfiguration("default", confs[i]);
                }
                md.addDependency(dd);
                XmlModuleDescriptorWriter.write(md, ivyfile);
                confs = new String[] {"default"};
            } else {
View Full Code Here

TOP

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

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.