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 2010/08/23 12:32:53 UTC
svn commit: r988063 - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse:
./ cpcontainer/ retrieve/ ui/menu/
Author: hibou
Date: Mon Aug 23 10:32:52 2010
New Revision: 988063
URL: http://svn.apache.org/viewvc?rev=988063&view=rev
Log:
IVYDE-56: ...work still in progress...
* implement the retrieve action
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
- copied, changed from r988052, ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java (with props)
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
Copied: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java (from r988052, ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java)
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java?p2=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java&p1=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java&r1=988052&r2=988063&rev=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java Mon Aug 23 10:32:52 2010
@@ -15,7 +15,7 @@
* limitations under the License.
*
*/
-package org.apache.ivyde.eclipse.cpcontainer;
+package org.apache.ivyde.eclipse;
import java.io.File;
import java.io.FileInputStream;
@@ -36,9 +36,6 @@ import org.apache.ivy.core.module.descri
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.util.Message;
-import org.apache.ivyde.eclipse.FakeProjectManager;
-import org.apache.ivyde.eclipse.IvyDEException;
-import org.apache.ivyde.eclipse.IvyPlugin;
import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceIvySettings;
import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
import org.eclipse.core.resources.IFile;
@@ -50,13 +47,14 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
import org.osgi.framework.BundleContext;
/**
* This class is a front end to the container configuration. It computes the configuration status,
* build the Ivy bean on demand and can cache it.
*/
-public class IvyClasspathContainerState {
+public abstract class CachedIvy {
private Ivy ivy;
@@ -64,14 +62,8 @@ public class IvyClasspathContainerState
private ModuleDescriptor md;
- private IvyClasspathContainerConfiguration conf;
- public IvyClasspathContainerState(IvyClasspathContainerConfiguration conf) {
- this.conf = conf;
- }
-
- public void setConf(IvyClasspathContainerConfiguration conf) {
- this.conf = conf;
+ public void reset() {
md = null;
ivy = null;
ivySettingsLastModified = -1;
@@ -90,17 +82,31 @@ public class IvyClasspathContainerState
}
}
+ protected abstract IProject getProject();
+
+ protected abstract String getIvyXmlPath();
+
+ protected abstract String getIvySettingsPath() throws IvyDEException;
+
+ protected abstract boolean isLoadSettingsOnDemandPath();
+
+ protected abstract Collection getPropertyFiles() throws IvyDEException;
+
+ protected abstract IJavaProject getJavaProject();
+
+ protected abstract boolean isResolveInWorkspace();
+
public void setResolveStatus(IStatus status) {
- if (FakeProjectManager.isFake(conf.getJavaProject())) {
+ if (FakeProjectManager.isFake(getProject())) {
return;
}
- IProject p = conf.getJavaProject().getProject();
+ IProject p = getProject().getProject();
try {
p.deleteMarkers(IvyPlugin.MARKER_ID, true, IResource.DEPTH_INFINITE);
if (status == Status.OK_STATUS) {
return;
}
- IResource r = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
+ IResource r = getProject().getFile(getIvyXmlPath());
if (!r.exists()) {
r = p;
}
@@ -142,7 +148,7 @@ public class IvyClasspathContainerState
}
private Ivy doGetIvy() throws IvyDEException {
- String settingsPath = conf.getInheritedIvySettingsPath();
+ String settingsPath = getIvySettingsPath();
if (settingsPath == null || settingsPath.trim().length() == 0) {
// no settings specified, so take the default one
if (ivy == null) {
@@ -223,7 +229,7 @@ public class IvyClasspathContainerState
}
private Ivy getIvy(File file) throws IvyDEException {
- String ivySettingsPath = conf.getInheritedIvySettingsPath();
+ String ivySettingsPath = getIvySettingsPath();
if (!file.exists()) {
IvyDEException ex = new IvyDEException("Ivy settings file not found",
"The Ivy settings file '" + ivySettingsPath + "' cannot be found", null);
@@ -232,7 +238,7 @@ public class IvyClasspathContainerState
}
if (file.lastModified() != ivySettingsLastModified
- || !conf.getInheritedLoadSettingsOnDemandPath()) {
+ || !isLoadSettingsOnDemandPath()) {
IvySettings ivySettings = createIvySettings();
if (ivySettingsLastModified == -1) {
Message.info("\n\n");
@@ -264,8 +270,8 @@ public class IvyClasspathContainerState
private IvySettings createIvySettings() throws IvyDEException {
IvySettings ivySettings;
- if (conf.isInheritedResolveInWorkspace()) {
- ivySettings = new WorkspaceIvySettings(conf.getJavaProject());
+ if (isResolveInWorkspace()) {
+ ivySettings = new WorkspaceIvySettings(getJavaProject());
DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
BundleContext bundleContext = IvyPlugin.getDefault().getBundleContext();
cacheManager.setBasedir(bundleContext.getDataFile("ivyde-workspace-resolver-cache"));
@@ -276,20 +282,20 @@ public class IvyClasspathContainerState
} else {
ivySettings = new IvySettings();
}
- IPath location = conf.getJavaProject().getProject().getLocation();
+ IPath location = getProject().getLocation();
if (location != null) {
ivySettings.setBaseDir(location.toFile());
}
- Collection propFiles = conf.getInheritedPropertyFiles();
+ Collection propFiles = getPropertyFiles();
if (propFiles != null) {
Iterator iter = propFiles.iterator();
while (iter.hasNext()) {
String file = (String) iter.next();
InputStream is;
Path p = new Path(file);
- if (conf.getJavaProject() != null && !p.isAbsolute()) {
+ if (getProject() != null && !p.isAbsolute()) {
try {
- is = new FileInputStream(conf.getJavaProject().getProject().getLocation()
+ is = new FileInputStream(getProject().getLocation()
.append(file).toFile());
} catch (FileNotFoundException e) {
IvyDEException ex = new IvyDEException("Property file not found",
@@ -334,11 +340,11 @@ public class IvyClasspathContainerState
}
public File getIvyFile() {
- File file = new File(conf.getIvyXmlPath());
- if (!file.isAbsolute() && !FakeProjectManager.isFake(conf.getJavaProject())) {
- Path ivyPath = new Path(conf.getIvyXmlPath());
+ File file = new File(getIvyXmlPath());
+ if (!file.isAbsolute() && !FakeProjectManager.isFake(getProject())) {
+ Path ivyPath = new Path(getIvyXmlPath());
// get the file location in Eclipse "space"
- IFile ivyfile = conf.getJavaProject().getProject().getFile(ivyPath);
+ IFile ivyfile = getProject().getFile(ivyPath);
// compute the actual file system location, following Eclipse's linked folders (see
// IVYDE-211)
IPath ivyLocation = ivyfile.getLocation();
@@ -392,8 +398,4 @@ public class IvyClasspathContainerState
}
}
- public String toString() {
- return conf.toString();
- }
-
}
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/FakeProjectManager.java Mon Aug 23 10:32:52 2010
@@ -38,8 +38,12 @@ public final class FakeProjectManager {
}
public static boolean isFake(IJavaProject project) {
+ return isFake(project.getProject());
+ }
+
+ public static boolean isFake(IProject project) {
// a fake project doesn't have real path
- return project.getProject().getLocation() == null;
+ return project.getLocation() == null;
}
public static IJavaProject createPlaceholderProject() {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java Mon Aug 23 10:32:52 2010
@@ -212,6 +212,7 @@ public final class IvyClasspathContainer
setup.setIvySettingsSetup(settingsSetup);
setup.setIvyXmlPath(ivyXmlPath);
setup.setSettingsProjectSpecific(conf.isSettingsProjectSpecific());
+ setup.setProject(conf.getJavaProject().getProject());
IPreferenceStore prefStore = IvyPlugin.getDefault().getPreferenceStore();
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerState.java Mon Aug 23 10:32:52 2010
@@ -17,52 +17,18 @@
*/
package org.apache.ivyde.eclipse.cpcontainer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.ParseException;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-import org.apache.ivy.Ivy;
-import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
-import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
-import org.apache.ivy.util.Message;
-import org.apache.ivyde.eclipse.FakeProjectManager;
+import org.apache.ivyde.eclipse.CachedIvy;
import org.apache.ivyde.eclipse.IvyDEException;
-import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceIvySettings;
-import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResolver;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
+import org.eclipse.jdt.core.IJavaProject;
/**
* This class is a front end to the container configuration. It computes the configuration status,
* build the Ivy bean on demand and can cache it.
*/
-public class IvyClasspathContainerState {
-
- private Ivy ivy;
-
- private long ivySettingsLastModified = -1;
-
- private ModuleDescriptor md;
+public class IvyClasspathContainerState extends CachedIvy {
private IvyClasspathContainerConfiguration conf;
@@ -72,324 +38,35 @@ public class IvyClasspathContainerState
public void setConf(IvyClasspathContainerConfiguration conf) {
this.conf = conf;
- md = null;
- ivy = null;
- ivySettingsLastModified = -1;
- }
-
- public void setIvySettingsLastModified(long ivySettingsLastModified) {
- this.ivySettingsLastModified = ivySettingsLastModified;
- }
-
- private void setConfStatus(IvyDEException ex) {
- if (ex != null) {
- setResolveStatus(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
- ex.getMessage(), ex.getCause()));
- } else {
- setResolveStatus(Status.OK_STATUS);
- }
- }
-
- public void setResolveStatus(IStatus status) {
- if (FakeProjectManager.isFake(conf.getJavaProject())) {
- return;
- }
- IProject p = conf.getJavaProject().getProject();
- try {
- p.deleteMarkers(IvyPlugin.MARKER_ID, true, IResource.DEPTH_INFINITE);
- if (status == Status.OK_STATUS) {
- return;
- }
- IResource r = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
- if (!r.exists()) {
- r = p;
- }
- IMarker marker = r.createMarker(IvyPlugin.MARKER_ID);
- marker.setAttribute(IMarker.MESSAGE, status.getMessage());
- switch (status.getSeverity()) {
- case IStatus.ERROR:
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- break;
- case IStatus.WARNING:
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
- break;
- case IStatus.INFO:
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- break;
- default:
- IvyPlugin.log(IStatus.WARNING, "Unsupported resolve status: "
- + status.getSeverity(), null);
- }
- } catch (CoreException e) {
- IvyPlugin.log(e);
- }
- }
-
- public Ivy getCachedIvy() throws IvyDEException {
- if (ivy != null) {
- return ivy;
- }
- return getIvy();
- }
-
- public Ivy getIvy() throws IvyDEException {
- try {
- return doGetIvy();
- } catch (IvyDEException e) {
- e.contextualizeMessage("Error while resolving the ivy instance for " + this.toString());
- throw e;
- }
+ reset();
}
- private Ivy doGetIvy() throws IvyDEException {
- String settingsPath = conf.getInheritedIvySettingsPath();
- if (settingsPath == null || settingsPath.trim().length() == 0) {
- // no settings specified, so take the default one
- if (ivy == null) {
- IvySettings ivySettings = createIvySettings();
- ivy = Ivy.newInstance(ivySettings);
- try {
- ivy.configureDefault();
- } catch (ParseException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException(
- "Parsing error of the default Ivy settings",
- "The default Ivy settings file could not be parsed: " + e.getMessage(),
- e);
- setConfStatus(ex);
- throw ex;
- } catch (IOException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException(
- "Read error of the default Ivy settings",
- "The default Ivy settings file could not be read: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- }
- }
- setConfStatus(null);
- return ivy;
- }
-
- // before returning the found ivy, try to refresh it if the settings changed
- URL url;
- try {
- url = new URL(settingsPath);
- } catch (MalformedURLException e) {
- IvyDEException ex = new IvyDEException("Incorrect url of the Ivy settings",
- "The Ivy settings url '" + settingsPath + "' is incorrect: " + e.getMessage(),
- e);
- setConfStatus(ex);
- throw ex;
- }
- if (url.getProtocol().startsWith("file")) {
- // first try the standard way
- File file;
- try {
- file = new File(url.toURI());
- } catch (URISyntaxException e) {
- // probably a badly constructed url: "file://" + filename
- file = new File(url.getPath());
- }
- return getIvy(file);
- } else {
- // an URL but not a file
- if (ivy == null || ivySettingsLastModified == -1) {
- IvySettings ivySettings = createIvySettings();
- ivy = Ivy.newInstance(ivySettings);
- try {
- ivy.configure(url);
- ivySettingsLastModified = 0;
- } catch (ParseException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
- "The ivy settings file '" + settingsPath + "' could not be parsed: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- } catch (IOException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
- "The ivy settings file '" + settingsPath + "' could not be read: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- }
- }
- }
- setConfStatus(null);
- return ivy;
+ protected String getIvySettingsPath() throws IvyDEException {
+ return conf.getInheritedIvySettingsPath();
}
- private Ivy getIvy(File file) throws IvyDEException {
- String ivySettingsPath = conf.getInheritedIvySettingsPath();
- if (!file.exists()) {
- IvyDEException ex = new IvyDEException("Ivy settings file not found",
- "The Ivy settings file '" + ivySettingsPath + "' cannot be found", null);
- setConfStatus(ex);
- throw ex;
- }
-
- if (file.lastModified() != ivySettingsLastModified
- || !conf.getInheritedLoadSettingsOnDemandPath()) {
- IvySettings ivySettings = createIvySettings();
- if (ivySettingsLastModified == -1) {
- Message.info("\n\n");
- } else {
- Message.info("\n\nIVYDE: ivysettings has changed, configuring ivy again\n");
- }
- ivy = Ivy.newInstance(ivySettings);
- try {
- ivy.configure(file);
- } catch (ParseException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException("Parsing error of the Ivy settings",
- "The ivy settings file '" + ivySettingsPath + "' could not be parsed: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- } catch (IOException e) {
- ivy = null;
- IvyDEException ex = new IvyDEException("Read error of the Ivy settings",
- "The ivy settings file '" + ivySettingsPath + "' could not be read: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- }
- ivySettingsLastModified = file.lastModified();
- }
- return ivy;
+ protected String getIvyXmlPath() {
+ return conf.getIvyXmlPath();
}
- private IvySettings createIvySettings() throws IvyDEException {
- IvySettings ivySettings;
- if (conf.isInheritedResolveInWorkspace()) {
- ivySettings = new WorkspaceIvySettings(conf.getJavaProject());
- DefaultRepositoryCacheManager cacheManager = new DefaultRepositoryCacheManager();
- BundleContext bundleContext = IvyPlugin.getDefault().getBundleContext();
- cacheManager.setBasedir(bundleContext.getDataFile("ivyde-workspace-resolver-cache"));
- cacheManager.setCheckmodified(true);
- cacheManager.setUseOrigin(true);
- cacheManager.setName(WorkspaceResolver.CACHE_NAME);
- ivySettings.addRepositoryCacheManager(cacheManager);
- } else {
- ivySettings = new IvySettings();
- }
- IPath location = conf.getJavaProject().getProject().getLocation();
- if (location != null) {
- ivySettings.setBaseDir(location.toFile());
- }
- Collection propFiles = conf.getInheritedPropertyFiles();
- if (propFiles != null) {
- Iterator iter = propFiles.iterator();
- while (iter.hasNext()) {
- String file = (String) iter.next();
- InputStream is;
- Path p = new Path(file);
- if (conf.getJavaProject() != null && !p.isAbsolute()) {
- try {
- is = new FileInputStream(conf.getJavaProject().getProject().getLocation()
- .append(file).toFile());
- } catch (FileNotFoundException e) {
- IvyDEException ex = new IvyDEException("Property file not found",
- "The property file '" + file + "' could not be found", e);
- setConfStatus(ex);
- throw ex;
- }
- } else {
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- IvyDEException ex = new IvyDEException("Property file not found",
- "The property file '" + file + "' was not found", e);
- setConfStatus(ex);
- throw ex;
- }
- }
- Properties props = new Properties();
- try {
- props.load(is);
- } catch (IOException e) {
- IvyDEException ex = new IvyDEException("Not a property file",
- "The property file '" + file + "' could not be loaded", e);
- setConfStatus(ex);
- throw ex;
- }
- try {
- is.close();
- } catch (IOException e) {
- // don't care
- }
-
- Iterator keys = props.keySet().iterator();
- while (keys.hasNext()) {
- String key = (String) keys.next();
- String value = props.getProperty(key);
- ivySettings.setVariable(key, value);
- }
- }
- }
- return ivySettings;
+ protected IJavaProject getJavaProject() {
+ return conf.getJavaProject();
}
- public File getIvyFile() {
- File file = new File(conf.getIvyXmlPath());
- if (!file.isAbsolute() && !FakeProjectManager.isFake(conf.getJavaProject())) {
- Path ivyPath = new Path(conf.getIvyXmlPath());
- // get the file location in Eclipse "space"
- IFile ivyfile = conf.getJavaProject().getProject().getFile(ivyPath);
- // compute the actual file system location, following Eclipse's linked folders (see
- // IVYDE-211)
- IPath ivyLocation = ivyfile.getLocation();
- // get the corresponding java.io.File instance
- file = ivyLocation.toFile();
- }
- return file;
+ protected IProject getProject() {
+ return conf.getJavaProject().getProject();
}
- public ModuleDescriptor getCachedModuleDescriptor() throws IvyDEException {
- if (md != null) {
- return md;
- }
- return getModuleDescriptor(getCachedIvy());
+ protected Collection getPropertyFiles() throws IvyDEException {
+ return conf.getInheritedPropertyFiles();
}
- public ModuleDescriptor getModuleDescriptor() throws IvyDEException {
- return getModuleDescriptor(getIvy());
+ protected boolean isLoadSettingsOnDemandPath() {
+ return conf.getInheritedLoadSettingsOnDemandPath();
}
- public ModuleDescriptor getModuleDescriptor(Ivy i) throws IvyDEException {
- File file = getIvyFile();
- if (!file.exists()) {
- IvyDEException ex = new IvyDEException("Ivy file not found", "The ivy.xml file '"
- + file.getAbsolutePath() + "' was not found", null);
- setConfStatus(ex);
- throw ex;
- }
- try {
- md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(i.getSettings(),
- file.toURI().toURL(), false);
- setConfStatus(null);
- return md;
- } catch (MalformedURLException e) {
- IvyDEException ex = new IvyDEException("Incorrect URL of the Ivy file",
- "The URL to the ivy.xml file is incorrect: '" + file.getAbsolutePath()
- + "'", e);
- setConfStatus(ex);
- throw ex;
- } catch (ParseException e) {
- IvyDEException ex = new IvyDEException("Parsing error of the Ivy file",
- "The ivy file '" + file.getAbsolutePath() + "' could not be parsed: "
- + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- } catch (IOException e) {
- IvyDEException ex = new IvyDEException("Read error of the Ivy file", "The ivy file '"
- + file.getAbsolutePath() + "' could not be read: " + e.getMessage(), e);
- setConfStatus(ex);
- throw ex;
- }
+ protected boolean isResolveInWorkspace() {
+ return conf.isInheritedResolveInWorkspace();
}
public String toString() {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java Mon Aug 23 10:32:52 2010
@@ -63,7 +63,7 @@ public class RetrieveSetupManager implem
StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
ByteArrayInputStream in = new ByteArrayInputStream(retrieveSetup.getBytes());
try {
- retrieveSetups = serializer.read(in);
+ retrieveSetups = serializer.read(in, project);
} finally {
try {
in.close();
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java Mon Aug 23 10:32:52 2010
@@ -35,6 +35,7 @@ import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult;
import org.apache.ivyde.eclipse.cpcontainer.IvySettingsSetup;
+import org.eclipse.core.resources.IProject;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
@@ -179,7 +180,8 @@ public class StandaloneRetrieveSerialize
attributes.setNamedItem(attr);
}
- public List/* <StandaloneRetrieveSetup> */read(InputStream in) throws IOException {
+ public List/* <StandaloneRetrieveSetup> */read(InputStream in, IProject project)
+ throws IOException {
try {
InputSource source = new InputSource(in);
@@ -196,6 +198,7 @@ public class StandaloneRetrieveSerialize
Node node = elements.item(i);
StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup();
+ setup.setProject(project);
NamedNodeMap attributes = node.getAttributes();
setup.setName(getAttribute(attributes, SETUP_NAME));
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java Mon Aug 23 10:32:52 2010
@@ -17,7 +17,12 @@
*/
package org.apache.ivyde.eclipse.retrieve;
+import java.util.Collection;
+
+import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.IvyPlugin;
import org.apache.ivyde.eclipse.cpcontainer.IvySettingsSetup;
+import org.eclipse.core.resources.IProject;
public class StandaloneRetrieveSetup {
@@ -31,6 +36,14 @@ public class StandaloneRetrieveSetup {
private boolean isSettingsProjectSpecific;
+ private IProject project;
+
+ private StandaloneRetrieveSetupState state = new StandaloneRetrieveSetupState(this);
+
+ public StandaloneRetrieveSetupState getState() {
+ return state;
+ }
+
public String getName() {
return name;
}
@@ -66,12 +79,45 @@ public class StandaloneRetrieveSetup {
public boolean isSettingProjectSpecific() {
return isSettingsProjectSpecific;
}
-
+
public void setSettingsProjectSpecific(boolean isSettingsProjectSpecific) {
this.isSettingsProjectSpecific = isSettingsProjectSpecific;
}
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
public String toString() {
return name != null ? name : retrieveSetup.getRetrievePattern();
}
+
+ public String getInheritedIvySettingsPath() throws IvyDEException {
+ if (!isSettingsProjectSpecific) {
+ return IvyPlugin.getPreferenceStoreHelper().getIvySettingsSetup()
+ .getResolvedIvySettingsPath();
+ }
+ return ivySettingsSetup.getResolvedIvySettingsPath();
+ }
+
+ public Collection getInheritedPropertyFiles() throws IvyDEException {
+ if (!isSettingsProjectSpecific) {
+ return IvyPlugin.getPreferenceStoreHelper().getIvySettingsSetup()
+ .getResolvedPropertyFiles();
+ }
+ return ivySettingsSetup.getResolvedPropertyFiles();
+ }
+
+ public boolean isInheritedLoadSettingsOnDemand() {
+ if (!isSettingsProjectSpecific) {
+ return IvyPlugin.getPreferenceStoreHelper().getIvySettingsSetup()
+ .isLoadSettingsOnDemand();
+ }
+ return ivySettingsSetup.isLoadSettingsOnDemand();
+ }
+
}
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java?rev=988063&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java Mon Aug 23 10:32:52 2010
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.retrieve;
+
+import java.util.Collection;
+
+import org.apache.ivyde.eclipse.CachedIvy;
+import org.apache.ivyde.eclipse.IvyDEException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+
+public class StandaloneRetrieveSetupState extends CachedIvy {
+
+ private final StandaloneRetrieveSetup setup;
+
+ public StandaloneRetrieveSetupState(StandaloneRetrieveSetup setup) {
+ this.setup = setup;
+ }
+
+ protected String getIvySettingsPath() throws IvyDEException {
+ return setup.getInheritedIvySettingsPath();
+ }
+
+ protected String getIvyXmlPath() {
+ return setup.getIvyXmlPath();
+ }
+
+ protected IJavaProject getJavaProject() {
+ return null;
+ }
+
+ protected IProject getProject() {
+ return setup.getProject();
+ }
+
+ protected Collection getPropertyFiles() throws IvyDEException {
+ return setup.getInheritedPropertyFiles();
+ }
+
+ protected boolean isLoadSettingsOnDemandPath() {
+ return setup.isInheritedLoadSettingsOnDemand();
+ }
+
+ protected boolean isResolveInWorkspace() {
+ return false;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java Mon Aug 23 10:32:52 2010
@@ -147,7 +147,7 @@ public class IvyMenuContributionItem ext
while (itSetup.hasNext()) {
StandaloneRetrieveSetup retrieveSetup = (StandaloneRetrieveSetup) itSetup
.next();
- RetrieveAction action = new RetrieveAction(retrieveSetup);
+ RetrieveAction action = new RetrieveAction(project, retrieveSetup);
action.setText("Retrieve '" + retrieveSetup.getName()
+ (oneProject ? "'" : "' of " + project.getName()));
fillMenu(menuManager, items, new ActionContributionItem(action));
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java?rev=988063&r1=988062&r2=988063&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/RetrieveAction.java Mon Aug 23 10:32:52 2010
@@ -17,8 +17,17 @@
*/
package org.apache.ivyde.eclipse.ui.menu;
+import java.io.IOException;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.retrieve.RetrieveOptions;
+import org.apache.ivy.util.filter.ArtifactTypeFilter;
+import org.apache.ivyde.eclipse.IvyDEException;
import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import org.apache.ivyde.eclipse.retrieve.StandaloneRetrieveSetup;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action;
@@ -26,12 +35,40 @@ public class RetrieveAction extends Acti
private final StandaloneRetrieveSetup retrieveSetup;
- public RetrieveAction(StandaloneRetrieveSetup retrieveSetup) {
+ private final IProject project;
+
+ public RetrieveAction(IProject project, StandaloneRetrieveSetup retrieveSetup) {
+ this.project = project;
this.retrieveSetup = retrieveSetup;
}
public void run() {
- // TODO
- IvyPlugin.log(IStatus.INFO, "retrieve of " + retrieveSetup.getName(), null);
+ String pattern = project.getLocation().toPortableString() + "/"
+ + retrieveSetup.getRetrieveSetup().getRetrievePattern();
+ RetrieveOptions c = new RetrieveOptions();
+ c.setSync(retrieveSetup.getRetrieveSetup().isRetrieveSync());
+ c.setConfs(retrieveSetup.getRetrieveSetup().getRetrieveConfs().split(","));
+ String inheritedRetrieveTypes = retrieveSetup.getRetrieveSetup().getRetrieveTypes();
+ if (inheritedRetrieveTypes != null && !inheritedRetrieveTypes.equals("*")) {
+ c.setArtifactFilter(new ArtifactTypeFilter(IvyClasspathUtil
+ .split(inheritedRetrieveTypes)));
+ }
+ Ivy ivy;
+ ModuleDescriptor md;
+ try {
+ ivy = retrieveSetup.getState().getCachedIvy();
+ md = retrieveSetup.getState().getCachedModuleDescriptor();
+ } catch (IvyDEException e) {
+ e.log(IStatus.ERROR, null);
+ return;
+ }
+ try {
+ ivy.retrieve(md.getModuleRevisionId(), pattern, c);
+ } catch (IOException e) {
+ IvyPlugin.log(IStatus.ERROR, "Error while retrieving '" + retrieveSetup.getName()
+ + "' in " + retrieveSetup.getProject().getName(), e);
+ }
+ IvyPlugin.log(IStatus.INFO, "Sucessfull retrieve of '" + retrieveSetup.getName() + "' in "
+ + retrieveSetup.getProject().getName(), null);
}
}