Package org.apache.ivy.core.resolve

Examples of org.apache.ivy.core.resolve.ResolvedModuleRevision


                    resource = "test-version.pom";
                }
                try {
                    ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                            .parseDescriptor(settings, getClass().getResource(resource), false);
                    return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
                } catch (IOException e) {
                    throw new AssertionError(e);
                }
            }
        });
View Full Code Here


        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            // TODO make it a real mock and check that dd and data are the one that are expected
            DefaultModuleDescriptor moduleDesc = DefaultModuleDescriptor.newDefaultInstance(dd
                    .getDependencyRevisionId());
            ResolvedModuleRevision r = new ResolvedModuleRevision(this, this, moduleDesc, null);
            return r;
        }
View Full Code Here

        }
        ModuleDescriptor md = toSystem(rmr.getDescriptor(), ns);
        if (md.equals(rmr.getDescriptor())) {
            return rmr;
        }
        return new ResolvedModuleRevision(rmr.getResolver(), rmr.getArtifactResolver(), md,
                transform(rmr.getReport(), ns.getToSystemTransformer()), rmr.isForce());
    }
View Full Code Here

        return findModuleInCache(dd, data, false);
    }

    protected ResolvedModuleRevision findModuleInCache(DependencyDescriptor dd, ResolveData data,
            boolean anyResolver) {
        ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd,
            dd.getDependencyRevisionId(), getCacheOptions(data), anyResolver ? null : getName());
        if (rmr == null) {
            return null;
        }
        if (data.getReport() != null
                && data.isBlacklisted(data.getReport().getConfiguration(), rmr.getId())) {
            Message.verbose("\t" + getName() + ": found revision in cache: " + rmr.getId()
                    + " for " + dd + ", but it is blacklisted");
            return null;
        }
        return rmr;
    }
View Full Code Here

            ResolvedModuleRevision newModuleFound, ResolveData data) {
        Checks.checkNotNull(dd, "dd");
        Checks.checkNotNull(data, "data");

        // check if latest is asked and compare to return the most recent
        ResolvedModuleRevision previousModuleFound = data.getCurrentResolvedModuleRevision();
        String newModuleDesc = describe(newModuleFound);
        Message.debug("\tchecking " + newModuleDesc + " against " + describe(previousModuleFound));
        if (previousModuleFound == null) {
            Message.debug("\tmodule revision kept as first found: " + newModuleDesc);
            saveModuleRevisionIfNeeded(dd, newModuleFound);
            return newModuleFound;
        } else if (isAfter(newModuleFound, previousModuleFound, data.getDate())) {
            Message.debug("\tmodule revision kept as younger: " + newModuleDesc);
            saveModuleRevisionIfNeeded(dd, newModuleFound);
            return newModuleFound;
        } else if (!newModuleFound.getDescriptor().isDefault()
                && previousModuleFound.getDescriptor().isDefault()) {
            Message.debug("\tmodule revision kept as better (not default): " + newModuleDesc);
            saveModuleRevisionIfNeeded(dd, newModuleFound);
            return newModuleFound;
        } else {
            Message.debug("\tmodule revision discarded as older: " + newModuleDesc);
View Full Code Here

                    }
                }
                // resolve
                DependencyResolver resolver = settings
                        .getResolver(dds[i].getDependencyRevisionId());
                ResolvedModuleRevision rmr = resolver.getDependency(dds[i], data);
                if (rmr == null) {
                    Message.info("dependency not found in " + ivyFile + ":\n\t" + dds[i]);
                    result = false;
                } else {
                    String[] depConfs = dds[i].getDependencyConfigurations(md
                            .getConfigurationsNames());
                    for (int j = 0; j < depConfs.length; j++) {
                        if (!Arrays.asList(rmr.getDescriptor().getConfigurationsNames()).contains(
                            depConfs[j])) {
                            Message.info("dependency configuration is missing for " + ivyFile
                                    + "\n\tin " + dds[i] + ": " + depConfs[j]);
                            result = false;
                        }
                        Artifact[] arts = rmr.getDescriptor().getArtifacts(depConfs[j]);
                        for (int k = 0; k < arts.length; k++) {
                            if (!resolver.exists(arts[k])) {
                                Message.info("dependency artifact is missing for " + ivyFile
                                        + "\n\t in " + dds[i] + ": " + arts[k]);
                                result = false;
View Full Code Here

                // Is there any other parent properties?

                ModuleRevisionId parentModRevID = ModuleRevisionId.newInstance(
                    domReader.getParentGroupId(), domReader.getParentArtifactId(),
                    domReader.getParentVersion());
                ResolvedModuleRevision parentModule = parseOtherPom(ivySettings, parentModRevID);
                if (parentModule != null) {
                    parentDescr = parentModule.getDescriptor();
                } else {
                    throw new IOException("Impossible to load parent for " + res.getName() + "."
                            + " Parent=" + parentModRevID);
                }
                if (parentDescr != null) {
                    Map parentPomProps = PomModuleDescriptorBuilder
                            .extractPomProperties(parentDescr.getExtraInfo());
                    for (Iterator iter = parentPomProps.entrySet().iterator(); iter.hasNext();) {
                        Map.Entry prop = (Map.Entry) iter.next();
                        domReader.setProperty((String) prop.getKey(), (String) prop.getValue());
                    }
                }
            }

            String groupId = domReader.getGroupId();
            String artifactId = domReader.getArtifactId();
            String version = domReader.getVersion();
            mdBuilder.setModuleRevId(groupId, artifactId, version);

            mdBuilder.setHomePage(domReader.getHomePage());
            mdBuilder.setDescription(domReader.getDescription());
            mdBuilder.setLicenses(domReader.getLicenses());

            ModuleRevisionId relocation = domReader.getRelocation();

            if (relocation != null) {
                if (groupId != null && artifactId != null
                        && artifactId.equals(relocation.getName())
                        && groupId.equals(relocation.getOrganisation())) {
                    Message.error("Relocation to an other version number not supported in ivy : "
                            + mdBuilder.getModuleDescriptor().getModuleRevisionId()
                            + " relocated to " + relocation
                            + ". Please update your dependency to directly use the right version.");
                    Message.warn("Resolution will only pick dependencies of the relocated element."
                            + "  Artefact and other metadata will be ignored.");
                    ResolvedModuleRevision relocatedModule = parseOtherPom(ivySettings, relocation);
                    if (relocatedModule == null) {
                        throw new ParseException("impossible to load module " + relocation
                                + " to which "
                                + mdBuilder.getModuleDescriptor().getModuleRevisionId()
                                + " has been relocated", 0);
                    }
                    DependencyDescriptor[] dds = relocatedModule.getDescriptor().getDependencies();
                    for (int i = 0; i < dds.length; i++) {
                        mdBuilder.addDependency(dds[i]);
                    }
                } else {
                    Message.info(mdBuilder.getModuleDescriptor().getModuleRevisionId()
                            + " is relocated to " + relocation
                            + ". Please update your dependencies.");
                    Message.verbose("Relocated module will be considered as a dependency");
                    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
                            mdBuilder.getModuleDescriptor(), relocation, true, false, true);
                    /* Map all public dependencies */
                    Configuration[] m2Confs = PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS;
                    for (int i = 0; i < m2Confs.length; i++) {
                        if (Visibility.PUBLIC.equals(m2Confs[i].getVisibility())) {
                            dd.addDependencyConfiguration(m2Confs[i].getName(),
                                m2Confs[i].getName());
                        }
                    }
                    mdBuilder.addDependency(dd);
                }
            } else {
                domReader.setProperty("project.groupId", groupId);
                domReader.setProperty("pom.groupId", groupId);
                domReader.setProperty("groupId", groupId);
                domReader.setProperty("project.artifactId", artifactId);
                domReader.setProperty("pom.artifactId", artifactId);
                domReader.setProperty("artifactId", artifactId);
                domReader.setProperty("project.version", version);
                domReader.setProperty("pom.version", version);
                domReader.setProperty("version", version);

                if (parentDescr != null) {
                    mdBuilder.addExtraInfos(parentDescr.getExtraInfo());

                    // add dependency management info from parent
                    List depMgt = PomModuleDescriptorBuilder.getDependencyManagements(parentDescr);
                    for (Iterator it = depMgt.iterator(); it.hasNext();) {
                        PomDependencyMgt dep = (PomDependencyMgt) it.next();
                        if (dep instanceof PomDependencyMgtElement) {
                            dep = domReader.new PomDependencyMgtElement(
                                    (PomDependencyMgtElement) dep);
                        }
                        mdBuilder.addDependencyMgt(dep);
                    }

                    // add plugins from parent
                    List /* <PomDependencyMgt> */plugins = PomModuleDescriptorBuilder
                            .getPlugins(parentDescr);
                    for (Iterator it = plugins.iterator(); it.hasNext();) {
                        mdBuilder.addPlugin((PomDependencyMgt) it.next());
                    }
                }

                for (Iterator it = domReader.getDependencyMgt().iterator(); it.hasNext();) {
                    PomDependencyMgt dep = (PomDependencyMgt) it.next();
                    if ("import".equals(dep.getScope())) {
                        ModuleRevisionId importModRevID = ModuleRevisionId.newInstance(
                            dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
                        ResolvedModuleRevision importModule = parseOtherPom(ivySettings,
                            importModRevID);
                        if (importModule != null) {
                            ModuleDescriptor importDescr = importModule.getDescriptor();

                            // add dependency management info from imported module
                            List depMgt = PomModuleDescriptorBuilder
                                    .getDependencyManagements(importDescr);
                            for (Iterator it2 = depMgt.iterator(); it2.hasNext();) {
View Full Code Here

        if (resolver == null) {
            // TODO: Throw exception here?
            return null;
        } else {
            dd = NameSpaceHelper.toSystem(dd, ivySettings.getContextNamespace());
            ResolvedModuleRevision otherModule = resolver.getDependency(dd, data);
            return otherModule;
        }
    }
View Full Code Here

            if (!matcher.accept(askedMrid, info.rmr)) {
                continue;
            }

            if (matcher.needModuleDescriptor(askedMrid, info.rmr)) {
                ResolvedModuleRevision rmr = ivy.findModule(info.rmr);
                if (matcher.accept(askedMrid, rmr.getDescriptor())) {
                    foundRevision = info.rmr.getRevision();
                }
            } else {
                foundRevision = info.rmr.getRevision();
            }
View Full Code Here

            resolver.setName("packager");
            assertEquals("packager", resolver.getName());

            // Get module descriptor
            ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "mod", "1.0");
            ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
                    mrid, false), data);
            assertNotNull(rmr);

            assertEquals(mrid, rmr.getId());
            Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
            assertEquals(pubdate, rmr.getPublicationDate());

            // Download artifact
            Artifact artifact = new DefaultArtifact(mrid, pubdate, "mod", "jar", "jar");
            DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions());
            assertNotNull(report);
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.resolve.ResolvedModuleRevision

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.