You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/04/06 16:25:33 UTC
svn commit: r526217 - in
/incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse:
IvyPlugin.java cpcontainer/IvyClasspathContainer.java
Author: xavier
Date: Fri Apr 6 09:25:32 2007
New Revision: 526217
URL: http://svn.apache.org/viewvc?view=rev&rev=526217
Log:
Support javadoc and sources even in modules where they are not declared (IVYDE-46)
I've added support for that, but I still have to add an option to disable it, since it can cause slowness when artifacts are not available, IvyDE will check for them at each resolve
Modified:
incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
Modified: incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?view=diff&rev=526217&r1=526216&r2=526217
==============================================================================
--- incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (original)
+++ incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Fri Apr 6 09:25:32 2007
@@ -549,6 +549,14 @@
return !"".equals(getRetrievePatternHerited(project));
}
+ public static boolean shouldTestNonDeclaredSources(IJavaProject project) {
+ return true; // TODO: add settings for that
+ }
+
+ public static boolean shouldTestNonDeclaredJavadocs(IJavaProject project) {
+ return true; // TODO: add settings for that
+ }
+
public IEclipsePreferences getProjectPreferences(final IJavaProject project) {
IScopeContext projectScope = new ProjectScope(project.getProject());
IEclipsePreferences projectNode = projectScope.getNode(ID);
Modified: incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?view=diff&rev=526217&r1=526216&r2=526217
==============================================================================
--- incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java (original)
+++ incubator/ivy/ivyde/trunk/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java Fri Apr 6 09:25:32 2007
@@ -10,9 +10,11 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.CacheManager;
@@ -24,8 +26,11 @@
import org.apache.ivy.core.event.resolve.EndResolveDependencyEvent;
import org.apache.ivy.core.event.resolve.StartResolveDependencyEvent;
import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.DownloadStatus;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.core.retrieve.RetrieveOptions;
@@ -207,7 +212,7 @@
status[0] = Status.CANCEL_STATUS;
return;
}
- //eventually do a retrieve
+ // call retrieve if required
if(IvyPlugin.shouldDoRetrieve(_javaProject)) {
_monitor.setTaskName("retrieving dependencies in "+IvyPlugin.getFullRetrievePatternHerited(_javaProject));
_ivy.retrieve(
@@ -336,22 +341,58 @@
return _cacheMgr.getArchiveFileInCache(a);
}
}
- return null;
+ if (IvyPlugin.shouldTestNonDeclaredSources(_javaProject)) {
+ // source artifact not found in resolved artifacts,
+ // try to see if a non declared one is available
+ Map extraAtt = new HashMap(artifact.getExtraAttributes());
+ extraAtt.put("classifier", "sources");
+ Artifact sourceArtifact = new DefaultArtifact(
+ artifact.getModuleRevisionId(),
+ artifact.getPublicationDate(),
+ artifact.getName(),
+ "source",
+ "jar",
+ extraAtt
+ );
+ _ivy.getResolveEngine().download(sourceArtifact, _cacheMgr, false);
+ File source = _cacheMgr.getArchiveFileInCache(sourceArtifact);
+ return source.exists()?source:null;
+ } else {
+ return null;
+ }
}
private File getJavadocArtifact(Artifact artifact, Collection all)
{
- for (Iterator iter = all.iterator(); iter.hasNext();) {
- Artifact a = (Artifact)iter.next();
- if (a.getName().equals(artifact.getName()) &&
- a.getModuleRevisionId().equals(artifact.getModuleRevisionId()) &&
- a.getId().equals(artifact.getId()) &&
- IvyPlugin.isJavadoc(_javaProject, a))
- {
- return _cacheMgr.getArchiveFileInCache(a);
- }
+ for (Iterator iter = all.iterator(); iter.hasNext();) {
+ Artifact a = (Artifact)iter.next();
+ if (a.getName().equals(artifact.getName()) &&
+ a.getModuleRevisionId().equals(artifact.getModuleRevisionId()) &&
+ a.getId().equals(artifact.getId()) &&
+ IvyPlugin.isJavadoc(_javaProject, a))
+ {
+ return _cacheMgr.getArchiveFileInCache(a);
+ }
+ }
+ if (IvyPlugin.shouldTestNonDeclaredSources(_javaProject)) {
+ // javadoc artifact not found in resolved artifacts,
+ // try to see if a non declared one is available
+ Map extraAtt = new HashMap(artifact.getExtraAttributes());
+ extraAtt.put("classifier", "javadocs");
+ Artifact javadocArtifact = new DefaultArtifact(
+ artifact.getModuleRevisionId(),
+ artifact.getPublicationDate(),
+ artifact.getName(),
+ "javadoc",
+ "jar",
+ extraAtt
+ );
+ _ivy.getResolveEngine().download(javadocArtifact, _cacheMgr, false);
+ File javadoc = _cacheMgr.getArchiveFileInCache(javadocArtifact);
+ return javadoc.exists()?javadoc:null;
+ } else {
+ return null;
}
- return null;
}
}