ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r730083 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse: CHANGES.txt src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
Date Tue, 30 Dec 2008 10:12:32 GMT
Author: xavier
Date: Tue Dec 30 02:12:32 2008
New Revision: 730083

URL: http://svn.apache.org/viewvc?rev=730083&view=rev
Log:
FIX: source and javadoc attachment regression (IVYDE-146)

Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt?rev=730083&r1=730082&r2=730083&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt Tue Dec 30 02:12:32 2008
@@ -7,6 +7,7 @@
 - FIX: The retrieve configuration doesn't support '*' as accepted types (IVYDE-137) (thanks
to Daniel Becheanu)
 - FIX: NPE when a project:/// path is used and path does not exist (IVYDE-144)
 - FIX: project://[projectname]/ scheme for settings only work with java projects, not simple
projects (IVYDE-145)
+- FIX: source and javadoc attachment regression (IVYDE-146)
 
   version 2.0.0 beta1
 ==========================

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=730083&r1=730082&r2=730083&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
Tue Dec 30 02:12:32 2008
@@ -48,6 +48,7 @@
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 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.ResolveOptions;
 import org.apache.ivy.core.retrieve.RetrieveOptions;
@@ -174,13 +175,11 @@
         }
     }
 
-    private Map listDependencies(ResolveReport r) {
+    private Map dependenciesAsMap(ResolveReport r) {
         Map result = new HashMap();
-        Iterator it = r.getDependencies().iterator();
-        while (it.hasNext()) {
+        for (Iterator it = r.getDependencies().iterator(); it.hasNext();) {
             IvyNode node = (IvyNode) it.next();
-            ModuleRevisionId moduleId = node.getId();
-            result.put(moduleId.getName(), moduleId);
+            result.put(node.getId(), node);
         }
         return result;
     }
@@ -216,7 +215,7 @@
                     Thread.currentThread().setContextClassLoader(
                         IvyResolveJob.class.getClassLoader());
                     try {
-                        Map dependencies = Collections.EMPTY_MAP;
+                        Map/*<ModuleRevisionId, IvyNode>*/ dependencies = Collections.EMPTY_MAP;
                         if (usePreviousResolveIfExist) {
                             if (conf.confs.size() == 1 && "*".equals(conf.confs.get(0)))
{
                                 confs = md.getConfigurationsNames();
@@ -262,7 +261,7 @@
                                     ResolveReport r = ivy.resolve(md, resolveOption);
                                     all.addAll(Arrays.asList(r.getArtifactsReports(null,
false)));
                                     confs = r.getConfigurations();
-                                    dependencies = listDependencies(r);
+                                    dependencies = dependenciesAsMap(r);
                                     problemMessages.addAll(r.getAllProblemMessages());
                                     maybeRetrieve(md);
 
@@ -281,7 +280,7 @@
                                 false)));
                             confs = report.getConfigurations();
 
-                            dependencies = listDependencies(report);
+                            dependencies = dependenciesAsMap(report);
 
                             if (monitor.isCanceled()) {
                                 status[0] = Status.CANCEL_STATUS;
@@ -459,7 +458,8 @@
         }
     }
 
-    private IClasspathEntry[] artifacts2ClasspathEntries(Collection all, Map dependencies)
{
+    private IClasspathEntry[] artifacts2ClasspathEntries(
+            Collection all, Map/*<ModuleRevisionId, IvyNode>*/ dependencies) {
         IClasspathEntry[] classpathEntries;
         Collection paths = new LinkedHashSet();
 
@@ -487,25 +487,21 @@
             boolean usedProject = false;
             if (conf.isResolveInWorkspace()) {
                 ModuleId moduleId = artifact.getArtifact().getModuleRevisionId().getModuleId();
-                String moduleName = moduleId.getName();
-                ModuleRevisionId moduleRevisionId = (ModuleRevisionId) dependencies.get(moduleName);
-                if (moduleRevisionId != null) {
-                    IJavaProject project = (IJavaProject) idToJProject.get(moduleId);
-                    if (project != null && project.exists()) {
-                        IClasspathEntry entry = JavaCore.newProjectEntry(project.getPath());
-                        if (entry != null && !paths.contains(entry)) {
-                            paths.add(entry);
-                        }
-                        usedProject = true;
+                IJavaProject project = (IJavaProject) idToJProject.get(moduleId);
+                if (project != null && project.exists()) {
+                    IClasspathEntry entry = JavaCore.newProjectEntry(project.getPath());
+                    if (entry != null && !paths.contains(entry)) {
+                        paths.add(entry);
                     }
+                    usedProject = true;
                 }
             }
 
             if (!usedProject) {
                 if (artifact.getLocalFile() != null && accept(artifact.getArtifact()))
{
                     Path classpathArtifact = new Path(artifact.getLocalFile().getAbsolutePath());
-                    Path sourcesArtifact = getSourcesArtifactPath(artifact, all);
-                    Path javadocArtifact = getJavadocArtifactPath(artifact, all);
+                    Path sourcesArtifact = getSourcesArtifactPath(artifact, all, dependencies);
+                    Path javadocArtifact = getJavadocArtifactPath(artifact, all, dependencies);
                     paths.add(JavaCore.newLibraryEntry(classpathArtifact, getSourceAttachment(
                         classpathArtifact, sourcesArtifact), getSourceAttachmentRoot(
                         classpathArtifact, sourcesArtifact), null, getExtraAttribute(
@@ -537,7 +533,8 @@
         return null;
     }
 
-    private Path getSourcesArtifactPath(ArtifactDownloadReport adr, Collection all) {
+    private Path getSourcesArtifactPath(ArtifactDownloadReport adr, Collection all, 
+            Map/*<ModuleRevisionId, IvyNode>*/ dependencies) {
         Artifact artifact = adr.getArtifact();
         monitor.subTask("searching sources for " + artifact);
         for (Iterator iter = all.iterator(); iter.hasNext();) {
@@ -550,10 +547,29 @@
                 return new Path(otherAdr.getLocalFile().getAbsolutePath());
             }
         }
+        // we haven't found source artifact in resolved artifacts, 
+        // let's look in the module declaring the artifact
+        IvyNode node = (IvyNode) dependencies.get(artifact.getId().getModuleRevisionId());
+        if (node != null) {
+            Artifact[] artifacts = node.getDescriptor().getAllArtifacts();
+            for (int i = 0; i < artifacts.length; i++) {
+                Artifact metaArtifact = artifacts[i];
+                if (isSourceArtifactName(artifact.getName(), metaArtifact.getName())
+                    && isSources(metaArtifact)) {
+                    // we've found the source artifact, let's provision it
+                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(
+                        metaArtifact, new DownloadOptions());
+                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists())
{
+                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
+                    }
+                }
+            }
+        }
         return null;
     }
 
-    private Path getJavadocArtifactPath(ArtifactDownloadReport adr, Collection all) {
+    private Path getJavadocArtifactPath(ArtifactDownloadReport adr, Collection all, 
+            Map/*<ModuleRevisionId, IvyNode>*/ dependencies) {
         Artifact artifact = adr.getArtifact();
         monitor.subTask("searching javadoc for " + artifact);
         for (Iterator iter = all.iterator(); iter.hasNext();) {
@@ -566,6 +582,24 @@
                 return new Path(otherAdr.getLocalFile().getAbsolutePath());
             }
         }
+        // we haven't found javadoc artifact in resolved artifacts, 
+        // let's look in the module declaring the artifact
+        IvyNode node = (IvyNode) dependencies.get(artifact.getId().getModuleRevisionId());
+        if (node != null) {
+            Artifact[] artifacts = node.getDescriptor().getAllArtifacts();
+            for (int i = 0; i < artifacts.length; i++) {
+                Artifact metaArtifact = artifacts[i];
+                if (isJavadocArtifactName(artifact.getName(), metaArtifact.getName())
+                    && isJavadoc(metaArtifact)) {
+                    // we've found the javadoc artifact, let's provision it
+                    ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(
+                        metaArtifact, new DownloadOptions());
+                    if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists())
{
+                        return new Path(metaAdr.getLocalFile().getAbsolutePath());
+                    }
+                }
+            }
+        }
         return null;
     }
 



Mime
View raw message