Examples of IvyContext


Examples of org.apache.ivy.core.IvyContext

        this.envDependent = envDependent;
    }

    public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
            throws ParseException {
        IvyContext context = IvyContext.pushNewCopyContext();
        try {
            ResolvedModuleRevision mr = data.getCurrentResolvedModuleRevision();
            if (mr != null) {
                if (shouldReturnResolvedModule(dd, mr)) {
                    return mr;
                }
            }
           
            if (isForce()) {
                dd = dd.clone(ModuleRevisionId.newInstance(
                    dd.getDependencyRevisionId(), "latest.integration"));
            }
            DependencyDescriptor systemDd = dd;
            DependencyDescriptor nsDd = fromSystem(dd);
            context.setDependencyDescriptor(systemDd);
            context.setResolveData(data);
           
            clearIvyAttempts();
            clearArtifactAttempts();
            ModuleRevisionId systemMrid = systemDd.getDependencyRevisionId();
            ModuleRevisionId nsMrid = nsDd.getDependencyRevisionId();
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

        this.envDependent = envDependent;
    }

    public ResolvedModuleRevision getDependency(DependencyDescriptor dde, ResolveData data)
            throws ParseException {
        IvyContext context = IvyContext.pushNewCopyContext();
        DependencyDescriptor systemDd = dde;
        DependencyDescriptor nsDd = fromSystem(dde);
        context.setDependencyDescriptor(systemDd);
        context.setResolveData(data);
        try {
            clearIvyAttempts();
            clearArtifactAttempts();
            ModuleRevisionId systemMrid = systemDd.getDependencyRevisionId();
            ModuleRevisionId  nsMrid = nsDd.getDependencyRevisionId();
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

            ModuleRevisionId mrid, Date date) {
        ResolvedResource found = null;
        List sorted = strategy.sort(rress);
        List rejected = new ArrayList();
        List foundBlacklisted = new ArrayList();
        IvyContext context = IvyContext.getContext();
       
        for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
            ResolvedResource rres = (ResolvedResource) iter.previous();
            if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
                Message.debug("\t" + name + ": filtered by name: " + rres);
                continue;
            }
            if ((date != null && rres.getLastModified() > date.getTime())) {
                Message.verbose("\t" + name + ": too young: " + rres);
                rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
                continue;
            }
            ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
           
            ResolveData data = context.getResolveData();
            if (data != null
                    && data.getReport() != null
                    && data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
                Message.debug("\t" + name + ": blacklisted: " + rres);
                rejected.add(rres.getRevision() + " (blacklisted)");
                foundBlacklisted.add(foundMrid);
                continue;
            }
           
            if (!versionMatcher.accept(mrid, foundMrid)) {
                Message.debug("\t" + name + ": rejected by version matcher: " + rres);
                rejected.add(rres.getRevision());
                continue;
            }
            if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
                ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
                if (r == null) {
                    Message.debug("\t" + name
                        + ": impossible to get module descriptor resource: " + rres);
                    rejected.add(rres.getRevision() + " (no or bad MD)");
                    continue;
                }
                ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision()
                        .getDescriptor();
                if (md.isDefault()) {
                    Message.debug("\t" + name + ": default md rejected by version matcher"
                            + "requiring module descriptor: " + rres);
                    rejected.add(rres.getRevision() + " (MD)");
                    continue;
                } else if (!versionMatcher.accept(mrid, md)) {
                    Message.debug("\t" + name + ": md rejected by version matcher: " + rres);
                    rejected.add(rres.getRevision() + " (MD)");
                    continue;
                } else {
                    found = r;
                }
            } else {
                found = rres;
            }

            if (found != null) {
                if (!found.getResource().exists()) {
                    Message.debug("\t" + name + ": resource not reachable for " + mrid + ": res="
                            + found.getResource());
                    logAttempt(found.getResource().toString());
                    continue;
                }
                break;
            }
        }
        if (found == null && !rejected.isEmpty()) {
            logAttempt(rejected.toString());
        }
        if (found == null && !foundBlacklisted.isEmpty()) {
            // all acceptable versions have been blacklisted, this means that an unsolvable conflict
            // has been found
            DependencyDescriptor dd = context.getDependencyDescriptor();
            IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
            ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
            cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
        }

        return found;
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

    private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
            Map extraAttributes) {
        super(null, extraAttributes);
        this.moduleId = moduleId;
        IvyContext context = IvyContext.getContext();
        this.branch = branch == null
            // we test if there's already an Ivy instance loaded, to avoid loading a default one
            // just to get the default branch
            ? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
            : branch;
        this.revision = revision == null ? Ivy.getWorkingRevision() : revision;
        setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
        setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
        setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

     * Resolve dependencies of a module described by a module descriptor.
     */
    public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options)
            throws ParseException, IOException {
        DependencyResolver oldDictator = getDictatorResolver();
        IvyContext context = IvyContext.getContext();
        if (options.isUseCacheOnly()) {
            setDictatorResolver(new CacheResolver(settings));
        }
        try {
            String[] confs = options.getConfs(md);
            options.setConfs(confs);

            if (options.getResolveId() == null) {
                options.setResolveId(ResolveOptions.getDefaultResolveId(md));
            }

            eventManager.fireIvyEvent(new StartResolveEvent(md, confs));

            long start = System.currentTimeMillis();
            if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
                Message.info(":: resolving dependencies :: " + md.getResolvedModuleRevisionId()
                        + (options.isTransitive() ? "" : " [not transitive]"));
                Message.info("\tconfs: " + Arrays.asList(confs));
            } else {
                Message.verbose(":: resolving dependencies :: " + md.getResolvedModuleRevisionId()
                    + (options.isTransitive() ? "" : " [not transitive]"));
                Message.verbose("\tconfs: " + Arrays.asList(confs));
            }
            Message.verbose("\tvalidate = " + options.isValidate());
            Message.verbose("\trefresh = " + options.isRefresh());
           
            ResolveReport report = new ResolveReport(md, options.getResolveId());

            ResolveData data = new ResolveData(this, options);
            context.setResolveData(data);
           
            // resolve dependencies
            IvyNode[] dependencies = getDependencies(md, options, report);
            report.setDependencies(Arrays.asList(dependencies), options.getArtifactFilter());

            // produce resolved ivy file and ivy properties in cache
            ResolutionCacheManager cacheManager = settings.getResolutionCacheManager();
            File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md
                    .getResolvedModuleRevisionId());
            md.toIvyFile(ivyFileInCache);

            // we store the resolved dependencies revisions and statuses per asked dependency
            // revision id,
            // for direct dependencies only.
            // this is used by the deliver task to resolve dynamic revisions to static ones
            File ivyPropertiesInCache = cacheManager.getResolvedIvyPropertiesInCache(
                        md.getResolvedModuleRevisionId());
            Properties props = new Properties();
            if (dependencies.length > 0) {
                IvyNode root = dependencies[0].getRoot();
                for (int i = 0; i < dependencies.length; i++) {
                    if (!dependencies[i].hasProblem()) {
                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
                        if (dd != null) {
                            ModuleRevisionId depResolvedId = dependencies[i].getResolvedId();
                            ModuleDescriptor depDescriptor = dependencies[i].getDescriptor();
                            ModuleRevisionId depRevisionId = dd.getDependencyRevisionId();
                            if (depResolvedId == null) {
                                throw new NullPointerException("getResolvedId() is null for "
                                    + dependencies[i].toString());
                            }
                            if (depRevisionId == null) {
                                throw new NullPointerException("getDependencyRevisionId() "
                                    + "is null for " + dd.toString());
                            }
                            String rev = depResolvedId.getRevision();
                            // The evicted modules have no description, so we can't put their
                            // status.
                            String status = depDescriptor == null ? "?" : depDescriptor.getStatus();
                            props.put(depRevisionId.encodeToString(), rev + " " + status);
                        }
                    }
                }
            }
            FileOutputStream out = new FileOutputStream(ivyPropertiesInCache);
            props.store(out, md.getResolvedModuleRevisionId() + " resolved revisions");
            out.close();
            Message.verbose("\tresolved ivy file produced in " + ivyFileInCache);

            report.setResolveTime(System.currentTimeMillis() - start);

            if (options.isDownload()) {
                Message.verbose(":: downloading artifacts ::");

                downloadArtifacts(report, options.getArtifactFilter(),
                    (DownloadOptions) new DownloadOptions().setLog(options.getLog()));
            }

            if (options.isOutputReport()) {
                outputReport(report, cacheManager, options);
            }

            Message.verbose("\tresolve done (" + report.getResolveTime() + "ms resolve - "
                    + report.getDownloadTime() + "ms download)");
            Message.sumupProblems();

            eventManager.fireIvyEvent(new EndResolveEvent(md, confs, report));
            return report;
        } catch (RuntimeException ex) {
            Message.error(ex.getMessage());
            Message.sumupProblems();
            throw ex;
        } finally {
            context.setResolveData(null);
            setDictatorResolver(oldDictator);
        }
    }
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

                "requested configuration" + (missingConfs.size() > 1 ? "s" : "")
                + " not found in "
                + md.getModuleRevisionId() + ": " + missingConfs);
        }

        IvyContext context = IvyContext.pushNewCopyContext();
        try {
            options.setConfs(confs);
   
            Date reportDate = new Date();
            ResolveData data = context.getResolveData();
            if (data == null) {
                data = new ResolveData(this, options);
                context.setResolveData(data);
            }
            IvyNode rootNode = new IvyNode(data, md);
           
            for (int i = 0; i < confs.length; i++) {
                Message.verbose("resolving dependencies for configuration '" + confs[i] + "'");
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

     * Resolve dependencies of a module described by a module descriptor.
     */
    public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options)
            throws ParseException, IOException {
        DependencyResolver oldDictator = getDictatorResolver();
        IvyContext context = IvyContext.getContext();
        try {
            String[] confs = options.getConfs(md);
            options.setConfs(confs);

            if (options.getResolveId() == null) {
                options.setResolveId(ResolveOptions.getDefaultResolveId(md));
            }

            eventManager.fireIvyEvent(new StartResolveEvent(md, confs));

            long start = System.currentTimeMillis();
            if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
                Message.info(":: resolving dependencies :: " + md.getResolvedModuleRevisionId()
                        + (options.isTransitive() ? "" : " [not transitive]"));
                Message.info("\tconfs: " + Arrays.asList(confs));
            } else {
                Message.verbose(":: resolving dependencies :: " + md.getResolvedModuleRevisionId()
                    + (options.isTransitive() ? "" : " [not transitive]"));
                Message.verbose("\tconfs: " + Arrays.asList(confs));
            }
            Message.verbose("\tvalidate = " + options.isValidate());
            Message.verbose("\trefresh = " + options.isRefresh());
           
            ResolveReport report = new ResolveReport(md, options.getResolveId());

            ResolveData data = new ResolveData(this, options);
            context.setResolveData(data);
           
            // resolve dependencies
            IvyNode[] dependencies = getDependencies(md, options, report);
            report.setDependencies(Arrays.asList(dependencies), options.getArtifactFilter());
           
            if (options.getCheckIfChanged()) {
                report.checkIfChanged();
            }

            // produce resolved ivy file and ivy properties in cache
            ResolutionCacheManager cacheManager = settings.getResolutionCacheManager();
            File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md
                    .getResolvedModuleRevisionId());
            md.toIvyFile(ivyFileInCache);

            // we store the resolved dependencies revisions and statuses per asked dependency
            // revision id,
            // for direct dependencies only.
            // this is used by the deliver task to resolve dynamic revisions to static ones
            File ivyPropertiesInCache = cacheManager.getResolvedIvyPropertiesInCache(
                        md.getResolvedModuleRevisionId());
            Properties props = new Properties();
            if (dependencies.length > 0) {
                Map forcedRevisions = new HashMap();
                for (int i = 0; i < dependencies.length; i++) {
                    if (dependencies[i].getModuleRevision() != null
                            && dependencies[i].getModuleRevision().isForce()) {
                        forcedRevisions.put(dependencies[i].getModuleId(), dependencies[i].getResolvedId());
                    }
                }

                IvyNode root = dependencies[0].getRoot();
                for (int i = 0; i < dependencies.length; i++) {
                    if (!dependencies[i].hasProblem()) {
                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
                        if (dd != null) {
                            ModuleRevisionId depResolvedId = dependencies[i].getResolvedId();
                            ModuleDescriptor depDescriptor = dependencies[i].getDescriptor();
                            ModuleRevisionId depRevisionId = dd.getDependencyRevisionId();
                            ModuleRevisionId forcedRevisionId = (ModuleRevisionId)
                                    forcedRevisions.get(dependencies[i].getModuleId());
                           
                            if (dependencies[i].getModuleRevision() != null
                                    && dependencies[i].getModuleRevision().isForce()
                                    && !depResolvedId.equals(depRevisionId)
                                    && !settings.getVersionMatcher().isDynamic(depRevisionId)) {
                                // if we were forced to this revision and we
                                // are not a dynamic revision, reset to the
                                // asked revision
                                depResolvedId = depRevisionId;
                                depDescriptor = null;
                            }
                           
                            if (depResolvedId == null) {
                                throw new NullPointerException("getResolvedId() is null for "
                                    + dependencies[i].toString());
                            }
                            if (depRevisionId == null) {
                                throw new NullPointerException("getDependencyRevisionId() "
                                    + "is null for " + dd.toString());
                            }
                            String rev = depResolvedId.getRevision();
                            String forcedRev = forcedRevisionId == null ? rev : forcedRevisionId.getRevision();
                           
                            // The evicted modules have no description, so we can't put the status
                            String status = depDescriptor == null ? "?" : depDescriptor.getStatus();
                            props.put(depRevisionId.encodeToString(), rev + " " + status + " " + forcedRev);
                        }
                    }
                }
            }
            FileOutputStream out = new FileOutputStream(ivyPropertiesInCache);
            props.store(out, md.getResolvedModuleRevisionId() + " resolved revisions");
            out.close();
            Message.verbose("\tresolved ivy file produced in " + ivyFileInCache);

            report.setResolveTime(System.currentTimeMillis() - start);

            if (options.isDownload()) {
                Message.verbose(":: downloading artifacts ::");

                downloadArtifacts(report, options.getArtifactFilter(),
                    (DownloadOptions) new DownloadOptions().setLog(options.getLog()));
            }

            if (options.isOutputReport()) {
                outputReport(report, cacheManager, options);
            }

            Message.verbose("\tresolve done (" + report.getResolveTime() + "ms resolve - "
                    + report.getDownloadTime() + "ms download)");
            Message.sumupProblems();

            eventManager.fireIvyEvent(new EndResolveEvent(md, confs, report));
            return report;
        } catch (RuntimeException ex) {
            Message.error(ex.getMessage());
            Message.sumupProblems();
            throw ex;
        } finally {
            context.setResolveData(null);
            setDictatorResolver(oldDictator);
        }
    }
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

                "requested configuration" + (missingConfs.size() > 1 ? "s" : "")
                + " not found in "
                + md.getModuleRevisionId() + ": " + missingConfs);
        }

        IvyContext context = IvyContext.pushNewCopyContext();
        try {
            options.setConfs(confs);
   
            Date reportDate = new Date();
            ResolveData data = context.getResolveData();
            if (data == null) {
                data = new ResolveData(this, options);
                context.setResolveData(data);
            }
            IvyNode rootNode = new IvyNode(data, md);
           
            for (int i = 0; i < confs.length; i++) {
                Message.verbose("resolving dependencies for configuration '" + confs[i] + "'");
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

   
    private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
            Map extraAttributes, boolean replaceNullBranchWithDefault) {
        super(null, extraAttributes);
        this.moduleId = moduleId;
        IvyContext context = IvyContext.getContext();
        this.branch = (replaceNullBranchWithDefault && branch == null)
            // we test if there's already an Ivy instance loaded, to avoid loading a default one
            // just to get the default branch
            ? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
            : branch;
        this.revision = revision == null ? Ivy.getWorkingRevision() : revision;
        setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
        setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
        setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
View Full Code Here

Examples of org.apache.ivy.core.IvyContext

        this.envDependent = envDependent;
    }

    public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
            throws ParseException {
        IvyContext context = IvyContext.pushNewCopyContext();
        try {
            ResolvedModuleRevision mr = data.getCurrentResolvedModuleRevision();
            if (mr != null) {
                if (shouldReturnResolvedModule(dd, mr)) {
                    return mr;
                }
            }
           
            if (isForce()) {
                dd = dd.clone(ModuleRevisionId.newInstance(
                    dd.getDependencyRevisionId(), "latest.integration"));
            }
            DependencyDescriptor systemDd = dd;
            DependencyDescriptor nsDd = fromSystem(dd);
            context.setDependencyDescriptor(systemDd);
            context.setResolveData(data);
           
            clearIvyAttempts();
            clearArtifactAttempts();
            ModuleRevisionId systemMrid = systemDd.getDependencyRevisionId();
            ModuleRevisionId nsMrid = nsDd.getDependencyRevisionId();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.