if (buildFileSets.isEmpty()) {
throw new BuildException(
"at least one nested fileset should be provided in ivy build list");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
ivyFilePath = getProperty(ivyFilePath, settings, "ivy.buildlist.ivyfilepath");
Path path = new Path(getProject());
Map buildFiles = new HashMap(); // Map (ModuleDescriptor -> File buildFile)
List independent = new ArrayList();
List noDescriptor = new ArrayList();
Collection mds = new ArrayList();
Set rootModuleNames = new LinkedHashSet();
if (!"*".equals(root)) {
StringTokenizer st = new StringTokenizer(root, delimiter);
while (st.hasMoreTokens()) {
rootModuleNames.add(st.nextToken());
}
}
Set leafModuleNames = new LinkedHashSet();
if (!"*".equals(leaf)) {
StringTokenizer st = new StringTokenizer(leaf, delimiter);
while (st.hasMoreTokens()) {
leafModuleNames.add(st.nextToken());
}
}
Set restartFromModuleNames = new LinkedHashSet();
if (!"*".equals(restartFrom)) {
StringTokenizer st = new StringTokenizer(restartFrom, delimiter);
// Only accept one (first) module
restartFromModuleNames.add(st.nextToken());
}
for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
FileSet fs = (FileSet) iter.next();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] builds = ds.getIncludedFiles();
for (int i = 0; i < builds.length; i++) {
File buildFile = new File(ds.getBasedir(), builds[i]);
File ivyFile = getIvyFileFor(buildFile);
if (!ivyFile.exists()) {
onMissingDescriptor(buildFile, ivyFile, noDescriptor);
} else {
try {
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
.parseDescriptor(settings, ivyFile.toURI().toURL(),
doValidate(settings));
buildFiles.put(md, buildFile);
mds.add(md);
Message.debug("Add " + md.getModuleRevisionId().getModuleId());
} catch (Exception ex) {
if (haltOnError) {
throw new BuildException("impossible to parse ivy file for "
+ buildFile + ": ivyfile=" + ivyFile + " exception=" + ex, ex);
} else {
Message.warn("impossible to parse ivy file for " + buildFile
+ ": ivyfile=" + ivyFile + " exception=" + ex.getMessage());
Message.info("\t=> adding it at the beginning of the path");
independent.add(buildFile);
}
}
}
}
}
List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, leafModuleNames,
"leaf");
List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, rootModuleNames,
"root");
List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
restartFromModuleNames, "restartFrom");
if (!rootModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on roots " + rootModuleNames);
mds = filterModulesFromRoot(mds, rootModuleDescriptors);
}
if (!leafModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on leafs " + leafModuleNames);
mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
}
List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
if (!OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
File buildFile = (File) iter.next();
addBuildFile(path, buildFile);