You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2008/09/23 21:45:00 UTC

svn commit: r698318 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/settings/ src/java/org/apache/ivy/util/ src/java/org/apache/ivy/util/url/

Author: maartenc
Date: Tue Sep 23 12:45:00 2008
New Revision: 698318

URL: http://svn.apache.org/viewvc?rev=698318&view=rev
Log:
Merged changes from 2.0.x branch back into trunk (IVY-910, IVY-909, IVY-907, IVY-911)

Modified:
    ant/ivy/core/trunk/   (props changed)
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvyVariableContainerImpl.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java

Propchange: ant/ivy/core/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Sep 23 12:45:00 2008
@@ -0,0 +1,2 @@
+/ant/ivy/core/branches/2.0.x:696803-698317
+/ant/ivy/core/trunk:695737,696014-696031,696442

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Sep 23 12:45:00 2008
@@ -75,10 +75,15 @@
 	Patrick Woodworth
 	Jaroslaw Wypychowski
 	
-   trunk version
+   trunk
 =====================================
 - DOCUMENTATION: Filesystem resolver: talks about "patterns" but does not mention these must become absolute file paths (IVY-910)
 
+- IMPROVEMENT: Error messages on use of relative paths can be cyrptic (IVY-909)
+
+- FIX: Cannot configure items with java.io.File attributes (IVY-905)
+- FIX: Environment properties in ivy settings are no longer resolved (IVY-907)
+- FIX: Resolve failed on certain proxy environment (IVY-911)
 
    2.0.0-rc1
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java Tue Sep 23 12:45:00 2008
@@ -52,7 +52,7 @@
     public void setVariable(String varName, String value, boolean overwrite) {
         if (overwrite) {
             Message.debug("setting '" + varName + "' to '" + value + "'");
-            overwrittenProperties.put(varName, value);
+            overwrittenProperties.put(varName, substitute(value));
         } else {
             super.setVariable(varName, value, overwrite);
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvyVariableContainerImpl.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvyVariableContainerImpl.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvyVariableContainerImpl.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvyVariableContainerImpl.java Tue Sep 23 12:45:00 2008
@@ -59,7 +59,7 @@
         }
     }
 
-    private String substitute(String value) {
+    protected String substitute(String value) {
         return IvyPatternHelper.substituteVariables(value, this);
     }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java Tue Sep 23 12:45:00 2008
@@ -46,6 +46,7 @@
 import org.apache.ivy.util.Configurator;
 import org.apache.ivy.util.FileResolver;
 import org.apache.ivy.util.Message;
+import org.apache.ivy.util.url.URLHandler;
 import org.apache.ivy.util.url.URLHandlerRegistry;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -364,6 +365,16 @@
         defaultCM = (String) attributes.get("defaultConflictManager");
         defaultLatest = (String) attributes.get("defaultLatestStrategy");
         defaultCircular = (String) attributes.get("circularDependencyStrategy");
+        
+        String requestMethod = (String) attributes.get("httpRequestMethod");
+        if ("head".equalsIgnoreCase(requestMethod)) {
+            URLHandlerRegistry.getHttp().setRequestMethod(URLHandler.REQUEST_METHOD_HEAD);
+        } else if ("get".equalsIgnoreCase(requestMethod)) {
+            URLHandlerRegistry.getHttp().setRequestMethod(URLHandler.REQUEST_METHOD_GET);
+        } else if ((requestMethod != null) && (requestMethod.trim().length() > 0)) {
+            throw new IllegalArgumentException("Invalid httpRequestMethod specified, must be " +
+            		"one of {'HEAD', 'GET'}");
+        }
     }
 
     private void includeStarted(Map attributes) throws IOException, ParseException {
@@ -561,7 +572,7 @@
             ivy.setDefaultResolver(ivy.substitute(defaultResolver));
         }
         if (defaultCM != null) {
-            ConflictManager conflictManager = ivy.getConflictManager(defaultCM);
+            ConflictManager conflictManager = ivy.getConflictManager(ivy.substitute(defaultCM));
             if (conflictManager == null) {
                 throw new IllegalArgumentException("unknown conflict manager "
                         + ivy.substitute(defaultCM));

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java Tue Sep 23 12:45:00 2008
@@ -650,7 +650,7 @@
         } catch (Exception ex) {
             IllegalArgumentException iae = new IllegalArgumentException("impossible to convert "
                     + value + " to " + paramClass + " for setting " + attributeName + " on "
-                    + od.getObject().getClass());
+                    + od.getObject().getClass() + ": " + ex.getMessage());
             iae.initCause(ex);
             throw iae;
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java Tue Sep 23 12:45:00 2008
@@ -22,6 +22,10 @@
 import java.io.IOException;
 
 public abstract class AbstractURLHandler implements URLHandler {
+    
+    // the request method to use. TODO: don't use a static here
+    private static int requestMethod = REQUEST_METHOD_HEAD;
+
     public boolean isReachable(URL url) {
         return getURLInfo(url).isReachable();
     }
@@ -67,4 +71,12 @@
                     + statusCode + (statusMessage == null ? "" : ": " + statusMessage));
         }
     }
+    
+    public void setRequestMethod(int requestMethod) {
+        AbstractURLHandler.requestMethod = requestMethod;
+    }
+    
+    public int getRequestMethod() {
+        return requestMethod;
+    }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java Tue Sep 23 12:45:00 2008
@@ -75,7 +75,9 @@
             con.setRequestProperty("User-Agent", "Apache Ivy/" + Ivy.getIvyVersion());
             if (con instanceof HttpURLConnection) {
                 HttpURLConnection httpCon = (HttpURLConnection) con;
-                httpCon.setRequestMethod("HEAD");
+                if (getRequestMethod() == URLHandler.REQUEST_METHOD_HEAD) {
+                    httpCon.setRequestMethod("HEAD");
+                }
                 if (checkStatusCode(url, httpCon)) {
                     return new URLInfo(true, httpCon.getContentLength(), con.getLastModified());
                 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/HttpClientHandler.java Tue Sep 23 12:45:00 2008
@@ -92,7 +92,7 @@
     }
 
     public InputStream openStream(URL url) throws IOException {
-        GetMethod get = doGet(url);
+        GetMethod get = doGet(url, 0);
         if (!checkStatusCode(url, get)) {
             throw new IOException(
                     "The HTTP response code for " + url + " did not indicate a success."
@@ -102,7 +102,7 @@
     }
 
     public void download(URL src, File dest, CopyProgressListener l) throws IOException {
-        GetMethod get = doGet(src);
+        GetMethod get = doGet(src, 0);
         // We can only figure the content we got is want we want if the status is success.
         if (!checkStatusCode(src, get)) {
             throw new IOException(
@@ -141,11 +141,15 @@
     }
 
     public URLInfo getURLInfo(URL url, int timeout) {
-        HeadMethod head = null;
+        HttpMethodBase method = null;
         try {
-            head = doHead(url, timeout);
-            if (checkStatusCode(url, head)) {
-                return new URLInfo(true, getResponseContentLength(head), getLastModified(head));
+            if (getRequestMethod() == URLHandler.REQUEST_METHOD_HEAD) {
+                method = doHead(url, timeout);
+            } else {
+                method = doGet(url, timeout);
+            }
+            if (checkStatusCode(url, method)) {
+                return new URLInfo(true, getResponseContentLength(method), getLastModified(method));
             }
         } catch (HttpException e) {
             Message.error("HttpClientHandler: " + e.getMessage() + ":" + e.getReasonCode() + "="
@@ -160,8 +164,8 @@
             // thrown by HttpClient to indicate the URL is not valid, this happens for instance
             // when trying to download a dynamic version (cfr IVY-390)
         } finally {
-            if (head != null) {
-                head.releaseConnection();
+            if (method != null) {
+                method.releaseConnection();
             }
         }
         return UNAVAILABLE;
@@ -199,7 +203,7 @@
         }
     }
 
-    private long getResponseContentLength(HeadMethod head) {
+    private long getResponseContentLength(HttpMethodBase head) {
         return getHttpClientHelper().getResponseContentLength(head);
     }
 
@@ -230,8 +234,9 @@
         return helper.getHttpClientMajorVersion();
     }
 
-    private GetMethod doGet(URL url) throws IOException {
+    private GetMethod doGet(URL url, int timeout) throws IOException {
         HttpClient client = getClient(url);
+        client.setTimeout(timeout);
 
         GetMethod get = new GetMethod(url.toExternalForm());
         get.setDoAuthentication(useAuthentication(url) || useProxyAuthentication());
@@ -372,8 +377,8 @@
         private HttpClientHelper3x() {
         }
 
-        public long getResponseContentLength(HeadMethod head) {
-            return head.getResponseContentLength();
+        public long getResponseContentLength(HttpMethodBase method) {
+            return method.getResponseContentLength();
         }
 
         /**
@@ -390,8 +395,8 @@
         private HttpClientHelper2x() {
         }
 
-        public long getResponseContentLength(HeadMethod head) {
-            Header header = head.getResponseHeader("Content-Length");
+        public long getResponseContentLength(HttpMethodBase method) {
+            Header header = method.getResponseHeader("Content-Length");
             if (header != null) {
                 try {
                     return Integer.parseInt(header.getValue());
@@ -411,7 +416,7 @@
     }
 
     public interface HttpClientHelper {
-        long getResponseContentLength(HeadMethod head);
+        long getResponseContentLength(HttpMethodBase method);
 
         int getHttpClientMajorVersion();
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandler.java Tue Sep 23 12:45:00 2008
@@ -29,6 +29,18 @@
  * check reachability, ...).
  */
 public interface URLHandler {
+    
+    /**
+     * Using the slower REQUEST method for getting the basic URL infos. Use this when getting errors
+     * behind a problematic/special proxy or firewall chain.
+     */
+    public static final int REQUEST_METHOD_GET = 1;
+
+    /**
+     * Using the faster HEAD method for getting the basic URL infos. Works for most common networks.
+     */
+    public static final int REQUEST_METHOD_HEAD = 2;
+
     public static class URLInfo {
         private long contentLength;
 
@@ -141,4 +153,6 @@
     public void download(URL src, File dest, CopyProgressListener l) throws IOException;
 
     public void upload(File src, URL dest, CopyProgressListener l) throws IOException;
+    
+    public void setRequestMethod(int requestMethod);
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java?rev=698318&r1=698317&r2=698318&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/URLHandlerDispatcher.java Tue Sep 23 12:45:00 2008
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.ivy.util.CopyProgressListener;
@@ -80,6 +81,14 @@
     public void upload(File src, URL dest, CopyProgressListener l) throws IOException {
         getHandler(dest.getProtocol()).upload(src, dest, l);
     }
+    
+    public void setRequestMethod(int requestMethod) {
+        defaultHandler.setRequestMethod(requestMethod);
+        for (Iterator it = handlers.values().iterator(); it.hasNext(); ) {
+            URLHandler handler = (URLHandler) it.next();
+            handler.setRequestMethod(requestMethod);
+        }
+    }
 
     public void setDownloader(String protocol, URLHandler downloader) {
         handlers.put(protocol, downloader);