ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1374795 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: cpcontainer/IvyClasspathContainerMapper.java resolve/IvyResolver.java resolve/ResolveResult.java
Date Sun, 19 Aug 2012 17:04:17 GMT
Author: hibou
Date: Sun Aug 19 17:04:15 2012
New Revision: 1374795

URL: http://svn.apache.org/viewvc?rev=1374795&view=rev
Log:
Restore the artifact gathering by dependency (destroyed by r1374767) which makes the source
attachement work with Maven repositories

Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/ResolveResult.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java?rev=1374795&r1=1374794&r2=1374795&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
Sun Aug 19 17:04:15 2012
@@ -71,7 +71,7 @@ public class IvyClasspathContainerMapper
 
     private final Collection/* <ArtifactDownloadReport> */all;
 
-    private final Map/* <ModuleRevisionId, List<Artifact>> */artifactsByDependency;
+    private final Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency;
 
     private final Map/*
                       * <ArtifactDownloadReport , Set<String>>
@@ -222,12 +222,12 @@ public class IvyClasspathContainerMapper
         // we haven't found source artifact in resolved artifacts,
         // let's look in the module declaring the artifact
         ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
-        List artifacts = (List/*<Artifact>*/) artifactsByDependency.get(mrid);
+        Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
         if (artifacts != null) {
             Artifact foundArtifact = null;
             int nbFound = 0;
-            for (int i = 0; i < artifacts.size(); i++) {
-                Artifact metaArtifact = (Artifact) artifacts.get(i);
+            for (int i = 0; i < artifacts.length; i++) {
+                Artifact metaArtifact = artifacts[i];
                 if (matcher.match(metaArtifact)) {
                     if (matcher.matchName(artifact, metaArtifact.getName())) {
                         // we've found a matching artifact, let's provision it

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java?rev=1374795&r1=1374794&r2=1374795&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/IvyResolver.java
Sun Aug 19 17:04:15 2012
@@ -29,22 +29,20 @@ import java.util.Set;
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.IvyPatternHelper;
-import org.apache.ivy.core.event.download.PrepareDownloadEvent;
-import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ArtifactDownloadReport;
-import org.apache.ivy.core.report.DownloadReport;
-import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.DownloadOptions;
 import org.apache.ivy.core.resolve.IvyNode;
+import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 import org.apache.ivy.core.retrieve.RetrieveOptions;
 import org.apache.ivy.plugins.report.XmlReportParser;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.filter.ArtifactTypeFilter;
-import org.apache.ivy.util.filter.Filter;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
 import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
@@ -206,6 +204,7 @@ public class IvyResolver {
                     XmlReportParser parser = new XmlReportParser();
                     parser.parse(report);
                     result.addArtifactReports(parser.getArtifactReports());
+                    findAllArtifactOnRefresh(ivy, parser, result);
                 } catch (ParseException e) {
                     Message.info("\n\nIVYDE: Error while parsing the report " + report
                             + ". Falling back by doing a resolve again.");
@@ -247,9 +246,47 @@ public class IvyResolver {
         }
         result.addArtifactReports(artifactReports);
 
+        collectArtifactsByDependency(report, result);
+
         return result;
     }
 
+    /**
+     * Populate the map of artifact. The map should be populated by metadata in cache as
this is
+     * called in the refresh process.
+     * 
+     * @param parser
+     * @throws ParseException
+     */
+    private void findAllArtifactOnRefresh(Ivy ivy, XmlReportParser parser, ResolveResult
result)
+            throws ParseException {
+        ModuleRevisionId[] dependencyMrdis = parser.getDependencyRevisionIds();
+        for (int iDep = 0; iDep < dependencyMrdis.length; iDep++) {
+            DependencyResolver depResolver = ivy.getSettings().getResolver(dependencyMrdis[iDep]);
+            DefaultDependencyDescriptor depDescriptor = new DefaultDependencyDescriptor(
+                    dependencyMrdis[iDep], false);
+            ResolveOptions options = new ResolveOptions();
+            options.setRefresh(true);
+            options.setUseCacheOnly(true);
+            ResolvedModuleRevision dependency = depResolver.getDependency(depDescriptor,
+                new ResolveData(ivy.getResolveEngine(), options));
+            if (dependency != null) {
+                result.putArtifactsForDep(dependencyMrdis[iDep], dependency.getDescriptor()
+                        .getAllArtifacts());
+            }
+        }
+    }
+
+    private void collectArtifactsByDependency(ResolveReport r, ResolveResult result) {
+        for (Iterator it = r.getDependencies().iterator(); it.hasNext();) {
+            IvyNode node = (IvyNode) it.next();
+            if (node.getDescriptor() != null) {
+                result.putArtifactsForDep(node.getResolvedId(), node.getDescriptor()
+                        .getAllArtifacts());
+            }
+        }
+    }
+
     private IStatus maybeRetrieve(Ivy ivy, ModuleDescriptor md, ResolveResult result,
             IProgressMonitor monitor) throws IOException {
         if (retrievePattern == null || project == null) {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/ResolveResult.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/ResolveResult.java?rev=1374795&r1=1374794&r2=1374795&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/ResolveResult.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/resolve/ResolveResult.java
Sun Aug 19 17:04:15 2012
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.ResolveReport;
@@ -45,7 +46,7 @@ public class ResolveResult {
 
     private final ResolveReport report;
 
-    private Map/* <ModuleRevisionId, List<Artifact>> */artifactsByDependency
= new HashMap();
+    private Map/* <ModuleRevisionId, Artifact[]> */artifactsByDependency = new HashMap();
 
     /**
      * Mapping of resolved artifact to their retrieved path, <code>null</code>
if there were no
@@ -100,18 +101,10 @@ public class ResolveResult {
 
     void addArtifactReports(ArtifactDownloadReport[] reports) {
         artifactReports.addAll(Arrays.asList(reports));
-        for (int i = 0; i < reports.length; i++) {
-            if (reports[i].getDownloadStatus() != DownloadStatus.FAILED) {
-                Artifact a = reports[i].getArtifact();
-                List/* <Artifact> */artifacts = (List) artifactsByDependency.get(a
-                        .getModuleRevisionId());
-                if (artifacts == null) {
-                    artifacts = new ArrayList();
-                    artifactsByDependency.put(a.getModuleRevisionId(), artifacts);
-                }
-                artifacts.add(a);
-            }
-        }
+    }
+
+    void putArtifactsForDep(ModuleRevisionId resolvedId, Artifact[] allArtifacts) {
+        artifactsByDependency.put(resolvedId, allArtifacts);
     }
 
     /**
@@ -126,7 +119,7 @@ public class ResolveResult {
      * 
      * @return the reports of the artifacts by dependency
      */
-    public Map /* <ModuleRevisionId, List<Artifact>> */getArtifactsByDependency()
{
+    public Map /* <ModuleRevisionId, Artifact[]> */getArtifactsByDependency() {
         return artifactsByDependency;
     }
 



Mime
View raw message