Examples of ModuleDescriptorParser


Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

                Message.verbose("Parent module doesn't exist on the filesystem: " + file.getAbsolutePath());
                return null;
            }
           
            FileResource res = new FileResource(null, file);
            ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
            return parser.parseDescriptor(getSettings(), file.toURL(), res, isValidate());
        }
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

     * too long, we should use a class to store the settings of the resolve.
     */
    public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
            IOException {
        URLResource res = new URLResource(ivySource);
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
        Message.verbose("using " + parser + " to parse " + ivySource);
        ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, options.isValidate());
        String revision = options.getRevision();
        if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
            revision = Ivy.getWorkingRevision();
        }
        if (revision != null) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

     * Resolve dependencies of a module described by an ivy file.
     */
    public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
            IOException {
        URLResource res = new URLResource(ivySource);
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
        Message.verbose("using " + parser + " to parse " + ivySource);
        ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, options.isValidate());
        String revision = options.getRevision();
        if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
            revision = Ivy.getWorkingRevision();
        }
        if (revision != null) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

            try {
                File ivyFile = getCache().getResolvedIvyFileInCache(mrid);
                Message.verbose("no explicit confs given for retrieve, using ivy file: " + ivyFile);
                URL ivySource = ivyFile.toURI().toURL();
                URLResource res = new URLResource(ivySource);
                ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance()
                        .getParser(res);
                Message.debug("using " + parser + " to parse " + ivyFile);
                ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, false);
                confs = md.getConfigurationsNames();
                options.setConfs(confs);
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

          try {
            File ivyFile = options.getCache().getResolvedIvyFileInCache(mrid);
            Message.verbose("no explicit confs given for retrieve, using ivy file: "+ivyFile);
            URL ivySource = ivyFile.toURL();
            URLResource res = new URLResource(ivySource);
            ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
            Message.debug("using "+parser+" to parse "+ivyFile);
            ModuleDescriptor md = parser.parseDescriptor(_settings, ivySource, false);
            confs = md.getConfigurationsNames();
            options.setConfs(confs);
          } catch (IOException e) {
            throw e;
          } catch (Exception e) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

        ResolvedResource ivyRef = findIvyFileRef(dd, data);
        checkInterrupted();
        searched = true;

        // get module descriptor
        ModuleDescriptorParser parser;
        ModuleDescriptor md;
        ModuleDescriptor systemMd = null;
        if (ivyRef == null) {
          if (!isAllownomd()) {
            Message.verbose("\t"+getName()+": no ivy file found for "+mrid);
            return null;
          }
          parser = XmlModuleDescriptorParser.getInstance();
          md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd.getAllDependencyArtifacts());
          ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
          checkInterrupted();
          if (artifactRef == null) {
            Message.verbose("\t"+getName()+": no ivy file nor artifact found for "+mrid);
            String[] conf = md.getConfigurationsNames();
            for (int i = 0; i < conf.length; i++) {
              Artifact[] artifacts = md.getArtifacts(conf[i]);
              for (int j = 0; j < artifacts.length; j++) {
              }
            }
            if (!checkedCache) {
              cachedRmr = findModuleInCache(data, mrid);
            }
            if (cachedRmr != null) {
              Message.verbose("\t"+getName()+": revision in cache: "+mrid);
              return toSystem(cachedRmr);                   
            }
            return null;
          } else {
            long lastModified = artifactRef.getLastModified();
            if (lastModified != 0 && md instanceof DefaultModuleDescriptor) {
              ((DefaultModuleDescriptor) md).setLastModified(lastModified);
            }
            Message.verbose("\t"+getName()+": no ivy file found for "+mrid+": using default data");           
            if (isDynamic) {
              md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid, artifactRef.getRevision()));
            }
          }
        } else {
          ResolvedModuleRevision rmr = null;
          if (ivyRef instanceof MDResolvedResource) {
            rmr = ((MDResolvedResource)ivyRef).getResolvedModuleRevision();
          }
          if (rmr == null) {
            rmr = parse(ivyRef, dd, data);
            if (rmr == null) {
              return null;
            }
          }
          if (!rmr.isDownloaded()) {
            return toSystem(rmr);
          } else {
            md = rmr.getDescriptor();
            parser = ModuleDescriptorParserRegistry.getInstance().getParser(ivyRef.getResource());
            cachedIvyURL = rmr.getLocalMDUrl();

            // check descriptor data is in sync with resource revision and names
            systemMd = toSystem(md);
            if (_checkconsistency) {
              checkDescriptorConsistency(mrid, md, ivyRef);
              checkDescriptorConsistency(systemDd.getDependencyRevisionId(), systemMd, ivyRef);
            } else {
              if (md instanceof DefaultModuleDescriptor) {
                String revision = getRevision(ivyRef, mrid, md);
                ((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid, revision));
              } else {
                Message.warn("consistency disabled with instance of non DefaultModuleDescriptor... module info can't be updated, so consistency check will be done");
                checkDescriptorConsistency(mrid, md, ivyRef);
                checkDescriptorConsistency(systemDd.getDependencyRevisionId(), systemMd, ivyRef);
              }
            }
          }
        }

        if (systemMd == null) {
          systemMd = toSystem(md);
        }

        // resolve revision
        ModuleRevisionId resolvedMrid = mrid;
        if (isDynamic) {
          resolvedMrid = md.getResolvedModuleRevisionId();
          if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0) {
            if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {
              resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@"+getName());
            } else {
              resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef.getRevision());
            }
          }
          Message.verbose("\t\t["+resolvedMrid.getRevision()+"] "+mrid.getModuleId());
        }
        md.setResolvedModuleRevisionId(resolvedMrid);
        systemMd.setResolvedModuleRevisionId(toSystem(resolvedMrid)); // keep system md in sync with md

        // check module descriptor revision
        if (!getSettings().getVersionMatcher().accept(mrid, md)) {
          Message.info("\t"+getName()+": unacceptable revision => was="+md.getModuleRevisionId().getRevision()+" required="+mrid.getRevision());
          return null;
        }


        // resolve and check publication date
        if (data.getDate() != null) {
          long pubDate = getPublicationDate(md, dd, data);
          if (pubDate > data.getDate().getTime()) {
            Message.info("\t"+getName()+": unacceptable publication date => was="+new Date(pubDate)+" required="+data.getDate());
            return null;
          } else if (pubDate == -1) {
            Message.info("\t"+getName()+": impossible to guess publication date: artifact missing for "+mrid);
            return null;
          }
          md.setResolvedPublicationDate(new Date(pubDate));
          systemMd.setResolvedPublicationDate(new Date(pubDate)); // keep system md in sync with md
        }

        try {
          File ivyFile = data.getCacheManager().getIvyFileInCache(systemMd.getResolvedModuleRevisionId());
          if (ivyRef == null) {
            // a basic ivy file is written containing default data
            XmlModuleDescriptorWriter.write(systemMd, ivyFile);
          } else {
            if (md instanceof DefaultModuleDescriptor) {
              DefaultModuleDescriptor dmd = (DefaultModuleDescriptor)md;
              if (data.getSettings().logNotConvertedExclusionRule() && dmd.isNamespaceUseful()) {
                Message.warn("the module descriptor "+ivyRef.getResource()+" has information which can't be converted into the system namespace. It will require the availability of the namespace '"+getNamespace().getName()+"' to be fully usable.");
              }
            }
            // copy and update ivy file from source to cache
            parser.toIvyFile(cachedIvyURL.openStream(), ivyRef.getResource(), ivyFile, systemMd);
            long repLastModified = ivyRef.getLastModified();
            if (repLastModified > 0) {
              ivyFile.setLastModified(repLastModified);
            }
          }
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

        DependencyDescriptor dd,
        ResolveData data
        ) throws ParseException {
     
      ModuleRevisionId mrid = dd.getDependencyRevisionId();
      ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(ivyRef.getResource());
        if (parser == null) {
            Message.warn("no module descriptor parser available for "+ivyRef.getResource());
            return null;
        }
        Message.verbose("\t"+getName()+": found md file for "+mrid);
        Message.verbose("\t\t=> "+ivyRef);
        Message.debug("\tparser = "+parser);

        boolean isChangingRevision = getChangingMatcher().matches(mrid.getRevision());       
        boolean isChangingDependency = isChangingRevision || dd.isChanging();
      Date cachedPublicationDate = null;
        ModuleRevisionId resolvedMrid = mrid;
       
        // first check if this dependency has not yet been resolved
        if (getSettings().getVersionMatcher().isDynamic(mrid)) {
            resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision());
            IvyNode node = getSystemNode(data, resolvedMrid);
            if (node != null && node.getModuleRevision() != null) {
                // this revision has already be resolved : return it
                if (node.getDescriptor() != null && node.getDescriptor().isDefault()) {
                    Message.verbose("\t"+getName()+": found already resolved revision: "+resolvedMrid+": but it's a default one, maybe we can find a better one");
                } else {
                    Message.verbose("\t"+getName()+": revision already resolved: "+resolvedMrid);
                    return searchedRmr(node.getModuleRevision());
                }
            }
        }
       
        // now let's see if we can find it in cache and if it is up to date
        ResolvedModuleRevision rmr = findModuleInCache(data, resolvedMrid);
        if (rmr != null) {
            if (rmr.getDescriptor().isDefault() && rmr.getResolver() != this) {
                Message.verbose("\t"+getName()+": found revision in cache: "+mrid+" (resolved by "+rmr.getResolver().getName()+"): but it's a default one, maybe we can find a better one");
            } else {
                if (!isCheckmodified() && !isChangingDependency) {
                    Message.verbose("\t"+getName()+": revision in cache: "+mrid);
                    return searchedRmr(rmr);
                }
                long repLastModified = ivyRef.getLastModified();
                long cacheLastModified = rmr.getDescriptor().getLastModified();
                if (!rmr.getDescriptor().isDefault() && repLastModified <= cacheLastModified) {
                    Message.verbose("\t"+getName()+": revision in cache (not updated): "+resolvedMrid);
                    return searchedRmr(rmr);
                } else {
                    Message.verbose("\t"+getName()+": revision in cache is not up to date: "+resolvedMrid);
                    if (isChangingDependency) {
                        // ivy file has been updated, we should see if it has a new publication date
                        // to see if a new download is required (in case the dependency is a changing one)
                        cachedPublicationDate = rmr.getDescriptor().getResolvedPublicationDate();
                    }
                }
            }
        }
       
        // now download ivy file and parse it
        URL cachedIvyURL = null;
        File ivyTempFile = null;
        try {
            // first check if source file is not cache file itself
            if (ResourceHelper.equals(ivyRef.getResource(),
                    data.getCacheManager().getIvyFileInCache(toSystem(resolvedMrid)))) {
                Message.error("invalid configuration for resolver '"+getName()+"': pointing ivy files to ivy cache is forbidden !");
                return null;
            }
           
            // temp file is used to prevent downloading twice
            ivyTempFile = File.createTempFile("ivy", "xml");
            ivyTempFile.deleteOnExit();
            Message.debug("\t"+getName()+": downloading "+ivyRef.getResource()+" to "+ivyTempFile);
            getAndCheck(ivyRef.getResource(), ivyTempFile);
            try {
                cachedIvyURL = ivyTempFile.toURL();
            } catch (MalformedURLException ex) {
                Message.warn("malformed url exception for temp file: "+ivyTempFile+": "+ex.getMessage());
                return null;
            }
        } catch (IOException ex) {
            Message.warn("problem while downloading ivy file: "+ivyRef.getResource()+" to "+ivyTempFile+": "+ex.getMessage());
            return null;
        }
        try {
            ModuleDescriptor md = parser.parseDescriptor(data.getSettings(), cachedIvyURL, ivyRef.getResource(), doValidate(data));
            Message.debug("\t"+getName()+": parsed downloaded md file for "+mrid+" parsed="+md.getModuleRevisionId());
           
           
            // check if we should delete old artifacts
            boolean deleteOldArtifacts = false;
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

     *
     * Note: the method signature is way too long, we should use a class to store the settings of the resolve.
     */
    public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException, IOException {
        URLResource res = new URLResource(ivySource);
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
        Message.verbose("using "+parser+" to parse "+ivySource);
        ModuleDescriptor md = parser.parseDescriptor(_settings, ivySource, options.isValidate());
        String revision = options.getRevision();
        if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
            revision = Ivy.getWorkingRevision();
        }
        if (revision != null) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

     * Resolve dependencies of a module described by an ivy file.
     */
    public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
            IOException {
        URLResource res = new URLResource(ivySource);
        ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
        Message.verbose("using " + parser + " to parse " + ivySource);
        ModuleDescriptor md = parser.parseDescriptor(settings, ivySource, options.isValidate());
        String revision = options.getRevision();
        if (revision == null && md.getResolvedModuleRevisionId().getRevision() == null) {
            revision = Ivy.getWorkingRevision();
        }
        if (revision != null) {
View Full Code Here

Examples of org.apache.ivy.plugins.parser.ModuleDescriptorParser

                            // we can't determine the revision from the pattern, get it
                            // from the moduledescriptor itself
                            File temp = File.createTempFile("ivy", artifact.getExt());
                            temp.deleteOnExit();
                            repository.get(res.getName(), temp);
                            ModuleDescriptorParser parser =
                                ModuleDescriptorParserRegistry.getInstance().getParser(res);
                            ModuleDescriptor md =
                                parser.parseDescriptor(
                                    getSettings(), temp.toURI().toURL(), res, false);
                            revision = md.getRevision();
                            if ((revision == null) || (revision.length() == 0)) {
                                revision = "working@" + name;
                            }
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.