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);
}
}