((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName(), ivyRef.getRevision(), mrid.getExtraAttributes()));
String revision = getRevision(ivyRef, mrid, md); ((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName(), revision, mrid.getExtraAttributes()));
    public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {        DependencyDescriptor systemDd = dd;        dd = fromSystem(dd);                clearIvyAttempts();        boolean downloaded = false;        boolean searched = false;        ModuleRevisionId mrid = dd.getDependencyRevisionId();    	// check revision		int index = mrid.getRevision().indexOf("@");		if (index != -1 && !mrid.getRevision().substring(index+1).equals(_workspaceName)) {            Message.verbose("\t"+getName()+": unhandled revision => "+mrid.getRevision());            return null;		}                if (getIvy().getVersionMatcher().isDynamic(mrid) && !acceptLatest()) {            Message.error("dynamic revisions not handled by "+getClass().getName()+". impossible to resolve "+mrid);            return null;        }    	        boolean isChangingRevision = getChangingMatcher().matches(mrid.getRevision());                boolean isChangingDependency = isChangingRevision || dd.isChanging();        // if we do not have to check modified and if the revision is exact and not changing,          // we first search for it in cache        ResolvedModuleRevision cachedRmr = null;        boolean checkedCache = false;        if (!getIvy().getVersionMatcher().isDynamic(mrid) && !isCheckmodified() && !isChangingDependency) {            cachedRmr = findModuleInCache(data, mrid);            checkedCache = true;            if (cachedRmr != null) {                if (cachedRmr.getDescriptor().isDefault() && cachedRmr.getResolver() != this) {                    Message.verbose("\t"+getName()+": found revision in cache: "+mrid+" (resolved by "+cachedRmr.getResolver().getName()+"): but it's a default one, maybe we can find a better one");                } else {                    Message.verbose("\t"+getName()+": revision in cache: "+mrid);                    return toSystem(cachedRmr);                }            }        }        URL cachedIvyURL = null;        ResolvedResource ivyRef = findIvyFileRef(dd, data);        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);                logIvyNotFound(mrid);                return null;            }            parser = XmlModuleDescriptorParser.getInstance();            md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd.getAllDependencyArtifactsIncludes());            ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);            if (artifactRef == null) {                Message.verbose("\t"+getName()+": no ivy file nor artifact found for "+mrid);                logIvyNotFound(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++) {                        logArtifactNotFound(artifacts[j]);                    }                }                if (!checkedCache) {                    cachedRmr = findModuleInCache(data, mrid);                }                if (cachedRmr != null) {                    Message.verbose("\t"+getName()+": revision in cache: "+mrid);                    return toSystem(cachedRmr);                                    }                return null;            } else {                Message.verbose("\t"+getName()+": no ivy file found for "+mrid+": using default data");                            logIvyNotFound(mrid);    	        if (getIvy().getVersionMatcher().isDynamic(mrid)) {    	            md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), artifactRef.getRevision(), mrid.getExtraAttributes()));    	        }            }        } 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) {                        ((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName(), ivyRef.getRevision(), mrid.getExtraAttributes()));                    } 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 (getIvy().getVersionMatcher().isDynamic(resolvedMrid)) {            resolvedMrid = md.getResolvedModuleRevisionId();            if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0) {                if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {                    resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), (_envDependent?"##":"")+DATE_FORMAT.format(data.getDate())+"@"+_workspaceName);                } else {                    resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), 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 (!getIvy().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.getIvy().getIvyFileInCache(data.getCache(), 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.getIvy().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, ivyRef.getResource(), ivyFile, systemMd);                long repLastModified = ivyRef.getLastModified();                if (repLastModified > 0) {                    ivyFile.setLastModified(repLastModified);                }	        }        } catch (Exception e) {            if (ivyRef == null) {                Message.warn("impossible to create ivy file in cache for module : " + resolvedMrid);            } else {            	e.printStackTrace();                Message.warn("impossible to copy ivy file to cache : "+ivyRef.getResource());            }        }                data.getIvy().saveResolver(data.getCache(), systemMd, getName());        data.getIvy().saveArtResolver(data.getCache(), systemMd, getName());        return new DefaultModuleRevision(this, this, systemMd, searched, downloaded, cachedIvyURL);    }