Author: xavier Date: Fri Jan 18 07:23:43 2008 New Revision: 613184 URL: http://svn.apache.org/viewvc?rev=613184&view=rev Log: 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)
Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Fri Jan 18 07:23:43 2008 @@ -71,6 +71,7 @@ - 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) Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java Fri Jan 18 07:23:43 2008 @@ -34,7 +34,7 @@ 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"; Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactId.java Fri Jan 18 07:23:43 2008 @@ -19,6 +19,8 @@ /** * 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; Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java Fri Jan 18 07:23:43 2008 @@ -23,7 +23,9 @@ 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, Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java Fri Jan 18 07:23:43 2008 @@ -23,7 +23,9 @@ 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 = ":[EMAIL PROTECTED]:"; Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Fri Jan 18 07:23:43 2008 @@ -30,7 +30,9 @@ 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 @@ private static final String REV_STRICT_CHARS_PATTERN = "[a-zA-Z0-9\\-/\\._+=,\\[\\]\\{\\}\\(\\):@]"; - private static final Map/*<ModuleRevisionId, ModuleRevisionId>*/ CACHE = new WeakHashMap(); /** Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java Fri Jan 18 07:23:43 2008 @@ -71,6 +71,10 @@ return artifact.getName(); } + /** + * + * @return the type of the downloaded artifact + */ public String getType() { return artifact.getType(); } Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java Fri Jan 18 07:23:43 2008 @@ -44,7 +44,7 @@ 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 @@ 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 @@ 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); } - public ArtifactDownloadReport[] getDownloadedArtifactsReports() { - List result = new ArrayList(); + /** + * 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 iterator = reports.iterator(); iterator.hasNext();) { - ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next(); - if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) { - result.add(adr); + 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[]) result.toArray(new ArtifactDownloadReport[result.size()]); + 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() { + 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() { Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java?rev=613184&r1=613183&r2=613184&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Fri Jan 18 07:23:43 2008 @@ -42,12 +42,15 @@ 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 @@ 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 @@ 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 @@ * 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 @@ * 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 void setDownloadSize(long size) { this.downloadSize = size; } - + /** * The total size of downloaded artifacts, in bytes. * <p>