ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1361798 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde: common/ivyfile/ eclipse/ eclipse/cpcontainer/ eclipse/retrieve/ eclipse/revdepexplorer/
Date Sun, 15 Jul 2012 21:07:19 GMT
Author: hibou
Date: Sun Jul 15 21:07:19 2012
New Revision: 1361798

URL: http://svn.apache.org/viewvc?rev=1361798&view=rev
Log:
IVYDE-304: introduction of a ResolvedPath class which is about taking care of the url/file
resolve from relative/absolute path with optional eclipse variables

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
  (with props)
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.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/cpcontainer/IvyClasspathUtil.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/SettingsSetup.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/revdepexplorer/SyncIvyFilesJob.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java?rev=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
Sun Jul 15 21:07:19 2012
@@ -21,6 +21,7 @@ import java.io.File;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
@@ -71,10 +72,14 @@ public class IvyFileResourceListener imp
             Iterator containerIter = containers.iterator();
             while (containerIter.hasNext()) {
                 IvyClasspathContainer container = (IvyClasspathContainer) containerIter.next();
-                File containerIvyFile = container.getState().getIvyFile();
-                if (containerIvyFile.equals(resourceFile.getLocation().toFile())) {
-                    container.launchResolve(false, null);
-                    return;
+                try {
+                    File containerIvyFile = container.getState().getIvyFile();
+                    if (containerIvyFile.equals(resourceFile.getLocation().toFile())) {
+                        container.launchResolve(false, null);
+                        return;
+                    }
+                } catch (IvyDEException e) {
+                    // we are in a listener, do nothing
                 }
             }
         }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java?rev=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/CachedIvy.java
Sun Jul 15 21:07:19 2012
@@ -23,9 +23,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
 import java.text.ParseException;
 import java.util.Collection;
 import java.util.Iterator;
@@ -85,7 +82,7 @@ public abstract class CachedIvy {
 
     protected abstract String getIvyXmlPath();
 
-    protected abstract String getIvySettingsPath() throws IvyDEException;
+    protected abstract ResolvedPath getIvySettingsPath() throws IvyDEException;
 
     protected abstract boolean isLoadSettingsOnDemandPath();
 
@@ -128,8 +125,13 @@ public abstract class CachedIvy {
     }
 
     private Ivy doGetIvy() throws IvyDEException {
-        String settingsPath = getIvySettingsPath();
-        if (settingsPath == null || settingsPath.trim().length() == 0) {
+        ResolvedPath settingsPath = getIvySettingsPath();
+        if (settingsPath.getError() != null) {
+            throw new IvyDEException("Incorrect path of the Ivy settings",
+                    "The Ivy settings path '" + settingsPath.getInputPath() + "' is incorrect:
"
+                            + settingsPath.getError().getMessage(), settingsPath.getError());
+        }
+        if (!settingsPath.isSet()) {
             // no settings specified, so take the default one
             if (ivy == null) {
                 IvySettings ivySettings = createIvySettings();
@@ -146,63 +148,44 @@ public abstract class CachedIvy {
                 } catch (IOException e) {
                     ivy = null;
                     throw new IvyDEException("Read error of the default Ivy settings",
-                            "The default Ivy settings file could not be read: " 
-                            + e.getMessage(), e);
+                            "The default Ivy settings file could not be read: " + e.getMessage(),
e);
                 }
             }
             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) {
-            throw new IvyDEException("Incorrect url of the Ivy settings", "The Ivy settings
url '"
-                    + settingsPath + "' is incorrect: " + e.getMessage(), e);
-        }
-        if (url.getProtocol().startsWith("file")) {
-            // first try the standard way
-            File file;
-            try {
-                file = new File(new URI(url.toString()));
-            } catch (URISyntaxException e) {
-                // probably a badly constructed url: "file://" + filename
-                file = new File(url.getPath());
-            } catch (IllegalArgumentException e) {
-                // probably a badly constructed url: "file:c:\" + filename
-                file = new File(url.getPath());
-            }
-            return getIvy(file);
+        if (settingsPath.getFile() != null) {
+            return getIvyFromFile(settingsPath);
         } else {
             // an URL but not a file
             if (ivy == null || ivySettingsLastModified == -1) {
                 IvySettings ivySettings = createIvySettings();
                 ivy = Ivy.newInstance(ivySettings);
                 try {
-                    ivy.configure(url);
+                    ivy.configure(settingsPath.getUrl());
                     ivySettingsLastModified = 0;
                 } catch (ParseException e) {
                     ivy = null;
                     throw new IvyDEException("Parsing error of the Ivy settings",
-                            "The ivy settings file '" + settingsPath + "' could not be parsed:
"
-                                    + e.getMessage(), e);
+                            "The ivy settings file '" + settingsPath.getResolvedPath()
+                                    + "' could not be parsed: " + e.getMessage(), e);
                 } catch (IOException e) {
                     ivy = null;
                     throw new IvyDEException("Read error of the Ivy settings",
-                            "The ivy settings file '" + settingsPath + "' could not be read:
"
-                                    + e.getMessage(), e);
+                            "The ivy settings file '" + settingsPath.getResolvedPath()
+                                    + "' could not be read: " + e.getMessage(), e);
                 }
             }
         }
         return ivy;
     }
 
-    private Ivy getIvy(File file) throws IvyDEException {
-        String ivySettingsPath = getIvySettingsPath();
+    private Ivy getIvyFromFile(ResolvedPath ivySettingsPath) throws IvyDEException {
+        File file = ivySettingsPath.getFile();
         if (!file.exists()) {
             throw new IvyDEException("Ivy settings file not found", "The Ivy settings file
'"
-                    + ivySettingsPath + "' cannot be found", null);
+                    + ivySettingsPath.getResolvedPath() + "' cannot be found", null);
         }
 
         if (file.lastModified() != ivySettingsLastModified || !isLoadSettingsOnDemandPath())
{
@@ -218,13 +201,13 @@ public abstract class CachedIvy {
             } catch (ParseException e) {
                 ivy = null;
                 throw new IvyDEException("Parsing error of the Ivy settings",
-                        "The ivy settings file '" + ivySettingsPath + "' could not be parsed:
"
-                                + e.getMessage(), e);
+                        "The ivy settings file '" + ivySettingsPath.getResolvedPath()
+                                + "' could not be parsed: " + e.getMessage(), e);
             } catch (IOException e) {
                 ivy = null;
                 throw new IvyDEException("Read error of the Ivy settings",
-                        "The ivy settings file '" + ivySettingsPath + "' could not be read:
"
-                                + e.getMessage(), e);
+                        "The ivy settings file '" + ivySettingsPath.getResolvedPath()
+                                + "' could not be read: " + e.getMessage(), e);
             }
             ivySettingsLastModified = file.lastModified();
         }
@@ -297,19 +280,24 @@ public abstract class CachedIvy {
         return ivySettings;
     }
 
-    public File getIvyFile() {
-        File file = new File(getIvyXmlPath());
-        if (!file.isAbsolute() && getProject() != null) {
-            Path ivyPath = new Path(getIvyXmlPath());
-            // get the file location in Eclipse "space"
-            IFile ivyfile = 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();
+    public File getIvyFile() throws IvyDEException {
+        ResolvedPath ivyPath = new ResolvedPath(getIvyXmlPath(), getProject());
+        if (ivyPath.getError() != null) {
+            throw new IvyDEException("Incorrect path of the ivy.xml",
+                    "The ivy.xml path '" + ivyPath.getInputPath() + "' is incorrect: "
+                            + ivyPath.getError().getMessage(), ivyPath.getError());
+        }
+        if (!ivyPath.isSet()) {
+            throw new IvyDEException("Empty path of the ivy.xml",
+                    "The ivy.xml path is resolved to be empty: '" + ivyPath.getInputPath()
+ "'",
+                    null);
+        }
+        if (ivyPath.getFile() == null) {
+            throw new IvyDEException("The path of the ivy.xml is not a local file",
+                    "The ivy.xml path is resolved to be a file: '" + ivyPath.getResolvedPath()
+                            + "'", null);
         }
-        return file;
+        return ivyPath.getFile();
     }
 
     public ModuleDescriptor getCachedModuleDescriptor() {
@@ -370,8 +358,7 @@ public abstract class CachedIvy {
             return md;
         } catch (MalformedURLException e) {
             throw new IvyDEException("Incorrect URL of the Ivy file",
-                    "The URL to the ivy.xml file is incorrect: '"
-                    + file.getAbsolutePath() + "'", e);
+                    "The URL to the ivy.xml file is incorrect: '" + file.getAbsolutePath()
+ "'", e);
         } catch (ParseException e) {
             throw new IvyDEException("Parsing error of the Ivy file", "The ivy file '"
                     + file.getAbsolutePath() + "' could not be parsed: " + e.getMessage(),
e);

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java?rev=1361798&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
Sun Jul 15 21:07:19 2012
@@ -0,0 +1,131 @@
+/*
+ *  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;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+
+public class ResolvedPath {
+
+    private String inputPath;
+
+    private String resolvedPath;
+
+    private File file;
+
+    private URL url;
+
+    private Exception e;
+
+    public ResolvedPath(String inputPath, IProject project) {
+        this.inputPath = inputPath;
+        try {
+            resolvePath(inputPath, project);
+        } catch (MalformedURLException e) {
+            this.e = e;
+        } catch (CoreException e) {
+            this.e = e;
+        }
+    }
+
+    public boolean isSet() {
+        return file != null || url != null;
+    }
+
+    public Exception getError() {
+        return e;
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public URL getUrl() {
+        return url;
+    }
+
+    public String getInputPath() {
+        return inputPath;
+    }
+
+    public String getResolvedPath() {
+        return resolvedPath;
+    }
+
+    private void resolvePath(String inputPath, IProject project) throws CoreException,
+            MalformedURLException {
+        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
+        if (project != null) {
+            resolvedPath = inputPath.replaceAll("\\$\\{ivyproject_loc\\}", "\\${workspace_loc:"
+                    + project.getName() + "}");
+        } else {
+            resolvedPath = inputPath;
+        }
+        resolvedPath = manager.performStringSubstitution(resolvedPath, false);
+        resolvedPath = resolvedPath.trim();
+        if (resolvedPath.length() == 0) {
+            // no file or url to set
+            return;
+        }
+        try {
+            url = new URL(resolvedPath);
+            if (url.getProtocol().equals("file")) {
+                try {
+                    // first try the standard way
+                    file = new File(new URI(url.toString()));
+                } catch (URISyntaxException e) {
+                    // probably a badly constructed url: "file://" + filename
+                    file = new File(url.getPath());
+                } catch (IllegalArgumentException e) {
+                    // probably a badly constructed url: "file:c:\" + filename
+                    file = new File(url.getPath());
+                }
+            }
+        } catch (MalformedURLException e) {
+            // probably a file
+            file = new File(resolvedPath);
+            if (!file.isAbsolute()) {
+                if (project != null) {
+                    Path path = new Path(resolvedPath);
+                    // get the file location in Eclipse "space"
+                    IFile ifile = project.getFile(path);
+                    // compute the actual file system location, following Eclipse's linked
folders
+                    // (see IVYDE-211)
+                    IPath ipath = ifile.getLocation();
+                    // get the corresponding java.io.File instance
+                    file = ipath.toFile();
+                } else {
+                    file = file.getAbsoluteFile();
+                }
+            }
+            url = file.toURI().toURL();
+        }
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ResolvedPath.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1361798&r1=1361797&r2=1361798&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
Sun Jul 15 21:07:19 2012
@@ -21,6 +21,7 @@ import java.util.Collection;
 
 import org.apache.ivyde.eclipse.CachedIvy;
 import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.ResolvedPath;
 import org.eclipse.core.resources.IProject;
 
 /**
@@ -40,7 +41,7 @@ public class IvyClasspathContainerState 
         reset();
     }
 
-    protected String getIvySettingsPath() throws IvyDEException {
+    protected ResolvedPath getIvySettingsPath() throws IvyDEException {
         return conf.getInheritedSettingsSetup().getResolvedIvySettingsPath(getProject());
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
Sun Jul 15 21:07:19 2012
@@ -17,8 +17,10 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -33,12 +35,16 @@ import org.apache.ivy.core.module.id.Mod
 import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ResolvedPath;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
 import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
@@ -190,7 +196,7 @@ public final class IvyClasspathUtil {
                         IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                         if (cp instanceof IvyClasspathContainer) {
                             IvyClasspathContainer ivycp = (IvyClasspathContainer) cp;
-                            String settingsPath;
+                            ResolvedPath settingsPath;
                             try {
                                 settingsPath = ivycp.getConf().getInheritedSettingsSetup()
                                         .getResolvedIvySettingsPath(ivycp.getConf().getProject());
@@ -198,8 +204,8 @@ public final class IvyClasspathUtil {
                                 // cannot resolve the ivy settings so just ignore
                                 continue;
                             }
-                            if (settingsPath
-                                    .equals(ivySettings.getProjectRelativePath().toString()))
{
+                            if (settingsPath.getResolvedPath().equals(
+                                ivySettings.getProjectRelativePath().toString())) {
                                 containers.add(ivycp);
                             }
                         }
@@ -316,9 +322,10 @@ public final class IvyClasspathUtil {
      * 
      * @throws IOException
      * @throws ParseException
+     * @throws IvyDEException
      */
     public static void toIvyFile(ModuleDescriptor descriptor, IvyClasspathContainer container)
-            throws ParseException, IOException {
+            throws ParseException, IOException, IvyDEException {
         IvyClasspathContainerConfiguration conf = container.getConf();
         // TODO the ivy file might not be in the workspace or may be an absolute path
         // in a such case the Eclipse API will state the file a read only

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/SettingsSetup.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/SettingsSetup.java?rev=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/SettingsSetup.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/SettingsSetup.java
Sun Jul 15 21:07:19 2012
@@ -17,17 +17,14 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
-import java.io.File;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivyde.eclipse.IvyDEException;
-import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ResolvedPath;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.variables.IStringVariableManager;
 import org.eclipse.core.variables.VariablesPlugin;
 
@@ -56,32 +53,8 @@ public class SettingsSetup {
         this.loadSettingsOnDemand = setup.loadSettingsOnDemand;
     }
 
-    public String getResolvedIvySettingsPath(IProject project) throws IvyDEException {
-        String url;
-        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
-        String path;
-        if (project != null) {
-            path = ivySettingsPath.replaceAll("\\$\\{ivyproject_loc\\}", "\\${workspace_loc:"
-                + project.getName() + "}");
-        } else {
-            path = ivySettingsPath;            
-        }
-        try {
-            url = manager.performStringSubstitution(path, false);
-        } catch (CoreException e) {
-            throw new IvyDEException("Unrecognized variables",
-                    "Unrecognized variables in the Ivy settings file " + ivySettingsPath,
e);
-        }
-        if (ivySettingsPath.trim().startsWith("$")) {
-            // it starts with a variable, let's add the file protocol.
-            try {
-                url = new File(url).toURI().toURL().toExternalForm();
-            } catch (MalformedURLException e) {
-                IvyPlugin.log(IStatus.ERROR,
-                    "The file got from the workspace browser has not a valid URL", e);
-            }
-        }
-        return url;
+    public ResolvedPath getResolvedIvySettingsPath(IProject project) throws IvyDEException
{
+        return new ResolvedPath(ivySettingsPath, project);
     }
 
     public String getRawIvySettingsPath() {

Modified: 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=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetupState.java
Sun Jul 15 21:07:19 2012
@@ -21,6 +21,7 @@ import java.util.Collection;
 
 import org.apache.ivyde.eclipse.CachedIvy;
 import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.ResolvedPath;
 import org.eclipse.core.resources.IProject;
 
 public class StandaloneRetrieveSetupState extends CachedIvy {
@@ -31,7 +32,7 @@ public class StandaloneRetrieveSetupStat
         this.setup = setup;
     }
 
-    protected String getIvySettingsPath() throws IvyDEException {
+    protected ResolvedPath getIvySettingsPath() throws IvyDEException {
         return setup.getInheritedSettingSetup().getResolvedIvySettingsPath(setup.getProject());
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/revdepexplorer/SyncIvyFilesJob.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/revdepexplorer/SyncIvyFilesJob.java?rev=1361798&r1=1361797&r2=1361798&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/revdepexplorer/SyncIvyFilesJob.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/revdepexplorer/SyncIvyFilesJob.java
Sun Jul 15 21:07:19 2012
@@ -37,6 +37,7 @@ import org.apache.ivy.plugins.namespace.
 import org.apache.ivy.plugins.namespace.NamespaceTransformer;
 import org.apache.ivy.plugins.parser.xml.UpdateOptions;
 import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorUpdater;
+import org.apache.ivyde.eclipse.IvyDEException;
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration;
@@ -61,13 +62,13 @@ public class SyncIvyFilesJob extends Wor
 
     /**
      * FIXME Here we seriously abuse the Ivy core API to allow us to preserve an info element
-     * containing no revision attribute.  Ivy code should be altered to allow us to preserve
-     * revision (including the lack of its definition!).
+     * containing no revision attribute. Ivy code should be altered to allow us to preserve
revision
+     * (including the lack of its definition!).
      */
     private class RevisionPreservingNamespace extends Namespace {
         private class NullableRevisionModuleRevisionId extends ModuleRevisionId {
             private String revision;
-            
+
             public NullableRevisionModuleRevisionId(ModuleId moduleId, String revision) {
                 super(moduleId, revision);
                 this.revision = revision;
@@ -75,31 +76,31 @@ public class SyncIvyFilesJob extends Wor
 
             public String getRevision() {
                 return revision;
-            }            
+            }
         }
-        
+
         private class RevisionPreservingNamespaceTransformer implements NamespaceTransformer
{
             public boolean isIdentity() {
                 return false;
             }
-    
+
             public ModuleRevisionId transform(ModuleRevisionId mrid) {
                 if (mrid.getRevision().indexOf("working@") > -1) {
                     return new NullableRevisionModuleRevisionId(mrid.getModuleId(), null);
                 }
                 return new ModuleRevisionId(mrid.getModuleId(), mrid.getRevision());
-            }        
+            }
         }
 
         public NamespaceTransformer getToSystemTransformer() {
             return new RevisionPreservingNamespaceTransformer();
         }
     }
-    
+
     public SyncIvyFilesJob(MultiRevDependencyDescriptor[] multiRevisionDependencies) {
         super("Synchronizing Ivy Files");
         this.multiRevisionDependencies = multiRevisionDependencies;
-    }    
+    }
 
     protected IStatus executeJob(IProgressMonitor monitor) {
         MultiStatus errorStatuses = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
@@ -125,20 +126,26 @@ public class SyncIvyFilesJob extends Wor
                     if (dependencies[j].getDependencyId().equals(multiRevision.getModuleId())
                             && multiRevision.hasNewRevision()
                             && multiRevision.isForContainer(container)) {
-                        newRevisions.put(dependencyRevisionId, multiRevisionDependencies[k]
-                                .getNewRevision());
+                        newRevisions.put(dependencyRevisionId,
+                            multiRevisionDependencies[k].getNewRevision());
                         break; // move on to the next dependency
                     }
                 }
             }
-            
-            UpdateOptions updateOptions = new UpdateOptions()
-                .setResolvedRevisions(newRevisions)
-                .setReplaceInclude(false)
-                .setGenerateRevConstraint(false)
-                .setNamespace(new RevisionPreservingNamespace());
-            File ivyFile = container.getState().getIvyFile();
-            
+
+            UpdateOptions updateOptions = new UpdateOptions().setResolvedRevisions(newRevisions)
+                    .setReplaceInclude(false).setGenerateRevConstraint(false)
+                    .setNamespace(new RevisionPreservingNamespace());
+
+            File ivyFile;
+            try {
+                ivyFile = container.getState().getIvyFile();
+            } catch (IvyDEException e) {
+                errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
+                        "Fail to resolve the ivy file", e));
+                continue;
+            }
+
             File ivyTempFile = new File(ivyFile.toString() + ".temp");
             try {
                 XmlModuleDescriptorUpdater.update(ivyFile.toURI().toURL(), ivyTempFile,
@@ -146,16 +153,13 @@ public class SyncIvyFilesJob extends Wor
                 saveChanges(container, ivyFile, ivyTempFile);
             } catch (MalformedURLException e) {
                 errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                        "Failed to write Ivy file " + container.getState().getIvyFile().getPath()
-                                + " (malformed URL)", e));
+                        "Failed to write Ivy file " + ivyFile + " (malformed URL)", e));
             } catch (IOException e) {
                 errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                        "Failed to write Ivy file " + container.getState().getIvyFile().getPath(),
-                        e));
+                        "Failed to write Ivy file " + ivyFile, e));
             } catch (SAXException e) {
                 errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
-                    "Failed to write Ivy file " + container.getState().getIvyFile().getPath(),
-                    e));
+                        "Failed to write Ivy file " + ivyFile, e));
             } finally {
                 ivyTempFile.delete();
             }
@@ -199,8 +203,8 @@ public class SyncIvyFilesJob extends Wor
         IFile virtualIvyFile = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
         IStatus writable = virtualIvyFile.getWorkspace().validateEdit(new IFile[] {virtualIvyFile},
             IWorkspace.VALIDATE_PROMPT);
-        if (writable.isOK()) {            
-            FileWriter writer = new FileWriter(permanentSaveTarget, false);            
+        if (writable.isOK()) {
+            FileWriter writer = new FileWriter(permanentSaveTarget, false);
             BufferedReader reader = new BufferedReader(new FileReader(temporaryChanges));
             while (reader.ready()) {
                 writer.write(reader.readLine() + "\n");
@@ -209,5 +213,5 @@ public class SyncIvyFilesJob extends Wor
             writer.close();
             reader.close();
         }
-    }    
+    }
 }



Mime
View raw message