mirror of https://github.com/apache/ant-ivy
IMPROVEMENT: Upgraded VFS dependency to 1.0 and removed dependency on VFS-sandbox (IVY-498)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/core/trunk@549622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a50afa7558
commit
f2e9b6ad91
|
|
@ -53,6 +53,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
|
|||
- NEW: A checkstyle report is generated (IVY-483) (thanks to Jan Materne)
|
||||
- NEW: Hide private or specific conf when publishing (IVY-77)
|
||||
|
||||
- IMPROVEMENT: Upgraded VFS dependency to 1.0 and removed dependency on VFS-sandbox (IVY-498)
|
||||
- IMPROVEMENT: Use maven2 repository to download dependencies
|
||||
- IMPROVEMENT: Allow "main" parameters to be passed directly (instead of using -args flag) (IVY-480) (thanks to Archie Cobbs)
|
||||
- IMPROVEMENT: Remove @author tags (thanks to Stephane Bailliez)
|
||||
|
|
|
|||
3
ivy.xml
3
ivy.xml
|
|
@ -26,7 +26,6 @@
|
|||
<conf name="httpclient" extends="core" description="core + optional httpclient for better http handling"/>
|
||||
<conf name="oro" extends="core" description="to use optional glob matcher"/>
|
||||
<conf name="vfs" extends="core" description="core + optional VirtualFileSystem(VFS) support" />
|
||||
<conf name="webdav" extends="core" description="core + optional VirtualFileSystem(VFS) with webdav support" />
|
||||
<conf name="sftp" extends="core" description="core + optional SFTP support" />
|
||||
<conf name="standalone" extends="core" description="to launch in standalone mode (from command line)"/>
|
||||
<conf name="default" description="full ivy with all dependencies"/>
|
||||
|
|
@ -45,7 +44,7 @@
|
|||
<exclude org="junit" name="junit"/>
|
||||
</dependency>
|
||||
<dependency org="oro" name="oro" rev="2.0.8" conf="default,oro->default"/>
|
||||
<dependency org="commons-vfs" name="commons-vfs" rev="20060920" conf="vfs->default;default,webdav->webdav" />
|
||||
<dependency org="commons-vfs" name="commons-vfs" rev="1.0" conf="default,vfs->default" />
|
||||
<dependency org="jsch" name="jsch" rev="0.1.25" conf="default,sftp->default" />
|
||||
<!-- Test depdendencies -->
|
||||
<dependency org="ant" name="ant-launcher" rev="1.6.5" conf="test->default"/>
|
||||
|
|
|
|||
|
|
@ -20,26 +20,6 @@
|
|||
<include url="${ivy.default.conf.dir}/ivysettings-local.xml"/>
|
||||
<settings defaultResolver="public" />
|
||||
<resolvers>
|
||||
<chain name="public" returnFirst="true">
|
||||
<ibiblio name="ibiblio" m2compatible="true"/>
|
||||
<url name="ivy" namespace="ivyrep-ns">
|
||||
<ivy pattern="http://ivyrep.jayasoft.org/[organisation]/[module]/ivy-[revision].xml"/>
|
||||
<artifact pattern="http://ivyrep.jayasoft.org/[organisation]/[module]/[revision]/[artifact].[ext]"/>
|
||||
</url>
|
||||
</chain>
|
||||
<ibiblio name="public" m2compatible="true"/>
|
||||
</resolvers>
|
||||
<namespaces>
|
||||
<namespace name="ivyrep-ns">
|
||||
<rule>
|
||||
<fromsystem>
|
||||
<src org="commons-vfs|slide" />
|
||||
<dest org="apache"/>
|
||||
</fromsystem>
|
||||
<tosystem>
|
||||
<src module="(.*)"/>
|
||||
<dest org="$m1"/>
|
||||
</tosystem>
|
||||
</rule>
|
||||
</namespace>
|
||||
</namespaces>
|
||||
</ivysettings>
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* 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.ivy.plugins.repository.vfs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpURL;
|
||||
import org.apache.commons.vfs.FileSystemException;
|
||||
import org.apache.commons.vfs.FileSystemOptions;
|
||||
import org.apache.commons.vfs.provider.webdav.WebdavConnectionManager;
|
||||
import org.apache.commons.vfs.provider.webdav.WebdavFileSystemConfigBuilder;
|
||||
import org.apache.ivy.util.url.HttpClientHandler;
|
||||
import org.apache.webdav.lib.WebdavResource;
|
||||
|
||||
/***************************************************************************************************
|
||||
* Modified version of the WebdavClientFactory from VFS which adds support for httpclient 3.x. See
|
||||
* http://issues.apache.org/jira/browse/VFS-74 for more info. Create a HttpClient instance
|
||||
*/
|
||||
class IvyWebdavClientFactory {
|
||||
|
||||
private IvyWebdavClientFactory() {
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* Creates a new connection to the server.
|
||||
*/
|
||||
public static HttpClient createConnection(String hostname, int port, String username,
|
||||
String password, FileSystemOptions fileSystemOptions) throws FileSystemException {
|
||||
// Create an Http client
|
||||
HttpClient client;
|
||||
try {
|
||||
final HttpURL url = new HttpURL(username, password, hostname, port, "/");
|
||||
|
||||
// WebdavResource resource = null;
|
||||
WebdavResource resource = new WebdavResource() {
|
||||
};
|
||||
|
||||
if (fileSystemOptions != null) {
|
||||
String proxyHost = WebdavFileSystemConfigBuilder.getInstance().getProxyHost(
|
||||
fileSystemOptions);
|
||||
int proxyPort = WebdavFileSystemConfigBuilder.getInstance().getProxyPort(
|
||||
fileSystemOptions);
|
||||
|
||||
if (proxyHost != null && proxyPort > 0) {
|
||||
// resource = new WebdavResource(url, proxyHost, proxyPort);
|
||||
resource.setProxy(proxyHost, proxyPort);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if (resource == null) { resource = new WebdavResource(url); }
|
||||
* resource.setProperties(WebdavResource.NOACTION, 1);
|
||||
*/
|
||||
resource.setHttpURL(url, WebdavResource.NOACTION, 1);
|
||||
|
||||
client = resource.retrieveSessionInstance();
|
||||
HttpClientHandler handler = new HttpClientHandler();
|
||||
int httpClientVersion = handler.getHttpClientMajorVersion();
|
||||
if (httpClientVersion == 2) {
|
||||
// VFS only supports httpclient v2 for now...
|
||||
client.setHttpConnectionManager(new WebdavConnectionManager());
|
||||
} else {
|
||||
client.setHttpConnectionManager(new IvyWebdavConnectionManager());
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new FileSystemException("vfs.provider.webdav/connect.error", hostname, e);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* 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.ivy.plugins.repository.vfs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpConnection;
|
||||
import org.apache.commons.httpclient.HttpConnectionManager;
|
||||
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
|
||||
|
||||
/**
|
||||
* Modified version of the WebdavConnectionManager from VFS which adds support for httpclient 3.x.
|
||||
* See http://issues.apache.org/jira/browse/VFS-74 for more info. A connection manager that provides
|
||||
* access to a single HttpConnection. This manager makes no attempt to provide exclusive access to
|
||||
* the contained HttpConnection. <p/> imario@apache.org: Keep connection in ThreadLocal.
|
||||
*/
|
||||
class IvyWebdavConnectionManager implements HttpConnectionManager {
|
||||
|
||||
/**
|
||||
* Since the same connection is about to be reused, make sure the previous request was
|
||||
* completely processed, and if not consume it now.
|
||||
*
|
||||
* @param conn
|
||||
* The connection
|
||||
*/
|
||||
static void finishLastResponse(HttpConnection conn) {
|
||||
InputStream lastResponse = conn.getLastResponseInputStream();
|
||||
if (lastResponse != null) {
|
||||
conn.setLastResponseInputStream(null);
|
||||
try {
|
||||
lastResponse.close();
|
||||
} catch (IOException ioe) {
|
||||
// FIXME: badness - close to force reconnect.
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The thread data
|
||||
*/
|
||||
protected ThreadLocal localHttpConnection = new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new Entry();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Collection of parameters associated with this connection manager.
|
||||
*/
|
||||
private HttpConnectionManagerParams params = new HttpConnectionManagerParams();
|
||||
|
||||
/**
|
||||
* release the connection of the current thread
|
||||
*/
|
||||
public void releaseLocalConnection() {
|
||||
if (getLocalHttpConnection() != null) {
|
||||
releaseConnection(getLocalHttpConnection());
|
||||
}
|
||||
}
|
||||
|
||||
private static class Entry {
|
||||
/**
|
||||
* The http connection
|
||||
*/
|
||||
private HttpConnection conn = null;
|
||||
|
||||
/**
|
||||
* The time the connection was made idle.
|
||||
*/
|
||||
private long idleStartTime = Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
public IvyWebdavConnectionManager() {
|
||||
}
|
||||
|
||||
protected HttpConnection getLocalHttpConnection() {
|
||||
return ((Entry) localHttpConnection.get()).conn;
|
||||
}
|
||||
|
||||
protected void setLocalHttpConnection(HttpConnection conn) {
|
||||
((Entry) localHttpConnection.get()).conn = conn;
|
||||
}
|
||||
|
||||
protected long getIdleStartTime() {
|
||||
return ((Entry) localHttpConnection.get()).idleStartTime;
|
||||
}
|
||||
|
||||
protected void setIdleStartTime(long idleStartTime) {
|
||||
((Entry) localHttpConnection.get()).idleStartTime = idleStartTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpConnectionManager#getConnection(org.apache.commons.httpclient.HostConfiguration)
|
||||
*/
|
||||
public HttpConnection getConnection(HostConfiguration hostConfiguration) {
|
||||
return getConnection(hostConfiguration, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the staleCheckingEnabled value to be set on HttpConnections that are created.
|
||||
*
|
||||
* @return <code>true</code> if stale checking will be enabled on HttpConections
|
||||
* @see HttpConnection#isStaleCheckingEnabled()
|
||||
*/
|
||||
public boolean isConnectionStaleCheckingEnabled() {
|
||||
return this.params.isStaleCheckingEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the staleCheckingEnabled value to be set on HttpConnections that are created.
|
||||
*
|
||||
* @param connectionStaleCheckingEnabled
|
||||
* <code>true</code> if stale checking will be enabled on HttpConections
|
||||
* @see HttpConnection#setStaleCheckingEnabled(boolean)
|
||||
*/
|
||||
public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled) {
|
||||
this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpConnectionManager#getConnection(HostConfiguration, long)
|
||||
* @since 3.0
|
||||
*/
|
||||
public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) {
|
||||
|
||||
HttpConnection httpConnection = getLocalHttpConnection();
|
||||
if (httpConnection == null) {
|
||||
httpConnection = new HttpConnection(hostConfiguration);
|
||||
setLocalHttpConnection(httpConnection);
|
||||
httpConnection.setHttpConnectionManager(this);
|
||||
httpConnection.getParams().setDefaults(this.params);
|
||||
} else {
|
||||
|
||||
// make sure the host and proxy are correct for this connection
|
||||
// close it and set the values if they are not
|
||||
if (!hostConfiguration.hostEquals(httpConnection)
|
||||
|| !hostConfiguration.proxyEquals(httpConnection)) {
|
||||
|
||||
if (httpConnection.isOpen()) {
|
||||
httpConnection.close();
|
||||
}
|
||||
|
||||
httpConnection.setHost(hostConfiguration.getHost());
|
||||
httpConnection.setPort(hostConfiguration.getPort());
|
||||
httpConnection.setProtocol(hostConfiguration.getProtocol());
|
||||
httpConnection.setLocalAddress(hostConfiguration.getLocalAddress());
|
||||
|
||||
httpConnection.setProxyHost(hostConfiguration.getProxyHost());
|
||||
httpConnection.setProxyPort(hostConfiguration.getProxyPort());
|
||||
} else {
|
||||
finishLastResponse(httpConnection);
|
||||
}
|
||||
}
|
||||
|
||||
// remove the connection from the timeout handler
|
||||
setIdleStartTime(Long.MAX_VALUE);
|
||||
|
||||
return httpConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpConnectionManager#getConnection(HostConfiguration, long)
|
||||
* @deprecated Use #getConnectionWithTimeout(HostConfiguration, long)
|
||||
*/
|
||||
public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) {
|
||||
return getConnectionWithTimeout(hostConfiguration, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection)
|
||||
*/
|
||||
public void releaseConnection(HttpConnection conn) {
|
||||
if (conn != getLocalHttpConnection()) {
|
||||
throw new IllegalStateException("Unexpected release of an unknown connection.");
|
||||
}
|
||||
|
||||
finishLastResponse(getLocalHttpConnection());
|
||||
|
||||
// track the time the connection was made idle
|
||||
setIdleStartTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 3.0
|
||||
*/
|
||||
public void closeIdleConnections(long idleTimeout) {
|
||||
long maxIdleTime = System.currentTimeMillis() - idleTimeout;
|
||||
if (getIdleStartTime() <= maxIdleTime) {
|
||||
getLocalHttpConnection().close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public HttpConnectionManagerParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setParams(HttpConnectionManagerParams params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* 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.ivy.plugins.repository.vfs;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.vfs.FileName;
|
||||
import org.apache.commons.vfs.FileSystem;
|
||||
import org.apache.commons.vfs.FileSystemException;
|
||||
import org.apache.commons.vfs.FileSystemOptions;
|
||||
import org.apache.commons.vfs.provider.GenericFileName;
|
||||
import org.apache.commons.vfs.provider.webdav.WebdavFileProvider;
|
||||
|
||||
/**
|
||||
* Modified version of the WebdavFileProvider from VFS which adds support for httpclient 3.x. See
|
||||
* http://issues.apache.org/jira/browse/VFS-74 for more info. A provider for WebDAV.
|
||||
*/
|
||||
public class IvyWebdavFileProvider extends WebdavFileProvider {
|
||||
|
||||
/***********************************************************************************************
|
||||
* Creates a filesystem.
|
||||
*/
|
||||
protected FileSystem doCreateFileSystem(final FileName name,
|
||||
final FileSystemOptions fileSystemOptions) throws FileSystemException {
|
||||
// Create the file system
|
||||
final GenericFileName rootName = (GenericFileName) name;
|
||||
|
||||
HttpClient httpClient = IvyWebdavClientFactory.createConnection(rootName.getHostName(),
|
||||
rootName.getPort(), rootName.getUserName(), rootName.getPassword(), fileSystemOptions);
|
||||
|
||||
return new IvyWebdavFileSystem(rootName, httpClient, fileSystemOptions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* 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.ivy.plugins.repository.vfs;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.vfs.FileSystemOptions;
|
||||
import org.apache.commons.vfs.provider.GenericFileName;
|
||||
import org.apache.commons.vfs.provider.webdav.WebDavFileSystem;
|
||||
|
||||
/**
|
||||
* This class extends from WebDavFileSystem because it doesn't provide an accessible constructor.
|
||||
*/
|
||||
class IvyWebdavFileSystem extends WebDavFileSystem {
|
||||
|
||||
protected IvyWebdavFileSystem(GenericFileName arg0, HttpClient arg1, FileSystemOptions arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -39,14 +39,6 @@
|
|||
<if-available class-name="org.apache.commons.httpclient.HttpClient"/>
|
||||
</provider>
|
||||
-->
|
||||
<provider class-name="org.apache.ivy.plugins.repository.vfs.IvyWebdavFileProvider">
|
||||
<scheme name="webdav"/>
|
||||
<if-available class-name="org.apache.webdav.lib.WebdavResource"/>
|
||||
<if-available class-name="org.apache.commons.httpclient.HttpClient"/>
|
||||
</provider>
|
||||
<provider class-name="org.apache.commons.vfs.provider.temp.TemporaryFileProvider">
|
||||
<scheme name="tmp"/>
|
||||
</provider>
|
||||
|
||||
<provider class-name="org.apache.commons.vfs.provider.sftp.SftpFileProvider">
|
||||
<scheme name="sftp"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue