You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2008/05/23 21:21:42 UTC
svn commit: r659633 - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer:
IvyClasspathContainer.java IvyClasspathContainerConfiguration.java
IvyResolveJob.java IvydeContainerPage.java
Author: hibou
Date: Fri May 23 12:21:41 2008
New Revision: 659633
URL: http://svn.apache.org/viewvc?rev=659633&view=rev
Log:
fix of IVYDE-93. The bug introduced with the little refactoring of how error are logged
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=659633&r1=659632&r2=659633&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java Fri May 23 12:21:41 2008
@@ -26,6 +26,7 @@
import java.util.Comparator;
import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.util.Message;
import org.apache.ivyde.eclipse.IvyPlugin;
@@ -97,7 +98,6 @@
this.javaProject = javaProject;
this.path = path;
conf = new IvyClasspathContainerConfiguration(javaProject, path);
- conf.resolveModuleDescriptor();
ivyXmlFile = resolveFile(conf.ivyXmlPath);
this.classpathEntries = classpathEntries;
}
@@ -186,7 +186,11 @@
if (ivy == null) {
return null;
}
- job = new IvyResolveJob(this, usePreviousResolveIfExist, notify, conf, ivy);
+ ModuleDescriptor md = conf.getModuleDescriptor(ivy);
+ if (md == null) {
+ return null;
+ }
+ job = new IvyResolveJob(this, usePreviousResolveIfExist, notify, conf, ivy, md);
job.setUser(isUser);
job.setRule(RESOLVE_EVENT_RULE);
return job;
@@ -301,10 +305,14 @@
if (ivy == null) {
return null;
}
- String resolveId = ResolveOptions.getDefaultResolveId(conf.md);
+ ModuleDescriptor md = conf.getModuleDescriptorSafely(ivy);
+ if (md == null) {
+ return null;
+ }
+ String resolveId = ResolveOptions.getDefaultResolveId(md);
try {
return ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resolveId,
- conf.md.getConfigurationsNames()[0]).toURL();
+ md.getConfigurationsNames()[0]).toURL();
} catch (MalformedURLException e) {
// should never happen
IvyPlugin.log(IStatus.ERROR, "The URL generated by Ivy is incorrect", e);
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java?rev=659633&r1=659632&r2=659633&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java Fri May 23 12:21:41 2008
@@ -39,6 +39,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.MessageDialog;
/**
* path: org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER? ivyXmlPath=ivy.xml &confs=default
@@ -73,8 +74,6 @@
boolean alphaOrder;
- ModuleDescriptor md;
-
/**
* Constructor
*
@@ -362,21 +361,48 @@
return IvyClasspathUtil.split(values);
}
- public void resolveModuleDescriptor() throws ParseException, MalformedURLException, IOException {
- md = null;
- URL url;
+ File getIvyFile() {
+ File file;
if (javaProject != null) {
- IFile file = javaProject.getProject().getFile(ivyXmlPath);
- url = new File(file.getLocation().toOSString()).toURL();
+ IFile f = javaProject.getProject().getFile(ivyXmlPath);
+ file = new File(f.getLocation().toOSString());
} else {
- url = new File(ivyXmlPath).toURL();
+ file = new File(ivyXmlPath);
}
- Ivy ivy = IvyPlugin.getIvy(getInheritedIvySettingsPath());
- if (ivy == null) {
- return;
+ return file;
+ }
+
+ public ModuleDescriptor getModuleDescriptorSafely(Ivy ivy) {
+ File file = getIvyFile();
+ try {
+ return getModuleDescriptor(ivy);
+ } catch (MalformedURLException e) {
+ MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Incorrect path",
+ "The path to the ivy.xml file is incorrect: '" + file.getAbsolutePath()
+ + "'. \nError:" + e.getMessage());
+ return null;
+ } catch (ParseException e) {
+ MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Incorrect ivy file",
+ "The ivy file '" + file.getAbsolutePath() + "' could not be parsed. \nError:"
+ + e.getMessage());
+ return null;
+ } catch (IOException e) {
+ MessageDialog.openWarning(IvyPlugin.getActiveWorkbenchShell(), "Read error",
+ "The ivy file '" + file.getAbsolutePath() + "' could not be read. \nError:"
+ + e.getMessage());
+ return null;
}
- md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy.getSettings(), url,
- false);
+ }
+
+ public ModuleDescriptor getModuleDescriptor(Ivy ivy) throws MalformedURLException,
+ ParseException, IOException {
+ return getModuleDescriptor(ivy, getIvyFile());
+ }
+
+ public ModuleDescriptor getModuleDescriptor(Ivy ivy, File ivyFile)
+ throws MalformedURLException, ParseException, IOException {
+ return ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy.getSettings(),
+ ivyFile.toURL(), false);
}
}
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=659633&r1=659632&r2=659633&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 Fri May 23 12:21:41 2008
@@ -18,7 +18,6 @@
package org.apache.ivyde.eclipse.cpcontainer;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -67,7 +66,6 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
/**
@@ -88,21 +86,23 @@
private boolean _notify;
- private final Ivy ivy;
+ final Ivy ivy;
- private final IvyClasspathContainerConfiguration conf;
+ final IvyClasspathContainerConfiguration conf;
private final IvyClasspathContainer container;
+ final ModuleDescriptor md;
+
public IvyResolveJob(IvyClasspathContainer container, boolean usePreviousResolveIfExist,
- boolean notify, IvyClasspathContainerConfiguration conf, Ivy ivy) throws FileNotFoundException,
- ParseException, IOException {
+ boolean notify, IvyClasspathContainerConfiguration conf, Ivy ivy, ModuleDescriptor md) {
super("Resolve "
+ (conf.getJavaProject() == null ? "" : conf.getJavaProject().getProject()
.getName()
+ "/") + conf.ivyXmlPath + " dependencies");
this.container = container;
this.ivy = ivy;
+ this.md = md;
_usePreviousResolveIfExist = usePreviousResolveIfExist;
_notify = notify;
this.conf = conf;
@@ -189,7 +189,7 @@
if (_usePreviousResolveIfExist) {
if (conf.confs.size() == 1 && "*".equals(conf.confs.get(0))) {
- confs = conf.md.getConfigurationsNames();
+ confs = md.getConfigurationsNames();
} else {
confs = (String[]) conf.confs.toArray(new String[conf.confs.size()]);
}
@@ -202,7 +202,7 @@
for (int i = 0; i < confs.length; i++) {
File report = ivy.getResolutionCacheManager()
.getConfigurationResolveReportInCache(
- ResolveOptions.getDefaultResolveId(conf.md), confs[i]);
+ ResolveOptions.getDefaultResolveId(md), confs[i]);
boolean resolved = false;
if (report.exists()) {
// found a report, try to parse it.
@@ -221,22 +221,22 @@
// no resolve previously done for at least
// one conf... we do it now
Message.info("\n\nIVYDE: previous resolve of "
- + conf.md.getModuleRevisionId().getModuleId()
+ + md.getModuleRevisionId().getModuleId()
+ " doesn't contain enough data: resolving again\n");
- ResolveReport r = ivy.resolve(conf.md, new ResolveOptions()
+ ResolveReport r = ivy.resolve(md, new ResolveOptions()
.setConfs((String[]) conf.confs
.toArray(new String[conf.confs.size()])));
all.addAll(Arrays.asList(r.getArtifactsReports(null, false)));
confs = r.getConfigurations();
problemMessages.addAll(r.getAllProblemMessages());
- maybeRetrieve(conf.md, confs);
+ maybeRetrieve(md, confs);
break;
}
}
} else {
Message.info("\n\nIVYDE: calling resolve on " + conf.ivyXmlPath + "\n");
- ResolveReport report = ivy.resolve(conf.md, new ResolveOptions()
+ ResolveReport report = ivy.resolve(md, new ResolveOptions()
.setConfs((String[]) conf.confs.toArray(new String[conf.confs
.size()])));
problemMessages = report.getAllProblemMessages();
@@ -249,7 +249,7 @@
return;
}
- maybeRetrieve(conf.md, confs);
+ maybeRetrieve(md, confs);
}
warnIfDuplicates(all);
@@ -280,9 +280,9 @@
problems.append(msg).append("\n");
}
status[0] = new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
- "Impossible to resolve dependencies of "
- + conf.md.getModuleRevisionId() + ":\n" + problems
- + "\nSee IvyConsole for further details", null);
+ "Impossible to resolve dependencies of " + md.getModuleRevisionId()
+ + ":\n" + problems + "\nSee IvyConsole for further details",
+ null);
return;
}
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=659633&r1=659632&r2=659633&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java Fri May 23 12:21:41 2008
@@ -25,7 +25,9 @@
import java.util.Arrays;
import java.util.List;
+import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
import org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage;
@@ -117,6 +119,8 @@
private String ivyXmlError;
+ private ModuleDescriptor md;
+
/**
* Constructor
*
@@ -131,8 +135,8 @@
error = "Choose an ivy file";
} else if (ivyXmlError != null) {
error = ivyXmlError;
- } else if (confTableViewer.getCheckedElements().length == 0 && conf.md != null
- && conf.md.getConfigurations().length != 0) {
+ } else if (confTableViewer.getCheckedElements().length == 0 && md != null
+ && md.getConfigurations().length != 0) {
error = "Choose at least one configuration";
} else {
error = null;
@@ -312,8 +316,8 @@
confTableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
resolveModuleDescriptor();
- if (conf.md != null) {
- return conf.md.getConfigurations();
+ if (md != null) {
+ return md.getConfigurations();
}
return new Configuration[0];
}
@@ -349,8 +353,8 @@
select.setText("<A>All</A>/<A>None</A>");
select.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- if (e.text.equals("All") && conf.md != null) {
- confTableViewer.setCheckedElements(conf.md.getConfigurations());
+ if (e.text.equals("All") && md != null) {
+ confTableViewer.setCheckedElements(md.getConfigurations());
} else {
confTableViewer.setCheckedElements(new Configuration[0]);
}
@@ -573,9 +577,15 @@
}
void resolveModuleDescriptor() {
+ ivyXmlError = null;
+ md = null;
+ Ivy ivy = IvyPlugin.getIvy(conf.getInheritedIvySettingsPath());
+ if (ivy == null) {
+ ivyXmlError = "Error while confiuraing Ivy";
+ return;
+ }
try {
- ivyXmlError = null;
- conf.resolveModuleDescriptor();
+ md = conf.getModuleDescriptor(ivy);
} catch (MalformedURLException e) {
ivyXmlError = "The path of the ivy.xml is not a valid URL";
} catch (ParseException e) {
@@ -589,14 +599,13 @@
* @param ivyFile
*/
private void initTableSelection() {
- if (conf.md != null) {
- Configuration[] configurations = conf.md.getConfigurations();
+ if (md != null) {
+ Configuration[] configurations = md.getConfigurations();
if ("*".equals(conf.confs.get(0))) {
confTableViewer.setCheckedElements(configurations);
} else {
for (int i = 0; i < conf.confs.size(); i++) {
- Configuration configuration = conf.md.getConfiguration((String) conf.confs
- .get(i));
+ Configuration configuration = md.getConfiguration((String) conf.confs.get(i));
if (configuration != null) {
confTableViewer.setChecked(configuration, true);
}