// moreover, we have dependency artifacts description
// these descritions are thus used as if they were declared in the module
// descriptor. If one is not really present, the error will be raised
// at download time
for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(), dad
.getUrl(), dad.getExtraAttributes()));
}
} else {
Set includes = (Set) dependencyIncludes.get(rootModuleConf);
if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
&& (includes == null || includes.isEmpty())) {
// no artifacts / includes: we get all artifacts as defined by the descriptor
for (Iterator iter = confs.iterator(); iter.hasNext();) {
String conf = (String) iter.next();
artifacts.addAll(Arrays.asList(md.getArtifacts(conf)));
}
} else {
// we have to get only artifacts listed as "includes"
// first we get all artifacts as defined by the module descriptor
// and classify them by artifact id
Map allArtifacts = new HashMap();
for (Iterator iter = confs.iterator(); iter.hasNext();) {
String conf = (String) iter.next();
Artifact[] arts = md.getArtifacts(conf);
for (int i = 0; i < arts.length; i++) {
allArtifacts.put(arts[i].getId().getArtifactId(), arts[i]);
}
}
// now we add caller defined ones
for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
dad.getUrl(), dad.getExtraAttributes()));
}
// and now we filter according to include rules
for (Iterator it = includes.iterator(); it.hasNext();) {
IncludeRule dad = (IncludeRule) it.next();
Collection arts = findArtifactsMatching(dad, allArtifacts);
if (arts.isEmpty()) {
Message.error("a required artifact is not listed by module descriptor: "
+ dad.getId());
// we remove it from required list to prevent message to be displayed more
// than once
it.remove();
} else {
Message.debug(this + " in " + rootModuleConf + ": including " + arts);