List<ModuleDescriptor> dependencies = new ArrayList<ModuleDescriptor>();
// first, let's resolve the ant scripts, just the scripts, not their possible jar dependencies, thus only
// the configuration "default"
XmlReportParser xmlreport = null;
if (!refresh) {
// first try to relad the resolve from the last report
xmlreport = getResolveReport(ivy, md.getModuleRevisionId().getModuleId(), "default", ivyfile);
}
if (xmlreport != null) {
// collect the ant scripts
artifacts = xmlreport.getArtifactReports();
// collect the descriptor associated with each ant script
ModuleRevisionId[] depIds = xmlreport.getDependencyRevisionIds();
for (int i = 0; i < depIds.length; i++) {
File depIvyFile = xmlreport.getMetadataArtifactReport(depIds[i]).getLocalFile();
dependencies.add(getMd(ivy, depIvyFile));
}
} else {
// do a full resolve
// if in a retrieved setup, clean the repo and repopulate it
maybeClearLocalRepo();
maybeRetrieve(md, "default");
// launch the actual resolve
ResolveReport resolveReport = resolve(ivy, md, "default");
ConfigurationResolveReport confReport = resolveReport.getConfigurationReport("default");
// collect the ant scripts
artifacts = confReport.getAllArtifactsReports();
// collect the descriptor associated with each ant script
Set<ModuleRevisionId> mrids = confReport.getModuleRevisionIds();
for (ModuleRevisionId mrid : mrids) {
dependencies.add(confReport.getDependency(mrid).getDescriptor());
}
}
int nbPaths = 1;
// save the collection of ant scripts as a path
Path antScriptsPath = makePath("easyant.antscripts", sortArtifacts(ivy, artifacts, dependencies));
// now, for each ant script descriptor, search for an ivy configuration which is used by the ant script
// itself
for (ModuleDescriptor depmd : dependencies) {
log("Searching for external conf for " + depmd.getModuleRevisionId(), Project.MSG_VERBOSE);
String[] confs = depmd.getConfigurationsNames();
log("configurations for " + depmd.getModuleRevisionId() + " : " + Arrays.toString(confs),
Project.MSG_DEBUG);
// some trick here: launching a resolve on a module won't resolve the artifacts of the module itself but
// only of its dependencies. So we'll create a mock one which will depend on the real one
String mockOrg = "_easyant_mocks_";
String mockName = depmd.getModuleRevisionId().getOrganisation() + "__"
+ depmd.getModuleRevisionId().getName();
ModuleRevisionId mockmrid = ModuleRevisionId.newInstance(mockOrg, mockName, depmd.getModuleRevisionId()
.getBranch(), depmd.getRevision(), depmd.getExtraAttributes());
DefaultModuleDescriptor mock = new DefaultModuleDescriptor(mockmrid, depmd.getStatus(),
depmd.getPublicationDate(), depmd.isDefault());
DefaultDependencyDescriptor mockdd = new DefaultDependencyDescriptor(depmd.getModuleRevisionId(), false);
for (String conf : confs) {
mock.addConfiguration(new Configuration(conf));
mockdd.addDependencyConfiguration(conf, conf);
}
mock.addDependency(mockdd);
for (String conf : confs) {
if (conf.equals("default")) {
continue;
}
nbPaths++;
log("Found configuration " + conf, Project.MSG_VERBOSE);
// same process than for the ant script:
// * trust the last resolve report
// * or launch a full resolve
// A full resolve might trigger a retrieve to populate the local repo
XmlReportParser xmldepreport = null;
if (!refresh) {
xmldepreport = getResolveReport(ivy, mock.getModuleRevisionId().getModuleId(), conf, null);
}
if (xmldepreport != null) {
artifacts = xmldepreport.getArtifactReports();
} else {
maybeRetrieve(mock, conf);
ResolveReport resolveReport = resolve(ivy, mock, conf);
ConfigurationResolveReport confReport = resolveReport.getConfigurationReport(conf);
artifacts = confReport.getAllArtifactsReports();