IMPROVEMENT: In the ResolveReport class, add the possibility to filter the evicted module while getting the list of DownloadArtifact (IVY-704) (thanks to Nicolas Lalevée)

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@613184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2008-01-18 15:23:43 +00:00
parent c6e9f1f953
commit f86bb7973b
9 changed files with 123 additions and 47 deletions

View File

@ -71,6 +71,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
- IMPROVEMENT: Flexible cache management (IVY-399 - not completed yet)
- IMPROVEMENT: Decrease memory footprint (IVY-662)
- IMPROVEMENT: Downgrade Ant version requirement to 1.6 to build Ivy (IVY-687)
- IMPROVEMENT: In the ResolveReport class, add the possibility to filter the evicted module while getting the list of DownloadArtifact (IVY-704) (thanks to Nicolas Lalevée)
- FIX: Ivy swallows ParseException when using a latest strategy requiring module descriptors (IVY-702) (thanks to Nicolas Lalevée)
- FIX: Problem with cached Ivy files which have extra attributes (IVY-693)

View File

@ -34,7 +34,7 @@ import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.extendable.ExtendableItem;
/**
*
* Decriptor of a module. This is the Java representation of an ivy.xml
*/
public interface ModuleDescriptor extends ExtendableItem, ArtifactInfo {
public static final String DEFAULT_CONFIGURATION = "default";

View File

@ -19,6 +19,8 @@ package org.apache.ivy.core.module.id;
/**
* Identifies an artifact in a module, without revision information
*
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ArtifactId {
private ModuleId mid;

View File

@ -23,7 +23,9 @@ import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
/**
* identifies an artifact in a particular module revision
* Identifies an artifact in a particular module revision
*
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ArtifactRevisionId extends UnmodifiableExtendableItem {
public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type,

View File

@ -23,7 +23,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* Identifies a module, without revision information
*
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ModuleId implements Comparable {
static final String ENCODE_SEPARATOR = ":#@#:";

View File

@ -30,7 +30,9 @@ import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
/**
*
* Identifies a module in a particular version
*
* @see <a href="package-summary.html">org.apache.ivy.core.module.id</a>
*/
public class ModuleRevisionId extends UnmodifiableExtendableItem {
private static final String ENCODE_SEPARATOR = ModuleId.ENCODE_SEPARATOR;
@ -43,7 +45,6 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
private static final String REV_STRICT_CHARS_PATTERN
= "[a-zA-Z0-9\\-/\\._+=,\\[\\]\\{\\}\\(\\):@]";
private static final Map/*<ModuleRevisionId, ModuleRevisionId>*/ CACHE = new WeakHashMap();
/**

View File

@ -71,6 +71,10 @@ public class ArtifactDownloadReport {
return artifact.getName();
}
/**
*
* @return the type of the downloaded artifact
*/
public String getType() {
return artifact.getType();
}

View File

@ -44,7 +44,7 @@ import org.apache.ivy.plugins.report.XmlReportParser;
import org.apache.ivy.util.Message;
/**
*
* Represents a whole resolution report for a module but for a specific configuration
*/
public class ConfigurationResolveReport {
@ -177,6 +177,15 @@ public class ConfigurationResolveReport {
return (IvyNode[]) evicted.toArray(new IvyNode[evicted.size()]);
}
private Set/*<ModuleRevisionId>*/ getEvictedMrids() {
Set/*<ModuleRevisionId>*/ evicted = new HashSet();
IvyNode[] evictedNodes = getEvictedNodes();
for (int i = 0; i < evictedNodes.length; i++) {
evicted.add(evictedNodes[i].getId());
}
return evicted;
}
public IvyNode[] getDownloadedNodes() {
List downloaded = new ArrayList();
for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
@ -255,41 +264,67 @@ public class ConfigurationResolveReport {
return total;
}
/**
* Get every report on the download requests.
*
* @return the list of reports, never <code>null</code>
*/
public ArtifactDownloadReport[] getAllArtifactsReports() {
List result = new ArrayList();
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
Collection reports = (Collection) iter.next();
result.addAll(reports);
}
return (ArtifactDownloadReport[]) result.toArray(new ArtifactDownloadReport[result.size()]);
return getArtifactsReports(null, true);
}
/**
* Get the report on the download requests. The list of download report can be restricted to a
* specific download status, and also remove the download report for the evicted modules.
*
* @param downloadStatus
* the status of download to retreive. Set it to <code>null</code> for no
* restriction on the download status
* @param withEvicted
* set it to <code>true</code> if the report for the evicted modules have to be
* retrieved.
* @return the list of reports, never <code>null</code>
* @see ArtifactDownloadReport
*/
public ArtifactDownloadReport[] getArtifactsReports(
DownloadStatus downloadStatus, boolean withEvicted) {
Collection all = new HashSet();
Collection evictedMrids = null;
if (!withEvicted) {
evictedMrids = getEvictedMrids();
}
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
Collection reports = (Collection) iter.next();
for (Iterator itReport = reports.iterator(); itReport.hasNext();) {
ArtifactDownloadReport report = (ArtifactDownloadReport) itReport.next();
if (downloadStatus != null && report.getDownloadStatus() != downloadStatus) {
continue;
}
if (withEvicted
|| !evictedMrids.contains(report.getArtifact().getModuleRevisionId())) {
all.add(report);
}
}
}
return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
}
/**
* Get the report on the sucessfull download requests with the evicted modules
*
* @return the list of reports, never <code>null</code>
*/
public ArtifactDownloadReport[] getDownloadedArtifactsReports() {
List result = new ArrayList();
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
Collection reports = (Collection) iter.next();
for (Iterator iterator = reports.iterator(); iterator.hasNext();) {
ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next();
if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
result.add(adr);
}
}
}
return (ArtifactDownloadReport[]) result.toArray(new ArtifactDownloadReport[result.size()]);
return getArtifactsReports(DownloadStatus.SUCCESSFUL, true);
}
/**
* Get the report on the failed download requests with the evicted modules
*
* @return the list of reports, never <code>null</code>
*/
public ArtifactDownloadReport[] getFailedArtifactsReports() {
List result = new ArrayList();
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
Collection reports = (Collection) iter.next();
for (Iterator iterator = reports.iterator(); iterator.hasNext();) {
ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next();
if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
result.add(adr);
}
}
}
return (ArtifactDownloadReport[]) result.toArray(new ArtifactDownloadReport[result.size()]);
return getArtifactsReports(DownloadStatus.FAILED, true);
}
public boolean hasError() {

View File

@ -42,12 +42,15 @@ import org.apache.ivy.util.filter.Filter;
public class ResolveReport {
private ModuleDescriptor md;
/** String conf -> ConfigurationResolveReport report */
private Map confReports = new LinkedHashMap();
private List problemMessages = new ArrayList();
private List dependencies = new ArrayList();
// the list of all dependencies resolved, ordered from the more dependent to the less dependent
/**
* the list of all dependencies resolved, ordered from the more dependent to the less dependent
*/
private List dependencies = new ArrayList();
private List artifacts = new ArrayList();
@ -89,7 +92,7 @@ public class ResolveReport {
return hasError;
}
public void output(ReportOutputter[] outputters, ResolutionCacheManager cacheMgr)
public void output(ReportOutputter[] outputters, ResolutionCacheManager cacheMgr)
throws IOException {
for (int i = 0; i < outputters.length; i++) {
outputters[i].output(this, cacheMgr);
@ -118,20 +121,46 @@ public class ResolveReport {
return (IvyNode[]) all.toArray(new IvyNode[all.size()]);
}
/**
* Get every report on the download requests.
*
* @return the list of reports, never <code>null</code>
*/
public ArtifactDownloadReport[] getFailedArtifactsReports() {
Collection all = new HashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
all.addAll(Arrays.asList(report.getFailedArtifactsReports()));
}
return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
return getArtifactsReports(DownloadStatus.FAILED, true);
}
/**
* Get every report on the download requests.
*
* @return the list of reports, never <code>null</code>
*/
public ArtifactDownloadReport[] getAllArtifactsReports() {
return getArtifactsReports(null, true);
}
/**
* Get the report on the download requests. The list of download report can be restricted to a
* specific download status, and also remove the download report for the evicted modules.
*
* @param downloadStatus
* the status of download to retreive. Set it to <code>null</code> for no
* restriction on the download status
* @param withEvicted
* set it to <code>true</code> if the report for the evicted modules have to be
* retrieved, <code>false</code> to exclude reports from modules evicted in all
* configurations.
* @return the list of reports, never <code>null</code>
* @see ConfigurationResolveReport#getArtifactsReports(DownloadStatus, boolean)
*/
public ArtifactDownloadReport[] getArtifactsReports(
DownloadStatus downloadStatus, boolean withEvicted) {
Collection all = new HashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
all.addAll(Arrays.asList(report.getAllArtifactsReports()));
ArtifactDownloadReport[] reports =
report.getArtifactsReports(downloadStatus, withEvicted);
all.addAll(Arrays.asList(reports));
}
return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
}
@ -209,7 +238,7 @@ public class ResolveReport {
* Returns the list of all dependencies concerned by this report as a List of IvyNode ordered
* from the more dependent to the least one
*
* @return The list of all dependencies.
* @return The list of all dependencies.
*/
public List getDependencies() {
return dependencies;
@ -219,7 +248,7 @@ public class ResolveReport {
* Returns the list of all artifacts which should be downloaded per this resolve To know if the
* artifact have actually been downloaded use information found in ConfigurationResolveReport.
*
* @return The list of all artifacts.
* @return The list of all artifacts.
*/
public List getArtifacts() {
return artifacts;
@ -262,7 +291,7 @@ public class ResolveReport {
public void setDownloadSize(long size) {
this.downloadSize = size;
}
/**
* The total size of downloaded artifacts, in bytes.
* <p>