( 256 );
public Object get( RepositorySystemSession session, Object key )
{
return cache.get( key );
}
public void put( RepositorySystemSession session, Object key, Object data )
{
if ( data != null )
{
cache.put( key, data );
}
else
{
cache.remove( key );
}
}
}
DefaultRepositorySystemSession.java 0000664 0000000 0000000 00000071140 12455463561 0033241 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.aether.artifact.ArtifactType;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.collection.DependencyGraphTransformer;
import org.eclipse.aether.collection.DependencyManager;
import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.collection.DependencyTraverser;
import org.eclipse.aether.collection.VersionFilter;
import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.AuthenticationSelector;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.repository.MirrorSelector;
import org.eclipse.aether.repository.Proxy;
import org.eclipse.aether.repository.ProxySelector;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.transfer.TransferListener;
/**
* A simple repository system session.
*
* Note: This class is not thread-safe. It is assumed that the mutators get only called during an
* initialization phase and that the session itself is not changed once initialized and being used by the repository
* system. It is recommended to call {@link #setReadOnly()} once the session has been fully initialized to prevent
* accidental manipulation of it afterwards.
*/
public final class DefaultRepositorySystemSession
implements RepositorySystemSession
{
private boolean readOnly;
private boolean offline;
private boolean ignoreArtifactDescriptorRepositories;
private ResolutionErrorPolicy resolutionErrorPolicy;
private ArtifactDescriptorPolicy artifactDescriptorPolicy;
private String checksumPolicy;
private String updatePolicy;
private LocalRepositoryManager localRepositoryManager;
private WorkspaceReader workspaceReader;
private RepositoryListener repositoryListener;
private TransferListener transferListener;
private Map systemProperties;
private Map systemPropertiesView;
private Map userProperties;
private Map userPropertiesView;
private Map configProperties;
private Map configPropertiesView;
private MirrorSelector mirrorSelector;
private ProxySelector proxySelector;
private AuthenticationSelector authenticationSelector;
private ArtifactTypeRegistry artifactTypeRegistry;
private DependencyTraverser dependencyTraverser;
private DependencyManager dependencyManager;
private DependencySelector dependencySelector;
private VersionFilter versionFilter;
private DependencyGraphTransformer dependencyGraphTransformer;
private SessionData data;
private RepositoryCache cache;
/**
* Creates an uninitialized session. Note: The new session is not ready to use, as a bare minimum,
* {@link #setLocalRepositoryManager(LocalRepositoryManager)} needs to be called but usually other settings also
* need to be customized to achieve meaningful behavior.
*/
public DefaultRepositorySystemSession()
{
systemProperties = new HashMap();
systemPropertiesView = Collections.unmodifiableMap( systemProperties );
userProperties = new HashMap();
userPropertiesView = Collections.unmodifiableMap( userProperties );
configProperties = new HashMap();
configPropertiesView = Collections.unmodifiableMap( configProperties );
mirrorSelector = NullMirrorSelector.INSTANCE;
proxySelector = NullProxySelector.INSTANCE;
authenticationSelector = NullAuthenticationSelector.INSTANCE;
artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
data = new DefaultSessionData();
}
/**
* Creates a shallow copy of the specified session. Actually, the copy is not completely shallow, all maps holding
* system/user/config properties are copied as well. In other words, invoking any mutator on the new session itself
* has no effect on the original session. Other mutable objects like the session data and cache (if any) are not
* copied and will be shared with the original session unless reconfigured.
*
* @param session The session to copy, must not be {@code null}.
*/
public DefaultRepositorySystemSession( RepositorySystemSession session )
{
if ( session == null )
{
throw new IllegalArgumentException( "repository system session not specified" );
}
setOffline( session.isOffline() );
setIgnoreArtifactDescriptorRepositories( session.isIgnoreArtifactDescriptorRepositories() );
setResolutionErrorPolicy( session.getResolutionErrorPolicy() );
setArtifactDescriptorPolicy( session.getArtifactDescriptorPolicy() );
setChecksumPolicy( session.getChecksumPolicy() );
setUpdatePolicy( session.getUpdatePolicy() );
setLocalRepositoryManager( session.getLocalRepositoryManager() );
setWorkspaceReader( session.getWorkspaceReader() );
setRepositoryListener( session.getRepositoryListener() );
setTransferListener( session.getTransferListener() );
setSystemProperties( session.getSystemProperties() );
setUserProperties( session.getUserProperties() );
setConfigProperties( session.getConfigProperties() );
setMirrorSelector( session.getMirrorSelector() );
setProxySelector( session.getProxySelector() );
setAuthenticationSelector( session.getAuthenticationSelector() );
setArtifactTypeRegistry( session.getArtifactTypeRegistry() );
setDependencyTraverser( session.getDependencyTraverser() );
setDependencyManager( session.getDependencyManager() );
setDependencySelector( session.getDependencySelector() );
setVersionFilter( session.getVersionFilter() );
setDependencyGraphTransformer( session.getDependencyGraphTransformer() );
setData( session.getData() );
setCache( session.getCache() );
}
public boolean isOffline()
{
return offline;
}
/**
* Controls whether the repository system operates in offline mode and avoids/refuses any access to remote
* repositories.
*
* @param offline {@code true} if the repository system is in offline mode, {@code false} otherwise.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setOffline( boolean offline )
{
failIfReadOnly();
this.offline = offline;
return this;
}
public boolean isIgnoreArtifactDescriptorRepositories()
{
return ignoreArtifactDescriptorRepositories;
}
/**
* Controls whether repositories declared in artifact descriptors should be ignored during transitive dependency
* collection. If enabled, only the repositories originally provided with the collect request will be considered.
*
* @param ignoreArtifactDescriptorRepositories {@code true} to ignore additional repositories from artifact
* descriptors, {@code false} to merge those with the originally specified repositories.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setIgnoreArtifactDescriptorRepositories( boolean ignoreArtifactDescriptorRepositories )
{
failIfReadOnly();
this.ignoreArtifactDescriptorRepositories = ignoreArtifactDescriptorRepositories;
return this;
}
public ResolutionErrorPolicy getResolutionErrorPolicy()
{
return resolutionErrorPolicy;
}
/**
* Sets the policy which controls whether resolutions errors from remote repositories should be cached.
*
* @param resolutionErrorPolicy The resolution error policy for this session, may be {@code null} if resolution
* errors should generally not be cached.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setResolutionErrorPolicy( ResolutionErrorPolicy resolutionErrorPolicy )
{
failIfReadOnly();
this.resolutionErrorPolicy = resolutionErrorPolicy;
return this;
}
public ArtifactDescriptorPolicy getArtifactDescriptorPolicy()
{
return artifactDescriptorPolicy;
}
/**
* Sets the policy which controls how errors related to reading artifact descriptors should be handled.
*
* @param artifactDescriptorPolicy The descriptor error policy for this session, may be {@code null} if descriptor
* errors should generally not be tolerated.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setArtifactDescriptorPolicy( ArtifactDescriptorPolicy artifactDescriptorPolicy )
{
failIfReadOnly();
this.artifactDescriptorPolicy = artifactDescriptorPolicy;
return this;
}
public String getChecksumPolicy()
{
return checksumPolicy;
}
/**
* Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
* repositories being used for resolution.
*
* @param checksumPolicy The global checksum policy, may be {@code null}/empty to apply the per-repository policies.
* @return This session for chaining, never {@code null}.
* @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
* @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
* @see RepositoryPolicy#CHECKSUM_POLICY_WARN
*/
public DefaultRepositorySystemSession setChecksumPolicy( String checksumPolicy )
{
failIfReadOnly();
this.checksumPolicy = checksumPolicy;
return this;
}
public String getUpdatePolicy()
{
return updatePolicy;
}
/**
* Sets the global update policy. If set, the global update policy overrides the update policies of the remote
* repositories being used for resolution.
*
* @param updatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
* @return This session for chaining, never {@code null}.
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
*/
public DefaultRepositorySystemSession setUpdatePolicy( String updatePolicy )
{
failIfReadOnly();
this.updatePolicy = updatePolicy;
return this;
}
public LocalRepository getLocalRepository()
{
LocalRepositoryManager lrm = getLocalRepositoryManager();
return ( lrm != null ) ? lrm.getRepository() : null;
}
public LocalRepositoryManager getLocalRepositoryManager()
{
return localRepositoryManager;
}
/**
* Sets the local repository manager used during this session. Note: Eventually, a valid session must have
* a local repository manager set.
*
* @param localRepositoryManager The local repository manager used during this session, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setLocalRepositoryManager( LocalRepositoryManager localRepositoryManager )
{
failIfReadOnly();
this.localRepositoryManager = localRepositoryManager;
return this;
}
public WorkspaceReader getWorkspaceReader()
{
return workspaceReader;
}
/**
* Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
* to resolve artifacts.
*
* @param workspaceReader The workspace reader for this session, may be {@code null} if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setWorkspaceReader( WorkspaceReader workspaceReader )
{
failIfReadOnly();
this.workspaceReader = workspaceReader;
return this;
}
public RepositoryListener getRepositoryListener()
{
return repositoryListener;
}
/**
* Sets the listener being notified of actions in the repository system.
*
* @param repositoryListener The repository listener, may be {@code null} if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setRepositoryListener( RepositoryListener repositoryListener )
{
failIfReadOnly();
this.repositoryListener = repositoryListener;
return this;
}
public TransferListener getTransferListener()
{
return transferListener;
}
/**
* Sets the listener being notified of uploads/downloads by the repository system.
*
* @param transferListener The transfer listener, may be {@code null} if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setTransferListener( TransferListener transferListener )
{
failIfReadOnly();
this.transferListener = transferListener;
return this;
}
private Map copySafe( Map, ?> table, Class valueType )
{
Map map;
if ( table == null || table.isEmpty() )
{
map = new HashMap();
}
else
{
map = new HashMap( (int) ( table.size() / 0.75f ) + 1 );
for ( Map.Entry, ?> entry : table.entrySet() )
{
Object key = entry.getKey();
if ( key instanceof String )
{
Object value = entry.getValue();
if ( valueType.isInstance( value ) )
{
map.put( key.toString(), valueType.cast( value ) );
}
}
}
}
return map;
}
public Map getSystemProperties()
{
return systemPropertiesView;
}
/**
* Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
* collected from the runtime environment like {@link System#getProperties()} and environment variables.
*
* Note: System properties are of type {@code Map} and any key-value pair in the input map
* that doesn't match this type will be silently ignored.
*
* @param systemProperties The system properties, may be {@code null} or empty if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setSystemProperties( Map, ?> systemProperties )
{
failIfReadOnly();
this.systemProperties = copySafe( systemProperties, String.class );
systemPropertiesView = Collections.unmodifiableMap( this.systemProperties );
return this;
}
/**
* Sets the specified system property.
*
* @param key The property key, must not be {@code null}.
* @param value The property value, may be {@code null} to remove/unset the property.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setSystemProperty( String key, String value )
{
failIfReadOnly();
if ( value != null )
{
systemProperties.put( key, value );
}
else
{
systemProperties.remove( key );
}
return this;
}
public Map getUserProperties()
{
return userPropertiesView;
}
/**
* Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
* system properties but are set on the discretion of the user and hence are considered of higher priority than
* system properties in case of conflicts.
*
* Note: User properties are of type {@code Map} and any key-value pair in the input map
* that doesn't match this type will be silently ignored.
*
* @param userProperties The user properties, may be {@code null} or empty if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setUserProperties( Map, ?> userProperties )
{
failIfReadOnly();
this.userProperties = copySafe( userProperties, String.class );
userPropertiesView = Collections.unmodifiableMap( this.userProperties );
return this;
}
/**
* Sets the specified user property.
*
* @param key The property key, must not be {@code null}.
* @param value The property value, may be {@code null} to remove/unset the property.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setUserProperty( String key, String value )
{
failIfReadOnly();
if ( value != null )
{
userProperties.put( key, value );
}
else
{
userProperties.remove( key );
}
return this;
}
public Map getConfigProperties()
{
return configPropertiesView;
}
/**
* Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
* connector-specific behavior, etc.).
*
* Note: Configuration properties are of type {@code Map} and any key-value pair in the
* input map that doesn't match this type will be silently ignored.
*
* @param configProperties The configuration properties, may be {@code null} or empty if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setConfigProperties( Map, ?> configProperties )
{
failIfReadOnly();
this.configProperties = copySafe( configProperties, Object.class );
configPropertiesView = Collections.unmodifiableMap( this.configProperties );
return this;
}
/**
* Sets the specified configuration property.
*
* @param key The property key, must not be {@code null}.
* @param value The property value, may be {@code null} to remove/unset the property.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setConfigProperty( String key, Object value )
{
failIfReadOnly();
if ( value != null )
{
configProperties.put( key, value );
}
else
{
configProperties.remove( key );
}
return this;
}
public MirrorSelector getMirrorSelector()
{
return mirrorSelector;
}
/**
* Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
* not used for remote repositories which are passed as request parameters to the repository system, those
* repositories are supposed to denote the effective repositories.
*
* @param mirrorSelector The mirror selector to use, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setMirrorSelector( MirrorSelector mirrorSelector )
{
failIfReadOnly();
this.mirrorSelector = mirrorSelector;
if ( this.mirrorSelector == null )
{
this.mirrorSelector = NullMirrorSelector.INSTANCE;
}
return this;
}
public ProxySelector getProxySelector()
{
return proxySelector;
}
/**
* Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
* not used for remote repositories which are passed as request parameters to the repository system, those
* repositories are supposed to have their proxy (if any) already set.
*
* @param proxySelector The proxy selector to use, may be {@code null}.
* @return This session for chaining, never {@code null}.
* @see org.eclipse.aether.repository.RemoteRepository#getProxy()
*/
public DefaultRepositorySystemSession setProxySelector( ProxySelector proxySelector )
{
failIfReadOnly();
this.proxySelector = proxySelector;
if ( this.proxySelector == null )
{
this.proxySelector = NullProxySelector.INSTANCE;
}
return this;
}
public AuthenticationSelector getAuthenticationSelector()
{
return authenticationSelector;
}
/**
* Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
* selector is not used for remote repositories which are passed as request parameters to the repository system,
* those repositories are supposed to have their authentication (if any) already set.
*
* @param authenticationSelector The authentication selector to use, may be {@code null}.
* @return This session for chaining, never {@code null}.
* @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
*/
public DefaultRepositorySystemSession setAuthenticationSelector( AuthenticationSelector authenticationSelector )
{
failIfReadOnly();
this.authenticationSelector = authenticationSelector;
if ( this.authenticationSelector == null )
{
this.authenticationSelector = NullAuthenticationSelector.INSTANCE;
}
return this;
}
public ArtifactTypeRegistry getArtifactTypeRegistry()
{
return artifactTypeRegistry;
}
/**
* Sets the registry of artifact types recognized by this session.
*
* @param artifactTypeRegistry The artifact type registry, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setArtifactTypeRegistry( ArtifactTypeRegistry artifactTypeRegistry )
{
failIfReadOnly();
this.artifactTypeRegistry = artifactTypeRegistry;
if ( this.artifactTypeRegistry == null )
{
this.artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
}
return this;
}
public DependencyTraverser getDependencyTraverser()
{
return dependencyTraverser;
}
/**
* Sets the dependency traverser to use for building dependency graphs.
*
* @param dependencyTraverser The dependency traverser to use for building dependency graphs, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setDependencyTraverser( DependencyTraverser dependencyTraverser )
{
failIfReadOnly();
this.dependencyTraverser = dependencyTraverser;
return this;
}
public DependencyManager getDependencyManager()
{
return dependencyManager;
}
/**
* Sets the dependency manager to use for building dependency graphs.
*
* @param dependencyManager The dependency manager to use for building dependency graphs, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setDependencyManager( DependencyManager dependencyManager )
{
failIfReadOnly();
this.dependencyManager = dependencyManager;
return this;
}
public DependencySelector getDependencySelector()
{
return dependencySelector;
}
/**
* Sets the dependency selector to use for building dependency graphs.
*
* @param dependencySelector The dependency selector to use for building dependency graphs, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setDependencySelector( DependencySelector dependencySelector )
{
failIfReadOnly();
this.dependencySelector = dependencySelector;
return this;
}
public VersionFilter getVersionFilter()
{
return versionFilter;
}
/**
* Sets the version filter to use for building dependency graphs.
*
* @param versionFilter The version filter to use for building dependency graphs, may be {@code null} to not filter
* versions.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setVersionFilter( VersionFilter versionFilter )
{
failIfReadOnly();
this.versionFilter = versionFilter;
return this;
}
public DependencyGraphTransformer getDependencyGraphTransformer()
{
return dependencyGraphTransformer;
}
/**
* Sets the dependency graph transformer to use for building dependency graphs.
*
* @param dependencyGraphTransformer The dependency graph transformer to use for building dependency graphs, may be
* {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setDependencyGraphTransformer( DependencyGraphTransformer dependencyGraphTransformer )
{
failIfReadOnly();
this.dependencyGraphTransformer = dependencyGraphTransformer;
return this;
}
public SessionData getData()
{
return data;
}
/**
* Sets the custom data associated with this session.
*
* @param data The session data, may be {@code null}.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setData( SessionData data )
{
failIfReadOnly();
this.data = data;
if ( this.data == null )
{
this.data = new DefaultSessionData();
}
return this;
}
public RepositoryCache getCache()
{
return cache;
}
/**
* Sets the cache the repository system may use to save data for future reuse during the session.
*
* @param cache The repository cache, may be {@code null} if none.
* @return This session for chaining, never {@code null}.
*/
public DefaultRepositorySystemSession setCache( RepositoryCache cache )
{
failIfReadOnly();
this.cache = cache;
return this;
}
/**
* Marks this session as read-only such that any future attempts to call its mutators will fail with an exception.
* Marking an already read-only session as read-only has no effect. The session's data and cache remain writable
* though.
*/
public void setReadOnly()
{
readOnly = true;
}
private void failIfReadOnly()
{
if ( readOnly )
{
throw new IllegalStateException( "repository system session is read-only" );
}
}
static class NullProxySelector
implements ProxySelector
{
public static final ProxySelector INSTANCE = new NullProxySelector();
public Proxy getProxy( RemoteRepository repository )
{
return repository.getProxy();
}
}
static class NullMirrorSelector
implements MirrorSelector
{
public static final MirrorSelector INSTANCE = new NullMirrorSelector();
public RemoteRepository getMirror( RemoteRepository repository )
{
return null;
}
}
static class NullAuthenticationSelector
implements AuthenticationSelector
{
public static final AuthenticationSelector INSTANCE = new NullAuthenticationSelector();
public Authentication getAuthentication( RemoteRepository repository )
{
return repository.getAuthentication();
}
}
static final class NullArtifactTypeRegistry
implements ArtifactTypeRegistry
{
public static final ArtifactTypeRegistry INSTANCE = new NullArtifactTypeRegistry();
public ArtifactType get( String typeId )
{
return null;
}
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/DefaultSessionData.java 0000664 0000000 0000000 00000004111 12455463561 0030577 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* A simple session data storage backed by a thread-safe map.
*/
public final class DefaultSessionData
implements SessionData
{
private final ConcurrentMap data;
public DefaultSessionData()
{
data = new ConcurrentHashMap();
}
public void set( Object key, Object value )
{
if ( key == null )
{
throw new IllegalArgumentException( "key must not be null" );
}
if ( value != null )
{
data.put( key, value );
}
else
{
data.remove( key );
}
}
public boolean set( Object key, Object oldValue, Object newValue )
{
if ( key == null )
{
throw new IllegalArgumentException( "key must not be null" );
}
if ( newValue != null )
{
if ( oldValue == null )
{
return data.putIfAbsent( key, newValue ) == null;
}
return data.replace( key, oldValue, newValue );
}
else
{
if ( oldValue == null )
{
return !data.containsKey( key );
}
return data.remove( key, oldValue );
}
}
public Object get( Object key )
{
if ( key == null )
{
throw new IllegalArgumentException( "key must not be null" );
}
return data.get( key );
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositoryCache.java 0000664 0000000 0000000 00000004700 12455463561 0030164 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
/**
* Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant
* for exclusive consumption by the repository system and is opaque to the cache implementation. Note:
* Actual cache implementations must be thread-safe.
*
* @see RepositorySystemSession#getCache()
*/
public interface RepositoryCache
{
/**
* Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be
* kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data.
*
* Warning: The cache will directly save the provided reference. If the cached data is mutable, i.e. could
* be modified after being put into the cache, the caller is responsible for creating a copy of the original data
* and store the copy in the cache.
*
* @param session The repository session during which the cache is accessed, must not be {@code null}.
* @param key The key to use for lookup of the data, must not be {@code null}.
* @param data The data to store in the cache, may be {@code null}.
*/
void put( RepositorySystemSession session, Object key, Object data );
/**
* Gets the specified data from the cache.
*
* Warning: The cache will directly return the saved reference. If the cached data is to be modified after
* its retrieval, the caller is responsible to create a copy of the returned data and use this instead of the cache
* record.
*
* @param session The repository session during which the cache is accessed, must not be {@code null}.
* @param key The key to use for lookup of the data, must not be {@code null}.
* @return The requested data or {@code null} if none was present in the cache.
*/
Object get( RepositorySystemSession session, Object key );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositoryEvent.java 0000664 0000000 0000000 00000027003 12455463561 0030243 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.ArtifactRepository;
/**
* An event describing an action performed by the repository system. Note that events which indicate the end of an
* action like {@link EventType#ARTIFACT_RESOLVED} are generally fired in both the success and the failure case. Use
* {@link #getException()} to check whether an event denotes success or failure.
*
* @see RepositoryListener
* @see RepositoryEvent.Builder
*/
public final class RepositoryEvent
{
/**
* The type of the repository event.
*/
public enum EventType
{
/**
* @see RepositoryListener#artifactDescriptorInvalid(RepositoryEvent)
*/
ARTIFACT_DESCRIPTOR_INVALID,
/**
* @see RepositoryListener#artifactDescriptorMissing(RepositoryEvent)
*/
ARTIFACT_DESCRIPTOR_MISSING,
/**
* @see RepositoryListener#metadataInvalid(RepositoryEvent)
*/
METADATA_INVALID,
/**
* @see RepositoryListener#artifactResolving(RepositoryEvent)
*/
ARTIFACT_RESOLVING,
/**
* @see RepositoryListener#artifactResolved(RepositoryEvent)
*/
ARTIFACT_RESOLVED,
/**
* @see RepositoryListener#metadataResolving(RepositoryEvent)
*/
METADATA_RESOLVING,
/**
* @see RepositoryListener#metadataResolved(RepositoryEvent)
*/
METADATA_RESOLVED,
/**
* @see RepositoryListener#artifactDownloading(RepositoryEvent)
*/
ARTIFACT_DOWNLOADING,
/**
* @see RepositoryListener#artifactDownloaded(RepositoryEvent)
*/
ARTIFACT_DOWNLOADED,
/**
* @see RepositoryListener#metadataDownloading(RepositoryEvent)
*/
METADATA_DOWNLOADING,
/**
* @see RepositoryListener#metadataDownloaded(RepositoryEvent)
*/
METADATA_DOWNLOADED,
/**
* @see RepositoryListener#artifactInstalling(RepositoryEvent)
*/
ARTIFACT_INSTALLING,
/**
* @see RepositoryListener#artifactInstalled(RepositoryEvent)
*/
ARTIFACT_INSTALLED,
/**
* @see RepositoryListener#metadataInstalling(RepositoryEvent)
*/
METADATA_INSTALLING,
/**
* @see RepositoryListener#metadataInstalled(RepositoryEvent)
*/
METADATA_INSTALLED,
/**
* @see RepositoryListener#artifactDeploying(RepositoryEvent)
*/
ARTIFACT_DEPLOYING,
/**
* @see RepositoryListener#artifactDeployed(RepositoryEvent)
*/
ARTIFACT_DEPLOYED,
/**
* @see RepositoryListener#metadataDeploying(RepositoryEvent)
*/
METADATA_DEPLOYING,
/**
* @see RepositoryListener#metadataDeployed(RepositoryEvent)
*/
METADATA_DEPLOYED
}
private final EventType type;
private final RepositorySystemSession session;
private final Artifact artifact;
private final Metadata metadata;
private final ArtifactRepository repository;
private final File file;
private final List exceptions;
private final RequestTrace trace;
RepositoryEvent( Builder builder )
{
type = builder.type;
session = builder.session;
artifact = builder.artifact;
metadata = builder.metadata;
repository = builder.repository;
file = builder.file;
exceptions = builder.exceptions;
trace = builder.trace;
}
/**
* Gets the type of the event.
*
* @return The type of the event, never {@code null}.
*/
public EventType getType()
{
return type;
}
/**
* Gets the repository system session during which the event occurred.
*
* @return The repository system session during which the event occurred, never {@code null}.
*/
public RepositorySystemSession getSession()
{
return session;
}
/**
* Gets the artifact involved in the event (if any).
*
* @return The involved artifact or {@code null} if none.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Gets the metadata involved in the event (if any).
*
* @return The involved metadata or {@code null} if none.
*/
public Metadata getMetadata()
{
return metadata;
}
/**
* Gets the file involved in the event (if any).
*
* @return The involved file or {@code null} if none.
*/
public File getFile()
{
return file;
}
/**
* Gets the repository involved in the event (if any).
*
* @return The involved repository or {@code null} if none.
*/
public ArtifactRepository getRepository()
{
return repository;
}
/**
* Gets the exception that caused the event (if any). As a rule of thumb, an event accompanied by an exception
* indicates a failure of the corresponding action. If multiple exceptions occurred, this method returns the first
* exception.
*
* @return The exception or {@code null} if none.
*/
public Exception getException()
{
return exceptions.isEmpty() ? null : exceptions.get( 0 );
}
/**
* Gets the exceptions that caused the event (if any). As a rule of thumb, an event accompanied by exceptions
* indicates a failure of the corresponding action.
*
* @return The exceptions, never {@code null}.
*/
public List getExceptions()
{
return exceptions;
}
/**
* Gets the trace information about the request during which the event occurred.
*
* @return The trace information or {@code null} if none.
*/
public RequestTrace getTrace()
{
return trace;
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder( 256 );
buffer.append( getType() );
if ( getArtifact() != null )
{
buffer.append( " " ).append( getArtifact() );
}
if ( getMetadata() != null )
{
buffer.append( " " ).append( getMetadata() );
}
if ( getFile() != null )
{
buffer.append( " (" ).append( getFile() ).append( ")" );
}
if ( getRepository() != null )
{
buffer.append( " @ " ).append( getRepository() );
}
return buffer.toString();
}
/**
* A builder to create events.
*/
public static final class Builder
{
EventType type;
RepositorySystemSession session;
Artifact artifact;
Metadata metadata;
ArtifactRepository repository;
File file;
List exceptions = Collections.emptyList();
RequestTrace trace;
/**
* Creates a new event builder for the specified session and event type.
*
* @param session The repository system session, must not be {@code null}.
* @param type The type of the event, must not be {@code null}.
*/
public Builder( RepositorySystemSession session, EventType type )
{
if ( session == null )
{
throw new IllegalArgumentException( "session not specified" );
}
this.session = session;
if ( type == null )
{
throw new IllegalArgumentException( "event type not specified" );
}
this.type = type;
}
/**
* Sets the artifact involved in the event.
*
* @param artifact The involved artifact, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setArtifact( Artifact artifact )
{
this.artifact = artifact;
return this;
}
/**
* Sets the metadata involved in the event.
*
* @param metadata The involved metadata, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setMetadata( Metadata metadata )
{
this.metadata = metadata;
return this;
}
/**
* Sets the repository involved in the event.
*
* @param repository The involved repository, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setRepository( ArtifactRepository repository )
{
this.repository = repository;
return this;
}
/**
* Sets the file involved in the event.
*
* @param file The involved file, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setFile( File file )
{
this.file = file;
return this;
}
/**
* Sets the exception causing the event.
*
* @param exception The exception causing the event, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setException( Exception exception )
{
if ( exception != null )
{
this.exceptions = Collections.singletonList( exception );
}
else
{
this.exceptions = Collections.emptyList();
}
return this;
}
/**
* Sets the exceptions causing the event.
*
* @param exceptions The exceptions causing the event, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setExceptions( List exceptions )
{
if ( exceptions != null )
{
this.exceptions = exceptions;
}
else
{
this.exceptions = Collections.emptyList();
}
return this;
}
/**
* Sets the trace information about the request during which the event occurred.
*
* @param trace The trace information, may be {@code null}.
* @return This event builder for chaining, never {@code null}.
*/
public Builder setTrace( RequestTrace trace )
{
this.trace = trace;
return this;
}
/**
* Builds a new event from the current values of this builder. The state of the builder itself remains
* unchanged.
*
* @return The event, never {@code null}.
*/
public RepositoryEvent build()
{
return new RepositoryEvent( this );
}
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositoryException.java 0000664 0000000 0000000 00000003602 12455463561 0031117 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
/**
* The base class for exceptions thrown by the repository system. Note: Unless otherwise noted, instances of
* this class and its subclasses will not persist fields carrying extended error information during serialization.
*/
public class RepositoryException
extends Exception
{
/**
* Creates a new exception with the specified detail message.
*
* @param message The detail message, may be {@code null}.
*/
public RepositoryException( String message )
{
super( message );
}
/**
* Creates a new exception with the specified detail message and cause.
*
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public RepositoryException( String message, Throwable cause )
{
super( message, cause );
}
/**
* @noreference This method is not intended to be used by clients.
*/
protected static String getMessage( String prefix, Throwable cause )
{
String msg = "";
if ( cause != null )
{
msg = cause.getMessage();
if ( msg == null || msg.length() <= 0 )
{
msg = cause.getClass().getSimpleName();
}
msg = prefix + msg;
}
return msg;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositoryListener.java 0000664 0000000 0000000 00000024722 12455463561 0030754 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
/**
* A listener being notified of events from the repository system. In general, the system sends events upon termination
* of an operation like {@link #artifactResolved(RepositoryEvent)} regardless whether it succeeded or failed so
* listeners need to inspect the event details carefully. Also, the listener may be called from an arbitrary thread.
* Note: Implementors are strongly advised to inherit from {@link AbstractRepositoryListener} instead of
* directly implementing this interface.
*
* @see org.eclipse.aether.RepositorySystemSession#getRepositoryListener()
* @see org.eclipse.aether.transfer.TransferListener
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface RepositoryListener
{
/**
* Notifies the listener of a syntactically or semantically invalid artifact descriptor.
* {@link RepositoryEvent#getArtifact()} indicates the artifact whose descriptor is invalid and
* {@link RepositoryEvent#getExceptions()} carries the encountered errors. Depending on the session's
* {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
* with an exception or ignore the invalid descriptor.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDescriptorInvalid( RepositoryEvent event );
/**
* Notifies the listener of a missing artifact descriptor. {@link RepositoryEvent#getArtifact()} indicates the
* artifact whose descriptor is missing. Depending on the session's
* {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
* with an exception or ignore the missing descriptor.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDescriptorMissing( RepositoryEvent event );
/**
* Notifies the listener of syntactically or semantically invalid metadata. {@link RepositoryEvent#getMetadata()}
* indicates the invalid metadata and {@link RepositoryEvent#getExceptions()} carries the encountered errors. The
* underlying repository operation might still succeed, depending on whether the metadata in question is actually
* needed to carry out the resolution process.
*
* @param event The event details, must not be {@code null}.
*/
void metadataInvalid( RepositoryEvent event );
/**
* Notifies the listener of an artifact that is about to be resolved. {@link RepositoryEvent#getArtifact()} denotes
* the artifact in question. Unlike the {@link #artifactDownloading(RepositoryEvent)} event, this event is fired
* regardless whether the artifact already exists locally or not.
*
* @param event The event details, must not be {@code null}.
*/
void artifactResolving( RepositoryEvent event );
/**
* Notifies the listener of an artifact whose resolution has been completed, either successfully or not.
* {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
* {@link #artifactDownloaded(RepositoryEvent)} event, this event is fired regardless whether the artifact already
* exists locally or not.
*
* @param event The event details, must not be {@code null}.
*/
void artifactResolved( RepositoryEvent event );
/**
* Notifies the listener of some metadata that is about to be resolved. {@link RepositoryEvent#getMetadata()}
* denotes the metadata in question. Unlike the {@link #metadataDownloading(RepositoryEvent)} event, this event is
* fired regardless whether the metadata already exists locally or not.
*
* @param event The event details, must not be {@code null}.
*/
void metadataResolving( RepositoryEvent event );
/**
* Notifies the listener of some metadata whose resolution has been completed, either successfully or not.
* {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
* {@link #metadataDownloaded(RepositoryEvent)} event, this event is fired regardless whether the metadata already
* exists locally or not.
*
* @param event The event details, must not be {@code null}.
*/
void metadataResolved( RepositoryEvent event );
/**
* Notifies the listener of an artifact that is about to be downloaded from a remote repository.
* {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getRepository()} the source repository. Unlike the
* {@link #artifactResolving(RepositoryEvent)} event, this event is only fired when the artifact does not already
* exist locally.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDownloading( RepositoryEvent event );
/**
* Notifies the listener of an artifact whose download has been completed, either successfully or not.
* {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
* {@link #artifactResolved(RepositoryEvent)} event, this event is only fired when the artifact does not already
* exist locally.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDownloaded( RepositoryEvent event );
/**
* Notifies the listener of some metadata that is about to be downloaded from a remote repository.
* {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getRepository()} the source repository. Unlike the
* {@link #metadataResolving(RepositoryEvent)} event, this event is only fired when the metadata does not already
* exist locally.
*
* @param event The event details, must not be {@code null}.
*/
void metadataDownloading( RepositoryEvent event );
/**
* Notifies the listener of some metadata whose download has been completed, either successfully or not.
* {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
* {@link #metadataResolved(RepositoryEvent)} event, this event is only fired when the metadata does not already
* exist locally.
*
* @param event The event details, must not be {@code null}.
*/
void metadataDownloaded( RepositoryEvent event );
/**
* Notifies the listener of an artifact that is about to be installed to the local repository.
* {@link RepositoryEvent#getArtifact()} denotes the artifact in question.
*
* @param event The event details, must not be {@code null}.
*/
void artifactInstalling( RepositoryEvent event );
/**
* Notifies the listener of an artifact whose installation to the local repository has been completed, either
* successfully or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
*
* @param event The event details, must not be {@code null}.
*/
void artifactInstalled( RepositoryEvent event );
/**
* Notifies the listener of some metadata that is about to be installed to the local repository.
* {@link RepositoryEvent#getMetadata()} denotes the metadata in question.
*
* @param event The event details, must not be {@code null}.
*/
void metadataInstalling( RepositoryEvent event );
/**
* Notifies the listener of some metadata whose installation to the local repository has been completed, either
* successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
*
* @param event The event details, must not be {@code null}.
*/
void metadataInstalled( RepositoryEvent event );
/**
* Notifies the listener of an artifact that is about to be uploaded to a remote repository.
* {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getRepository()} the destination repository.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDeploying( RepositoryEvent event );
/**
* Notifies the listener of an artifact whose upload to a remote repository has been completed, either successfully
* or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
*
* @param event The event details, must not be {@code null}.
*/
void artifactDeployed( RepositoryEvent event );
/**
* Notifies the listener of some metadata that is about to be uploaded to a remote repository.
* {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getRepository()} the destination repository.
*
* @param event The event details, must not be {@code null}.
*/
void metadataDeploying( RepositoryEvent event );
/**
* Notifies the listener of some metadata whose upload to a remote repository has been completed, either
* successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
* {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
*
* @param event The event details, must not be {@code null}.
*/
void metadataDeployed( RepositoryEvent event );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositorySystem.java 0000664 0000000 0000000 00000036665 12455463561 0030464 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.util.Collection;
import java.util.List;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.collection.CollectResult;
import org.eclipse.aether.collection.DependencyCollectionException;
import org.eclipse.aether.deployment.DeployRequest;
import org.eclipse.aether.deployment.DeployResult;
import org.eclipse.aether.deployment.DeploymentException;
import org.eclipse.aether.installation.InstallRequest;
import org.eclipse.aether.installation.InstallResult;
import org.eclipse.aether.installation.InstallationException;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactDescriptorException;
import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
import org.eclipse.aether.resolution.ArtifactDescriptorResult;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
import org.eclipse.aether.resolution.DependencyRequest;
import org.eclipse.aether.resolution.DependencyResolutionException;
import org.eclipse.aether.resolution.DependencyResult;
import org.eclipse.aether.resolution.MetadataRequest;
import org.eclipse.aether.resolution.MetadataResult;
import org.eclipse.aether.resolution.VersionRangeRequest;
import org.eclipse.aether.resolution.VersionRangeResolutionException;
import org.eclipse.aether.resolution.VersionRangeResult;
import org.eclipse.aether.resolution.VersionRequest;
import org.eclipse.aether.resolution.VersionResolutionException;
import org.eclipse.aether.resolution.VersionResult;
/**
* The main entry point to the repository system and its functionality. Note that obtaining a concrete implementation of
* this interface (e.g. via dependency injection, service locator, etc.) is dependent on the application and its
* specific needs, please consult the online documentation for examples and directions on booting the system.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface RepositorySystem
{
/**
* Expands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to
* "3.8", "3.8.1", "3.8.2". Note that the returned list of versions is only dependent on the configured repositories
* and their contents, the list is not processed by the {@link RepositorySystemSession#getVersionFilter() session's
* version filter}.
*
* The supplied request may also refer to a single concrete version rather than a version range. In this case
* though, the result contains simply the (parsed) input version, regardless of the repositories and their contents.
*
* @param session The repository session, must not be {@code null}.
* @param request The version range request, must not be {@code null}.
* @return The version range result, never {@code null}.
* @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does
* not raise an exception.
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
throws VersionRangeResolutionException;
/**
* Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to
* "1.0-20090208.132618-23".
*
* @param session The repository session, must not be {@code null}.
* @param request The version request, must not be {@code null}.
* @return The version result, never {@code null}.
* @throws VersionResolutionException If the metaversion could not be resolved.
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
throws VersionResolutionException;
/**
* Gets information about an artifact like its direct dependencies and potential relocations.
*
* @param session The repository session, must not be {@code null}.
* @param request The descriptor request, must not be {@code null}.
* @return The descriptor result, never {@code null}.
* @throws ArtifactDescriptorException If the artifact descriptor could not be read.
* @see RepositorySystemSession#getArtifactDescriptorPolicy()
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, ArtifactDescriptorRequest request )
throws ArtifactDescriptorException;
/**
* Collects the transitive dependencies of an artifact and builds a dependency graph. Note that this operation is
* only concerned about determining the coordinates of the transitive dependencies. To also resolve the actual
* artifact files, use {@link #resolveDependencies(RepositorySystemSession, DependencyRequest)}.
*
* @param session The repository session, must not be {@code null}.
* @param request The collection request, must not be {@code null}.
* @return The collection result, never {@code null}.
* @throws DependencyCollectionException If the dependency tree could not be built.
* @see RepositorySystemSession#getDependencyTraverser()
* @see RepositorySystemSession#getDependencyManager()
* @see RepositorySystemSession#getDependencySelector()
* @see RepositorySystemSession#getVersionFilter()
* @see RepositorySystemSession#getDependencyGraphTransformer()
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
throws DependencyCollectionException;
/**
* Collects and resolves the transitive dependencies of an artifact. This operation is essentially a combination of
* {@link #collectDependencies(RepositorySystemSession, CollectRequest)} and
* {@link #resolveArtifacts(RepositorySystemSession, Collection)}.
*
* @param session The repository session, must not be {@code null}.
* @param request The dependency request, must not be {@code null}.
* @return The dependency result, never {@code null}.
* @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could
* not be resolved.
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
DependencyResult resolveDependencies( RepositorySystemSession session, DependencyRequest request )
throws DependencyResolutionException;
/**
* Resolves the path for an artifact. The artifact will be downloaded to the local repository if necessary. An
* artifact that is already resolved will be skipped and is not re-resolved. In general, callers must not assume any
* relationship between an artifact's resolved filename and its coordinates. Note that this method assumes that any
* relocations have already been processed.
*
* @param session The repository session, must not be {@code null}.
* @param request The resolution request, must not be {@code null}.
* @return The resolution result, never {@code null}.
* @throws ArtifactResolutionException If the artifact could not be resolved.
* @see Artifact#getFile()
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
throws ArtifactResolutionException;
/**
* Resolves the paths for a collection of artifacts. Artifacts will be downloaded to the local repository if
* necessary. Artifacts that are already resolved will be skipped and are not re-resolved. In general, callers must
* not assume any relationship between an artifact's filename and its coordinates. Note that this method assumes
* that any relocations have already been processed.
*
* @param session The repository session, must not be {@code null}.
* @param requests The resolution requests, must not be {@code null}.
* @return The resolution results (in request order), never {@code null}.
* @throws ArtifactResolutionException If any artifact could not be resolved.
* @see Artifact#getFile()
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
List resolveArtifacts( RepositorySystemSession session,
Collection extends ArtifactRequest> requests )
throws ArtifactResolutionException;
/**
* Resolves the paths for a collection of metadata. Metadata will be downloaded to the local repository if
* necessary, e.g. because it hasn't been cached yet or the cache is deemed outdated.
*
* @param session The repository session, must not be {@code null}.
* @param requests The resolution requests, must not be {@code null}.
* @return The resolution results (in request order), never {@code null}.
* @see Metadata#getFile()
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
List resolveMetadata( RepositorySystemSession session,
Collection extends MetadataRequest> requests );
/**
* Installs a collection of artifacts and their accompanying metadata to the local repository.
*
* @param session The repository session, must not be {@code null}.
* @param request The installation request, must not be {@code null}.
* @return The installation result, never {@code null}.
* @throws InstallationException If any artifact/metadata from the request could not be installed.
*/
InstallResult install( RepositorySystemSession session, InstallRequest request )
throws InstallationException;
/**
* Uploads a collection of artifacts and their accompanying metadata to a remote repository.
*
* @param session The repository session, must not be {@code null}.
* @param request The deployment request, must not be {@code null}.
* @return The deployment result, never {@code null}.
* @throws DeploymentException If any artifact/metadata from the request could not be deployed.
* @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
*/
DeployResult deploy( RepositorySystemSession session, DeployRequest request )
throws DeploymentException;
/**
* Creates a new manager for the specified local repository. If the specified local repository has no type, the
* default local repository type of the system will be used. Note: It is expected that this method
* invocation is one of the last steps of setting up a new session, in particular any configuration properties
* should have been set already.
*
* @param session The repository system session from which to configure the manager, must not be {@code null}.
* @param localRepository The local repository to create a manager for, must not be {@code null}.
* @return The local repository manager, never {@code null}.
* @throws IllegalArgumentException If the specified repository type is not recognized or no base directory is
* given.
*/
LocalRepositoryManager newLocalRepositoryManager( RepositorySystemSession session, LocalRepository localRepository );
/**
* Creates a new synchronization context.
*
* @param session The repository session during which the context will be used, must not be {@code null}.
* @param shared A flag indicating whether access to the artifacts/metadata associated with the new context can be
* shared among concurrent readers or whether access needs to be exclusive to the calling thread.
* @return The synchronization context, never {@code null}.
*/
SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
/**
* Forms remote repositories suitable for artifact resolution by applying the session's authentication selector and
* similar network configuration to the given repository prototypes. As noted for
* {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repositories passed to e.g.
* {@link #resolveArtifact(RepositorySystemSession, ArtifactRequest) resolveArtifact()} are used as is and expected
* to already carry any required authentication or proxy configuration. This method can be used to apply the
* authentication/proxy configuration from a session to a bare repository definition to obtain the complete
* repository definition for use in the resolution request.
*
* @param session The repository system session from which to configure the repositories, must not be {@code null}.
* @param repositories The repository prototypes from which to derive the resolution repositories, must not be
* {@code null} or contain {@code null} elements.
* @return The resolution repositories, never {@code null}. Note that there is generally no 1:1 relationship of the
* obtained repositories to the original inputs due to mirror selection potentially aggregating multiple
* repositories.
* @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
*/
List newResolutionRepositories( RepositorySystemSession session,
List repositories );
/**
* Forms a remote repository suitable for artifact deployment by applying the session's authentication selector and
* similar network configuration to the given repository prototype. As noted for
* {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repository passed to
* {@link #deploy(RepositorySystemSession, DeployRequest) deploy()} is used as is and expected to already carry any
* required authentication or proxy configuration. This method can be used to apply the authentication/proxy
* configuration from a session to a bare repository definition to obtain the complete repository definition for use
* in the deploy request.
*
* @param session The repository system session from which to configure the repository, must not be {@code null}.
* @param repository The repository prototype from which to derive the deployment repository, must not be
* {@code null}.
* @return The deployment repository, never {@code null}.
* @see #newResolutionRepositories(RepositorySystemSession, List)
*/
RemoteRepository newDeploymentRepository( RepositorySystemSession session, RemoteRepository repository );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java 0000664 0000000 0000000 00000025033 12455463561 0032013 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.util.Map;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.collection.DependencyGraphTransformer;
import org.eclipse.aether.collection.DependencyManager;
import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.collection.DependencyTraverser;
import org.eclipse.aether.collection.VersionFilter;
import org.eclipse.aether.repository.AuthenticationSelector;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.repository.MirrorSelector;
import org.eclipse.aether.repository.ProxySelector;
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.transfer.TransferListener;
/**
* Defines settings and components that control the repository system. Once initialized, the session object itself is
* supposed to be immutable and hence can safely be shared across an entire application and any concurrent threads
* reading it. Components that wish to tweak some aspects of an existing session should use the copy constructor of
* {@link DefaultRepositorySystemSession} and its mutators to derive a custom session.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface RepositorySystemSession
{
/**
* Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
* repositories.
*
* @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
*/
boolean isOffline();
/**
* Indicates whether repositories declared in artifact descriptors should be ignored during transitive dependency
* collection. If enabled, only the repositories originally provided with the collect request will be considered.
*
* @return {@code true} if additional repositories from artifact descriptors are ignored, {@code false} to merge
* those with the originally specified repositories.
*/
boolean isIgnoreArtifactDescriptorRepositories();
/**
* Gets the policy which controls whether resolutions errors from remote repositories should be cached.
*
* @return The resolution error policy for this session or {@code null} if resolution errors should generally not be
* cached.
*/
ResolutionErrorPolicy getResolutionErrorPolicy();
/**
* Gets the policy which controls how errors related to reading artifact descriptors should be handled.
*
* @return The descriptor error policy for this session or {@code null} if descriptor errors should generally not be
* tolerated.
*/
ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
/**
* Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
* repositories being used for resolution.
*
* @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
* @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
* @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
* @see RepositoryPolicy#CHECKSUM_POLICY_WARN
*/
String getChecksumPolicy();
/**
* Gets the global update policy. If set, the global update policy overrides the update policies of the remote
* repositories being used for resolution.
*
* @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
*/
String getUpdatePolicy();
/**
* Gets the local repository used during this session. This is a convenience method for
* {@link LocalRepositoryManager#getRepository()}.
*
* @return The local repository being during this session, never {@code null}.
*/
LocalRepository getLocalRepository();
/**
* Gets the local repository manager used during this session.
*
* @return The local repository manager used during this session, never {@code null}.
*/
LocalRepositoryManager getLocalRepositoryManager();
/**
* Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
* to resolve artifacts.
*
* @return The workspace reader for this session or {@code null} if none.
*/
WorkspaceReader getWorkspaceReader();
/**
* Gets the listener being notified of actions in the repository system.
*
* @return The repository listener or {@code null} if none.
*/
RepositoryListener getRepositoryListener();
/**
* Gets the listener being notified of uploads/downloads by the repository system.
*
* @return The transfer listener or {@code null} if none.
*/
TransferListener getTransferListener();
/**
* Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
* collected from the runtime environment like {@link System#getProperties()} and environment variables.
*
* @return The (read-only) system properties, never {@code null}.
*/
Map getSystemProperties();
/**
* Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
* system properties but are set on the discretion of the user and hence are considered of higher priority than
* system properties.
*
* @return The (read-only) user properties, never {@code null}.
*/
Map getUserProperties();
/**
* Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
* connector-specific behavior, etc.)
*
* @return The (read-only) configuration properties, never {@code null}.
* @see ConfigurationProperties
*/
Map getConfigProperties();
/**
* Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
* not used for remote repositories which are passed as request parameters to the repository system, those
* repositories are supposed to denote the effective repositories.
*
* @return The mirror selector to use, never {@code null}.
* @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
*/
MirrorSelector getMirrorSelector();
/**
* Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
* not used for remote repositories which are passed as request parameters to the repository system, those
* repositories are supposed to have their proxy (if any) already set.
*
* @return The proxy selector to use, never {@code null}.
* @see org.eclipse.aether.repository.RemoteRepository#getProxy()
* @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
*/
ProxySelector getProxySelector();
/**
* Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
* selector is not used for remote repositories which are passed as request parameters to the repository system,
* those repositories are supposed to have their authentication (if any) already set.
*
* @return The authentication selector to use, never {@code null}.
* @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
* @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
*/
AuthenticationSelector getAuthenticationSelector();
/**
* Gets the registry of artifact types recognized by this session, for instance when processing artifact
* descriptors.
*
* @return The artifact type registry, never {@code null}.
*/
ArtifactTypeRegistry getArtifactTypeRegistry();
/**
* Gets the dependency traverser to use for building dependency graphs.
*
* @return The dependency traverser to use for building dependency graphs or {@code null} if dependencies are
* unconditionally traversed.
*/
DependencyTraverser getDependencyTraverser();
/**
* Gets the dependency manager to use for building dependency graphs.
*
* @return The dependency manager to use for building dependency graphs or {@code null} if dependency management is
* not performed.
*/
DependencyManager getDependencyManager();
/**
* Gets the dependency selector to use for building dependency graphs.
*
* @return The dependency selector to use for building dependency graphs or {@code null} if dependencies are
* unconditionally included.
*/
DependencySelector getDependencySelector();
/**
* Gets the version filter to use for building dependency graphs.
*
* @return The version filter to use for building dependency graphs or {@code null} if versions aren't filtered.
*/
VersionFilter getVersionFilter();
/**
* Gets the dependency graph transformer to use for building dependency graphs.
*
* @return The dependency graph transformer to use for building dependency graphs or {@code null} if none.
*/
DependencyGraphTransformer getDependencyGraphTransformer();
/**
* Gets the custom data associated with this session.
*
* @return The session data, never {@code null}.
*/
SessionData getData();
/**
* Gets the cache the repository system may use to save data for future reuse during the session.
*
* @return The repository cache or {@code null} if none.
*/
RepositoryCache getCache();
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/RequestTrace.java 0000664 0000000 0000000 00000007121 12455463561 0027470 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
/**
* A trace of nested requests that are performed by the repository system. This trace information can be used to
* correlate repository events with higher level operations in the application code that eventually caused the events. A
* single trace can carry an arbitrary object as data which is meant to describe a request/operation that is currently
* executed. For call hierarchies within the repository system itself, this data will usually be the {@code *Request}
* object that is currently processed. When invoking methods on the repository system, client code may provide a request
* trace that has been prepopulated with whatever data is useful for the application to indicate its state for later
* evaluation when processing the repository events.
*
* @see RepositoryEvent#getTrace()
*/
public class RequestTrace
{
private final RequestTrace parent;
private final Object data;
/**
* Creates a child of the specified request trace. This method is basically a convenience that will invoke
* {@link RequestTrace#newChild(Object) parent.newChild()} when the specified parent trace is not {@code null} or
* otherwise instantiante a new root trace.
*
* @param parent The parent request trace, may be {@code null}.
* @param data The data to associate with the child trace, may be {@code null}.
* @return The child trace, never {@code null}.
*/
public static RequestTrace newChild( RequestTrace parent, Object data )
{
if ( parent == null )
{
return new RequestTrace( data );
}
return parent.newChild( data );
}
/**
* Creates a new root trace with the specified data.
*
* @param data The data to associate with the trace, may be {@code null}.
*/
public RequestTrace( Object data )
{
this( null, data );
}
/**
* Creates a new trace with the specified data and parent
*
* @param parent The parent trace, may be {@code null} for a root trace.
* @param data The data to associate with the trace, may be {@code null}.
*/
protected RequestTrace( RequestTrace parent, Object data )
{
this.parent = parent;
this.data = data;
}
/**
* Gets the data associated with this trace.
*
* @return The data associated with this trace or {@code null} if none.
*/
public final Object getData()
{
return data;
}
/**
* Gets the parent of this trace.
*
* @return The parent of this trace or {@code null} if this is the root of the trace stack.
*/
public final RequestTrace getParent()
{
return parent;
}
/**
* Creates a new child of this trace.
*
* @param data The data to associate with the child, may be {@code null}.
* @return The child trace, never {@code null}.
*/
public RequestTrace newChild( Object data )
{
return new RequestTrace( this, data );
}
@Override
public String toString()
{
return String.valueOf( getData() );
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/SessionData.java 0000664 0000000 0000000 00000005227 12455463561 0027303 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
/**
* A container for data that is specific to a repository system session. Both components within the repository system
* and clients of the system may use this storage to associate arbitrary data with a session.
*
* Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be
* abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion.
*
* Note: Actual implementations must be thread-safe.
*
* @see RepositorySystemSession#getData()
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface SessionData
{
/**
* Associates the specified session data with the given key.
*
* @param key The key under which to store the session data, must not be {@code null}.
* @param value The data to associate with the key, may be {@code null} to remove the mapping.
*/
void set( Object key, Object value );
/**
* Associates the specified session data with the given key if the key is currently mapped to the given value. This
* method provides an atomic compare-and-update of some key's value.
*
* @param key The key under which to store the session data, must not be {@code null}.
* @param oldValue The expected data currently associated with the key, may be {@code null}.
* @param newValue The data to associate with the key, may be {@code null} to remove the mapping.
* @return {@code true} if the key mapping was successfully updated from the old value to the new value,
* {@code false} if the current key mapping didn't match the expected value and was not updated.
*/
boolean set( Object key, Object oldValue, Object newValue );
/**
* Gets the session data associated with the specified key.
*
* @param key The key for which to retrieve the session data, must not be {@code null}.
* @return The session data associated with the key or {@code null} if none.
*/
Object get( Object key );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/SyncContext.java 0000664 0000000 0000000 00000005764 12455463561 0027355 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether;
import java.io.Closeable;
import java.util.Collection;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
/**
* A synchronization context used to coordinate concurrent access to artifacts or metadatas. The typical usage of a
* synchronization context looks like this:
*
*
* SyncContext syncContext = repositorySystem.newSyncContext( ... );
* try {
* syncContext.acquire( artifacts, metadatas );
* // work with the artifacts and metadatas
* } finally {
* syncContext.close();
* }
*
*
* Within one thread, synchronization contexts may be nested which can naturally happen in a hierarchy of method calls.
* The nested synchronization contexts may also acquire overlapping sets of artifacts/metadatas as long as the following
* conditions are met. If the outer-most context holding a particular resource is exclusive, that resource can be
* reacquired in any nested context. If however the outer-most context is shared, the resource may only be reacquired by
* nested contexts if these are also shared.
*
* A synchronization context is meant to be utilized by only one thread and as such is not thread-safe.
*
* Note that the level of actual synchronization is subject to the implementation and might range from OS-wide to none.
*
* @see RepositorySystem#newSyncContext(RepositorySystemSession, boolean)
*/
public interface SyncContext
extends Closeable
{
/**
* Acquires synchronized access to the specified artifacts and metadatas. The invocation will potentially block
* until all requested resources can be acquired by the calling thread. Acquiring resources that are already
* acquired by this synchronization context has no effect. Please also see the class-level documentation for
* information regarding reentrancy. The method may be invoked multiple times on a synchronization context until all
* desired resources have been acquired.
*
* @param artifacts The artifacts to acquire, may be {@code null} or empty if none.
* @param metadatas The metadatas to acquire, may be {@code null} or empty if none.
*/
void acquire( Collection extends Artifact> artifacts, Collection extends Metadata> metadatas );
/**
* Releases all previously acquired artifacts/metadatas. If no resources have been acquired before or if this
* synchronization context has already been closed, this method does nothing.
*/
void close();
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/ 0000775 0000000 0000000 00000000000 12455463561 0026012 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java 0000664 0000000 0000000 00000015464 12455463561 0032110 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A skeleton class for artifacts.
*/
public abstract class AbstractArtifact
implements Artifact
{
private static final String SNAPSHOT = "SNAPSHOT";
private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile( "^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$" );
public boolean isSnapshot()
{
return isSnapshot( getVersion() );
}
private static boolean isSnapshot( String version )
{
return version.endsWith( SNAPSHOT ) || SNAPSHOT_TIMESTAMP.matcher( version ).matches();
}
public String getBaseVersion()
{
return toBaseVersion( getVersion() );
}
private static String toBaseVersion( String version )
{
String baseVersion;
if ( version == null )
{
baseVersion = version;
}
else if ( version.startsWith( "[" ) || version.startsWith( "(" ) )
{
baseVersion = version;
}
else
{
Matcher m = SNAPSHOT_TIMESTAMP.matcher( version );
if ( m.matches() )
{
if ( m.group( 1 ) != null )
{
baseVersion = m.group( 1 ) + SNAPSHOT;
}
else
{
baseVersion = SNAPSHOT;
}
}
else
{
baseVersion = version;
}
}
return baseVersion;
}
/**
* Creates a new artifact with the specified coordinates, properties and file.
*
* @param version The version of the artifact, may be {@code null}.
* @param properties The properties of the artifact, may be {@code null} if none. The method may assume immutability
* of the supplied map, i.e. need not copy it.
* @param file The resolved file of the artifact, may be {@code null}.
* @return The new artifact instance, never {@code null}.
*/
private Artifact newInstance( String version, Map properties, File file )
{
return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
properties );
}
public Artifact setVersion( String version )
{
String current = getVersion();
if ( current.equals( version ) || ( version == null && current.length() <= 0 ) )
{
return this;
}
return newInstance( version, getProperties(), getFile() );
}
public Artifact setFile( File file )
{
File current = getFile();
if ( ( current == null ) ? file == null : current.equals( file ) )
{
return this;
}
return newInstance( getVersion(), getProperties(), file );
}
public Artifact setProperties( Map properties )
{
Map current = getProperties();
if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
{
return this;
}
return newInstance( getVersion(), copyProperties( properties ), getFile() );
}
public String getProperty( String key, String defaultValue )
{
String value = getProperties().get( key );
return ( value != null ) ? value : defaultValue;
}
/**
* Copies the specified artifact properties. This utility method should be used when creating new artifact instances
* with caller-supplied properties.
*
* @param properties The properties to copy, may be {@code null}.
* @return The copied and read-only properties, never {@code null}.
*/
protected static Map copyProperties( Map properties )
{
if ( properties != null && !properties.isEmpty() )
{
return Collections.unmodifiableMap( new HashMap( properties ) );
}
else
{
return Collections.emptyMap();
}
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder( 128 );
buffer.append( getGroupId() );
buffer.append( ':' ).append( getArtifactId() );
buffer.append( ':' ).append( getExtension() );
if ( getClassifier().length() > 0 )
{
buffer.append( ':' ).append( getClassifier() );
}
buffer.append( ':' ).append( getVersion() );
return buffer.toString();
}
/**
* Compares this artifact with the specified object.
*
* @param obj The object to compare this artifact against, may be {@code null}.
* @return {@code true} if and only if the specified object is another {@link Artifact} with equal coordinates,
* properties and file, {@code false} otherwise.
*/
@Override
public boolean equals( Object obj )
{
if ( obj == this )
{
return true;
}
else if ( !( obj instanceof Artifact ) )
{
return false;
}
Artifact that = (Artifact) obj;
return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
&& getVersion().equals( that.getVersion() ) && getExtension().equals( that.getExtension() )
&& getClassifier().equals( that.getClassifier() ) && eq( getFile(), that.getFile() )
&& getProperties().equals( that.getProperties() );
}
private static boolean eq( T s1, T s2 )
{
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
/**
* Returns a hash code for this artifact.
*
* @return A hash code for the artifact.
*/
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + getGroupId().hashCode();
hash = hash * 31 + getArtifactId().hashCode();
hash = hash * 31 + getExtension().hashCode();
hash = hash * 31 + getClassifier().hashCode();
hash = hash * 31 + getVersion().hashCode();
hash = hash * 31 + hash( getFile() );
return hash;
}
private static int hash( Object obj )
{
return ( obj != null ) ? obj.hashCode() : 0;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/Artifact.java 0000664 0000000 0000000 00000011626 12455463561 0030420 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
import java.io.File;
import java.util.Map;
/**
* A specific artifact. In a nutshell, an artifact has identifying coordinates and optionally a file that denotes its
* data. Note: Artifact instances are supposed to be immutable, e.g. any exposed mutator method returns a new
* artifact instance and leaves the original instance unchanged. Note: Implementors are strongly advised to
* inherit from {@link AbstractArtifact} instead of directly implementing this interface.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface Artifact
{
/**
* Gets the group identifier of this artifact, for example "org.apache.maven".
*
* @return The group identifier, never {@code null}.
*/
String getGroupId();
/**
* Gets the artifact identifier of this artifact, for example "maven-model".
*
* @return The artifact identifier, never {@code null}.
*/
String getArtifactId();
/**
* Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like
* "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or
* deployed will usually have the meta version expanded.
*
* @return The version, never {@code null}.
*/
String getVersion();
/**
* Sets the version of the artifact.
*
* @param version The version of this artifact, may be {@code null} or empty.
* @return The new artifact, never {@code null}.
*/
Artifact setVersion( String version );
/**
* Gets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to the {@link #getVersion()}, the
* base version will always refer to the unresolved meta version.
*
* @return The base version, never {@code null}.
*/
String getBaseVersion();
/**
* Determines whether this artifact uses a snapshot version.
*
* @return {@code true} if the artifact is a snapshot, {@code false} otherwise.
*/
boolean isSnapshot();
/**
* Gets the classifier of this artifact, for example "sources".
*
* @return The classifier or an empty string if none, never {@code null}.
*/
String getClassifier();
/**
* Gets the (file) extension of this artifact, for example "jar" or "tar.gz".
*
* @return The file extension (without leading period), never {@code null}.
*/
String getExtension();
/**
* Gets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general,
* callers must not assume any relationship between an artifact's filename and its coordinates.
*
* @return The file or {@code null} if the artifact isn't resolved.
*/
File getFile();
/**
* Sets the file of the artifact.
*
* @param file The file of the artifact, may be {@code null}
* @return The new artifact, never {@code null}.
*/
Artifact setFile( File file );
/**
* Gets the specified property.
*
* @param key The name of the property, must not be {@code null}.
* @param defaultValue The default value to return in case the property is not set, may be {@code null}.
* @return The requested property value or {@code null} if the property is not set and no default value was
* provided.
* @see ArtifactProperties
*/
String getProperty( String key, String defaultValue );
/**
* Gets the properties of this artifact. Clients may use these properties to associate non-persistent values with an
* artifact that help later processing when the artifact gets passed around within the application.
*
* @return The (read-only) properties, never {@code null}.
* @see ArtifactProperties
*/
Map getProperties();
/**
* Sets the properties for the artifact. Note that these properties exist merely in memory and are not persisted
* when the artifact gets installed/deployed to a repository.
*
* @param properties The properties for the artifact, may be {@code null}.
* @return The new artifact, never {@code null}.
* @see ArtifactProperties
*/
Artifact setProperties( Map properties );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/ArtifactProperties.java 0000664 0000000 0000000 00000004651 12455463561 0032475 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
/**
* The keys for common properties of artifacts.
*
* @see Artifact#getProperties()
*/
public final class ArtifactProperties
{
/**
* A high-level characterization of the artifact, e.g. "maven-plugin" or "test-jar".
*
* @see ArtifactType#getId()
*/
public static final String TYPE = "type";
/**
* The programming language this artifact is relevant for, e.g. "java" or "none".
*/
public static final String LANGUAGE = "language";
/**
* The (expected) path to the artifact on the local filesystem. An artifact which has this property set is assumed
* to be not present in any regular repository and likewise has no artifact descriptor. Artifact resolution will
* verify the path and resolve the artifact if the path actually denotes an existing file. If the path isn't valid,
* resolution will fail and no attempts to search local/remote repositories are made.
*/
public static final String LOCAL_PATH = "localPath";
/**
* A boolean flag indicating whether the artifact presents some kind of bundle that physically includes its
* dependencies, e.g. a fat WAR.
*/
public static final String INCLUDES_DEPENDENCIES = "includesDependencies";
/**
* A boolean flag indicating whether the artifact is meant to be used for the compile/runtime/test build path of a
* consumer project.
*/
public static final String CONSTITUTES_BUILD_PATH = "constitutesBuildPath";
/**
* The URL to a web page from which the artifact can be manually downloaded. This URL is not contacted by the
* repository system but serves as a pointer for the end user to assist in getting artifacts that are not published
* in a proper repository.
*/
public static final String DOWNLOAD_URL = "downloadUrl";
private ArtifactProperties()
{
// hide constructor
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/ArtifactType.java 0000664 0000000 0000000 00000004135 12455463561 0031257 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
import java.util.Map;
/**
* An artifact type describing artifact characteristics/properties that are common for certain artifacts. Artifact types
* are a means to simplify the description of an artifact by referring to an artifact type instead of specifying the
* various properties individually.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
* @see ArtifactTypeRegistry
* @see DefaultArtifact#DefaultArtifact(String, String, String, String, String, ArtifactType)
*/
public interface ArtifactType
{
/**
* Gets the identifier of this type, e.g. "maven-plugin" or "test-jar".
*
* @return The identifier of this type, never {@code null}.
* @see ArtifactProperties#TYPE
*/
String getId();
/**
* Gets the file extension to use for artifacts of this type (unless explicitly overridden by the artifact).
*
* @return The usual file extension, never {@code null}.
*/
String getExtension();
/**
* Gets the classifier to use for artifacts of this type (unless explicitly overridden by the artifact).
*
* @return The usual classifier or an empty string if none, never {@code null}.
*/
String getClassifier();
/**
* Gets the properties to use for artifacts of this type (unless explicitly overridden by the artifact).
*
* @return The (read-only) properties, never {@code null}.
* @see ArtifactProperties
*/
Map getProperties();
}
ArtifactTypeRegistry.java 0000664 0000000 0000000 00000002011 12455463561 0032720 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
/**
* A registry of known artifact types.
*
* @see org.eclipse.aether.RepositorySystemSession#getArtifactTypeRegistry()
*/
public interface ArtifactTypeRegistry
{
/**
* Gets the artifact type with the specified identifier.
*
* @param typeId The identifier of the type, must not be {@code null}.
* @return The artifact type or {@code null} if no type with the requested identifier exists.
*/
ArtifactType get( String typeId );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java 0000664 0000000 0000000 00000025556 12455463561 0031734 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A simple artifact. Note: Instances of this class are immutable and the exposed mutators return new objects
* rather than changing the current instance.
*/
public final class DefaultArtifact
extends AbstractArtifact
{
private final String groupId;
private final String artifactId;
private final String version;
private final String classifier;
private final String extension;
private final File file;
private final Map properties;
/**
* Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the
* artifact's extension defaults to {@code jar} and classifier to an empty string.
*
* @param coords The artifact coordinates in the format
* {@code :[:[:]]:}, must not be {@code null}.
*/
public DefaultArtifact( String coords )
{
this( coords, Collections. emptyMap() );
}
/**
* Creates a new artifact with the specified coordinates and properties. If not specified in the artifact
* coordinates, the artifact's extension defaults to {@code jar} and classifier to an empty string.
*
* @param coords The artifact coordinates in the format
* {@code :[:[:]]:}, must not be {@code null}.
* @param properties The artifact properties, may be {@code null}.
*/
public DefaultArtifact( String coords, Map properties )
{
Pattern p = Pattern.compile( "([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)" );
Matcher m = p.matcher( coords );
if ( !m.matches() )
{
throw new IllegalArgumentException( "Bad artifact coordinates " + coords
+ ", expected format is :[:[:]]:" );
}
groupId = m.group( 1 );
artifactId = m.group( 2 );
extension = get( m.group( 4 ), "jar" );
classifier = get( m.group( 6 ), "" );
version = m.group( 7 );
file = null;
this.properties = copyProperties( properties );
}
private static String get( String value, String defaultValue )
{
return ( value == null || value.length() <= 0 ) ? defaultValue : value;
}
/**
* Creates a new artifact with the specified coordinates and no classifier. Passing {@code null} for any of the
* coordinates is equivalent to specifying an empty string.
*
* @param groupId The group identifier of the artifact, may be {@code null}.
* @param artifactId The artifact identifier of the artifact, may be {@code null}.
* @param extension The file extension of the artifact, may be {@code null}.
* @param version The version of the artifact, may be {@code null}.
*/
public DefaultArtifact( String groupId, String artifactId, String extension, String version )
{
this( groupId, artifactId, "", extension, version );
}
/**
* Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
* equivalent to specifying an empty string.
*
* @param groupId The group identifier of the artifact, may be {@code null}.
* @param artifactId The artifact identifier of the artifact, may be {@code null}.
* @param classifier The classifier of the artifact, may be {@code null}.
* @param extension The file extension of the artifact, may be {@code null}.
* @param version The version of the artifact, may be {@code null}.
*/
public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version )
{
this( groupId, artifactId, classifier, extension, version, null, (File) null );
}
/**
* Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
* equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to
* determine the artifact's classifier and file extension if the corresponding arguments for this constructor are
* {@code null}.
*
* @param groupId The group identifier of the artifact, may be {@code null}.
* @param artifactId The artifact identifier of the artifact, may be {@code null}.
* @param classifier The classifier of the artifact, may be {@code null}.
* @param extension The file extension of the artifact, may be {@code null}.
* @param version The version of the artifact, may be {@code null}.
* @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
*/
public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
ArtifactType type )
{
this( groupId, artifactId, classifier, extension, version, null, type );
}
/**
* Creates a new artifact with the specified coordinates and properties. Passing {@code null} for any of the
* coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor
* will be used to determine the artifact's classifier and file extension if the corresponding arguments for this
* constructor are {@code null}. If the artifact type specifies properties, those will get merged with the
* properties passed directly into the constructor, with the latter properties taking precedence.
*
* @param groupId The group identifier of the artifact, may be {@code null}.
* @param artifactId The artifact identifier of the artifact, may be {@code null}.
* @param classifier The classifier of the artifact, may be {@code null}.
* @param extension The file extension of the artifact, may be {@code null}.
* @param version The version of the artifact, may be {@code null}.
* @param properties The properties of the artifact, may be {@code null} if none.
* @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
*/
public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
Map properties, ArtifactType type )
{
this.groupId = emptify( groupId );
this.artifactId = emptify( artifactId );
if ( classifier != null || type == null )
{
this.classifier = emptify( classifier );
}
else
{
this.classifier = emptify( type.getClassifier() );
}
if ( extension != null || type == null )
{
this.extension = emptify( extension );
}
else
{
this.extension = emptify( type.getExtension() );
}
this.version = emptify( version );
this.file = null;
this.properties = merge( properties, ( type != null ) ? type.getProperties() : null );
}
private static Map merge( Map dominant, Map recessive )
{
Map properties;
if ( ( dominant == null || dominant.isEmpty() ) && ( recessive == null || recessive.isEmpty() ) )
{
properties = Collections.emptyMap();
}
else
{
properties = new HashMap();
if ( recessive != null )
{
properties.putAll( recessive );
}
if ( dominant != null )
{
properties.putAll( dominant );
}
properties = Collections.unmodifiableMap( properties );
}
return properties;
}
/**
* Creates a new artifact with the specified coordinates, properties and file. Passing {@code null} for any of the
* coordinates is equivalent to specifying an empty string.
*
* @param groupId The group identifier of the artifact, may be {@code null}.
* @param artifactId The artifact identifier of the artifact, may be {@code null}.
* @param classifier The classifier of the artifact, may be {@code null}.
* @param extension The file extension of the artifact, may be {@code null}.
* @param version The version of the artifact, may be {@code null}.
* @param properties The properties of the artifact, may be {@code null} if none.
* @param file The resolved file of the artifact, may be {@code null}.
*/
public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
Map properties, File file )
{
this.groupId = emptify( groupId );
this.artifactId = emptify( artifactId );
this.classifier = emptify( classifier );
this.extension = emptify( extension );
this.version = emptify( version );
this.file = file;
this.properties = copyProperties( properties );
}
DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version, File file,
Map properties )
{
// NOTE: This constructor assumes immutability of the provided properties, for internal use only
this.groupId = emptify( groupId );
this.artifactId = emptify( artifactId );
this.classifier = emptify( classifier );
this.extension = emptify( extension );
this.version = emptify( version );
this.file = file;
this.properties = properties;
}
private static String emptify( String str )
{
return ( str == null ) ? "" : str;
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public String getClassifier()
{
return classifier;
}
public String getExtension()
{
return extension;
}
public File getFile()
{
return file;
}
public Map getProperties()
{
return properties;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java0000664 0000000 0000000 00000013106 12455463561 0032562 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.artifact;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* A simple artifact type.
*/
public final class DefaultArtifactType
implements ArtifactType
{
private final String id;
private final String extension;
private final String classifier;
private final Map properties;
/**
* Creates a new artifact type with the specified identifier. This constructor assumes the usual file extension
* equals the given type id and that the usual classifier is empty. Additionally, the properties
* {@link ArtifactProperties#LANGUAGE}, {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and
* {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be set to {@code "none"}, {@code true} and {@code false},
* respectively.
*
* @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
* property, must not be {@code null} or empty.
*/
public DefaultArtifactType( String id )
{
this( id, id, "", "none", false, false );
}
/**
* Creates a new artifact type with the specified properties. Additionally, the properties
* {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be
* set to {@code true} and {@code false}, respectively.
*
* @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
* property, must not be {@code null} or empty.
* @param extension The usual file extension for artifacts of this type, may be {@code null}.
* @param classifier The usual classifier for artifacts of this type, may be {@code null}.
* @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
*/
public DefaultArtifactType( String id, String extension, String classifier, String language )
{
this( id, extension, classifier, language, true, false );
}
/**
* Creates a new artifact type with the specified properties.
*
* @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
* property, must not be {@code null} or empty.
* @param extension The usual file extension for artifacts of this type, may be {@code null}.
* @param classifier The usual classifier for artifacts of this type, may be {@code null}.
* @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
* @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property.
* @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property.
*/
public DefaultArtifactType( String id, String extension, String classifier, String language,
boolean constitutesBuildPath, boolean includesDependencies )
{
if ( id == null || id.length() < 0 )
{
throw new IllegalArgumentException( "no type id specified" );
}
this.id = id;
this.extension = emptify( extension );
this.classifier = emptify( classifier );
Map props = new HashMap();
props.put( ArtifactProperties.TYPE, id );
props.put( ArtifactProperties.LANGUAGE, ( language != null && language.length() > 0 ) ? language : "none" );
props.put( ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString( includesDependencies ) );
props.put( ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString( constitutesBuildPath ) );
properties = Collections.unmodifiableMap( props );
}
/**
* Creates a new artifact type with the specified properties.
*
* @param id The identifier of the type, must not be {@code null} or empty.
* @param extension The usual file extension for artifacts of this type, may be {@code null}.
* @param classifier The usual classifier for artifacts of this type, may be {@code null}.
* @param properties The properties for artifacts of this type, may be {@code null}.
*/
public DefaultArtifactType( String id, String extension, String classifier, Map properties )
{
if ( id == null || id.length() < 0 )
{
throw new IllegalArgumentException( "no type id specified" );
}
this.id = id;
this.extension = emptify( extension );
this.classifier = emptify( classifier );
this.properties = AbstractArtifact.copyProperties( properties );
}
private static String emptify( String str )
{
return ( str == null ) ? "" : str;
}
public String getId()
{
return id;
}
public String getExtension()
{
return extension;
}
public String getClassifier()
{
return classifier;
}
public Map getProperties()
{
return properties;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/artifact/package-info.java 0000664 0000000 0000000 00000001225 12455463561 0031201 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The definition of an artifact, that is the primary entity managed by the repository system.
*/
package org.eclipse.aether.artifact;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/ 0000775 0000000 0000000 00000000000 12455463561 0026350 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/CollectRequest.java 0000664 0000000 0000000 00000026466 12455463561 0032167 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.RemoteRepository;
/**
* A request to collect the transitive dependencies and to build a dependency graph from them. There are three ways to
* create a dependency graph. First, only the root dependency can be given. Second, a root dependency and direct
* dependencies can be specified in which case the specified direct dependencies are merged with the direct dependencies
* retrieved from the artifact descriptor of the root dependency. And last, only direct dependencies can be specified in
* which case the root node of the resulting graph has no associated dependency.
*
* @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
*/
public final class CollectRequest
{
private Artifact rootArtifact;
private Dependency root;
private List dependencies = Collections.emptyList();
private List managedDependencies = Collections.emptyList();
private List repositories = Collections.emptyList();
private String context = "";
private RequestTrace trace;
/**
* Creates an uninitialized request.
*/
public CollectRequest()
{
// enables default constructor
}
/**
* Creates a request with the specified properties.
*
* @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
* @param repositories The repositories to use for the collection, may be {@code null}.
*/
public CollectRequest( Dependency root, List repositories )
{
setRoot( root );
setRepositories( repositories );
}
/**
* Creates a new request with the specified properties.
*
* @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
* @param dependencies The direct dependencies to merge with the direct dependencies from the root dependency's
* artifact descriptor.
* @param repositories The repositories to use for the collection, may be {@code null}.
*/
public CollectRequest( Dependency root, List dependencies, List repositories )
{
setRoot( root );
setDependencies( dependencies );
setRepositories( repositories );
}
/**
* Creates a new request with the specified properties.
*
* @param dependencies The direct dependencies of some imaginary root, may be {@code null}.
* @param managedDependencies The dependency management information to apply to the transitive dependencies, may be
* {@code null}.
* @param repositories The repositories to use for the collection, may be {@code null}.
*/
public CollectRequest( List dependencies, List managedDependencies,
List repositories )
{
setDependencies( dependencies );
setManagedDependencies( managedDependencies );
setRepositories( repositories );
}
/**
* Gets the root artifact for the dependency graph.
*
* @return The root artifact for the dependency graph or {@code null} if none.
*/
public Artifact getRootArtifact()
{
return rootArtifact;
}
/**
* Sets the root artifact for the dependency graph. This must not be confused with {@link #setRoot(Dependency)}: The
* root dependency , like any other specified dependency, will be subject to dependency
* collection/resolution, i.e. should have an artifact descriptor and a corresponding artifact file. The root
* artifact on the other hand is only used as a label for the root node of the graph in case no root
* dependency was specified. As such, the configured root artifact is ignored if {@link #getRoot()} does not return
* {@code null}.
*
* @param rootArtifact The root artifact for the dependency graph, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setRootArtifact( Artifact rootArtifact )
{
this.rootArtifact = rootArtifact;
return this;
}
/**
* Gets the root dependency of the graph.
*
* @return The root dependency of the graph or {@code null} if none.
*/
public Dependency getRoot()
{
return root;
}
/**
* Sets the root dependency of the graph.
*
* @param root The root dependency of the graph, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setRoot( Dependency root )
{
this.root = root;
return this;
}
/**
* Gets the direct dependencies.
*
* @return The direct dependencies, never {@code null}.
*/
public List getDependencies()
{
return dependencies;
}
/**
* Sets the direct dependencies. If both a root dependency and direct dependencies are given in the request, the
* direct dependencies from the request will be merged with the direct dependencies from the root dependency's
* artifact descriptor, giving higher priority to the dependencies from the request.
*
* @param dependencies The direct dependencies, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setDependencies( List dependencies )
{
if ( dependencies == null )
{
this.dependencies = Collections.emptyList();
}
else
{
this.dependencies = dependencies;
}
return this;
}
/**
* Adds the specified direct dependency.
*
* @param dependency The dependency to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest addDependency( Dependency dependency )
{
if ( dependency != null )
{
if ( this.dependencies.isEmpty() )
{
this.dependencies = new ArrayList();
}
this.dependencies.add( dependency );
}
return this;
}
/**
* Gets the dependency management to apply to transitive dependencies.
*
* @return The dependency management to apply to transitive dependencies, never {@code null}.
*/
public List getManagedDependencies()
{
return managedDependencies;
}
/**
* Sets the dependency management to apply to transitive dependencies. To clarify, this management does not apply to
* the direct dependencies of the root node.
*
* @param managedDependencies The dependency management, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setManagedDependencies( List managedDependencies )
{
if ( managedDependencies == null )
{
this.managedDependencies = Collections.emptyList();
}
else
{
this.managedDependencies = managedDependencies;
}
return this;
}
/**
* Adds the specified managed dependency.
*
* @param managedDependency The managed dependency to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest addManagedDependency( Dependency managedDependency )
{
if ( managedDependency != null )
{
if ( this.managedDependencies.isEmpty() )
{
this.managedDependencies = new ArrayList();
}
this.managedDependencies.add( managedDependency );
}
return this;
}
/**
* Gets the repositories to use for the collection.
*
* @return The repositories to use for the collection, never {@code null}.
*/
public List getRepositories()
{
return repositories;
}
/**
* Sets the repositories to use for the collection.
*
* @param repositories The repositories to use for the collection, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setRepositories( List repositories )
{
if ( repositories == null )
{
this.repositories = Collections.emptyList();
}
else
{
this.repositories = repositories;
}
return this;
}
/**
* Adds the specified repository for collection.
*
* @param repository The repository to collect dependency information from, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest addRepository( RemoteRepository repository )
{
if ( repository != null )
{
if ( this.repositories.isEmpty() )
{
this.repositories = new ArrayList();
}
this.repositories.add( repository );
}
return this;
}
/**
* Gets the context in which this request is made.
*
* @return The context, never {@code null}.
*/
public String getRequestContext()
{
return context;
}
/**
* Sets the context in which this request is made.
*
* @param context The context, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setRequestContext( String context )
{
this.context = ( context != null ) ? context : "";
return this;
}
/**
* Gets the trace information that describes the higher level request/operation in which this request is issued.
*
* @return The trace information about the higher level operation or {@code null} if none.
*/
public RequestTrace getTrace()
{
return trace;
}
/**
* Sets the trace information that describes the higher level request/operation in which this request is issued.
*
* @param trace The trace information about the higher level operation, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public CollectRequest setTrace( RequestTrace trace )
{
this.trace = trace;
return this;
}
@Override
public String toString()
{
return getRoot() + " -> " + getDependencies() + " < " + getRepositories();
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/CollectResult.java 0000664 0000000 0000000 00000010024 12455463561 0031774 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.graph.DependencyCycle;
import org.eclipse.aether.graph.DependencyNode;
/**
* The result of a dependency collection request.
*
* @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
*/
public final class CollectResult
{
private final CollectRequest request;
private List exceptions;
private List cycles;
private DependencyNode root;
/**
* Creates a new result for the specified request.
*
* @param request The resolution request, must not be {@code null}.
*/
public CollectResult( CollectRequest request )
{
if ( request == null )
{
throw new IllegalArgumentException( "dependency collection request has not been specified" );
}
this.request = request;
exceptions = Collections.emptyList();
cycles = Collections.emptyList();
}
/**
* Gets the collection request that was made.
*
* @return The collection request, never {@code null}.
*/
public CollectRequest getRequest()
{
return request;
}
/**
* Gets the exceptions that occurred while building the dependency graph.
*
* @return The exceptions that occurred, never {@code null}.
*/
public List getExceptions()
{
return exceptions;
}
/**
* Records the specified exception while building the dependency graph.
*
* @param exception The exception to record, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public CollectResult addException( Exception exception )
{
if ( exception != null )
{
if ( exceptions.isEmpty() )
{
exceptions = new ArrayList();
}
exceptions.add( exception );
}
return this;
}
/**
* Gets the dependency cycles that were encountered while building the dependency graph.
*
* @return The dependency cycles in the (raw) graph, never {@code null}.
*/
public List getCycles()
{
return cycles;
}
/**
* Records the specified dependency cycle.
*
* @param cycle The dependency cycle to record, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public CollectResult addCycle( DependencyCycle cycle )
{
if ( cycle != null )
{
if ( cycles.isEmpty() )
{
cycles = new ArrayList();
}
cycles.add( cycle );
}
return this;
}
/**
* Gets the root node of the dependency graph.
*
* @return The root node of the dependency graph or {@code null} if none.
*/
public DependencyNode getRoot()
{
return root;
}
/**
* Sets the root node of the dependency graph.
*
* @param root The root node of the dependency graph, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public CollectResult setRoot( DependencyNode root )
{
this.root = root;
return this;
}
@Override
public String toString()
{
return String.valueOf( getRoot() );
}
}
DependencyCollectionContext.java 0000664 0000000 0000000 00000005260 12455463561 0034576 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.List;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.graph.Dependency;
/**
* A context used during dependency collection to update the dependency manager, selector and traverser.
*
* @see DependencyManager#deriveChildManager(DependencyCollectionContext)
* @see DependencyTraverser#deriveChildTraverser(DependencyCollectionContext)
* @see DependencySelector#deriveChildSelector(DependencyCollectionContext)
* @see VersionFilter#deriveChildFilter(DependencyCollectionContext)
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface DependencyCollectionContext
{
/**
* Gets the repository system session during which the dependency collection happens.
*
* @return The repository system session, never {@code null}.
*/
RepositorySystemSession getSession();
/**
* Gets the artifact whose children are to be processed next during dependency collection. For all nodes but the
* root, this is simply shorthand for {@code getDependency().getArtifact()}. In case of the root node however,
* {@link #getDependency()} might be {@code null} while the node still has an artifact which serves as its label and
* is not to be resolved.
*
* @return The artifact whose children are going to be processed or {@code null} in case of the root node without
* dependency and label.
*/
Artifact getArtifact();
/**
* Gets the dependency whose children are to be processed next during dependency collection.
*
* @return The dependency whose children are going to be processed or {@code null} in case of the root node without
* dependency.
*/
Dependency getDependency();
/**
* Gets the dependency management information that was contributed by the artifact descriptor of the current
* dependency.
*
* @return The dependency management information, never {@code null}.
*/
List getManagedDependencies();
}
DependencyCollectionException.java 0000664 0000000 0000000 00000006503 12455463561 0035111 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.RepositoryException;
/**
* Thrown in case of bad artifact descriptors, version ranges or other issues encountered during calculation of the
* dependency graph.
*/
public class DependencyCollectionException
extends RepositoryException
{
private final transient CollectResult result;
/**
* Creates a new exception with the specified result.
*
* @param result The collection result at the point the exception occurred, may be {@code null}.
*/
public DependencyCollectionException( CollectResult result )
{
super( "Failed to collect dependencies for " + getSource( result ), getCause( result ) );
this.result = result;
}
/**
* Creates a new exception with the specified result and detail message.
*
* @param result The collection result at the point the exception occurred, may be {@code null}.
* @param message The detail message, may be {@code null}.
*/
public DependencyCollectionException( CollectResult result, String message )
{
super( message, getCause( result ) );
this.result = result;
}
/**
* Creates a new exception with the specified result, detail message and cause.
*
* @param result The collection result at the point the exception occurred, may be {@code null}.
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public DependencyCollectionException( CollectResult result, String message, Throwable cause )
{
super( message, cause );
this.result = result;
}
/**
* Gets the collection result at the point the exception occurred. Despite being incomplete, callers might want to
* use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
*
* @return The collection result or {@code null} if unknown.
*/
public CollectResult getResult()
{
return result;
}
private static String getSource( CollectResult result )
{
if ( result == null )
{
return "";
}
CollectRequest request = result.getRequest();
if ( request.getRoot() != null )
{
return request.getRoot().toString();
}
if ( request.getRootArtifact() != null )
{
return request.getRootArtifact().toString();
}
return request.getDependencies().toString();
}
private static Throwable getCause( CollectResult result )
{
Throwable cause = null;
if ( result != null && !result.getExceptions().isEmpty() )
{
cause = result.getExceptions().get( 0 );
}
return cause;
}
}
DependencyGraphTransformationContext.java 0000664 0000000 0000000 00000003414 12455463561 0036472 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.RepositorySystemSession;
/**
* A context used during dependency collection to exchange information within a chain of dependency graph transformers.
*
* @see DependencyGraphTransformer
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface DependencyGraphTransformationContext
{
/**
* Gets the repository system session during which the graph transformation happens.
*
* @return The repository system session, never {@code null}.
*/
RepositorySystemSession getSession();
/**
* Gets a keyed value from the context.
*
* @param key The key used to query the value, must not be {@code null}.
* @return The queried value or {@code null} if none.
*/
Object get( Object key );
/**
* Puts a keyed value into the context.
*
* @param key The key used to store the value, must not be {@code null}.
* @param value The value to store, may be {@code null} to remove the mapping.
* @return The previous value associated with the key or {@code null} if none.
*/
Object put( Object key, Object value );
}
DependencyGraphTransformer.java 0000664 0000000 0000000 00000003526 12455463561 0034425 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.RepositoryException;
import org.eclipse.aether.graph.DependencyNode;
/**
* Transforms a given dependency graph.
*
* Note: Implementations must be stateless.
*
* Warning: Dependency graphs may generally contain cycles. As such a graph transformer that cannot assume for
* sure that cycles have already been eliminated must gracefully handle cyclic graphs, e.g. guard against infinite
* recursion.
*
* @see org.eclipse.aether.RepositorySystemSession#getDependencyGraphTransformer()
*/
public interface DependencyGraphTransformer
{
/**
* Transforms the dependency graph denoted by the specified root node. The transformer may directly change the
* provided input graph or create a new graph, the former is recommended for performance reasons.
*
* @param node The root node of the (possibly cyclic!) graph to transform, must not be {@code null}.
* @param context The graph transformation context, must not be {@code null}.
* @return The result graph of the transformation, never {@code null}.
* @throws RepositoryException If the transformation failed.
*/
DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
throws RepositoryException;
}
DependencyManagement.java 0000664 0000000 0000000 00000013003 12455463561 0033204 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.Collection;
import java.util.Map;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.Exclusion;
/**
* The management updates to apply to a dependency.
*
* @see DependencyManager#manageDependency(Dependency)
*/
public final class DependencyManagement
{
private String version;
private String scope;
private Boolean optional;
private Collection exclusions;
private Map properties;
/**
* Creates an empty management update.
*/
public DependencyManagement()
{
// enables default constructor
}
/**
* Gets the new version to apply to the dependency.
*
* @return The new version or {@code null} if the version is not managed and the existing dependency version should
* remain unchanged.
*/
public String getVersion()
{
return version;
}
/**
* Sets the new version to apply to the dependency.
*
* @param version The new version, may be {@code null} if the version is not managed.
* @return This management update for chaining, never {@code null}.
*/
public DependencyManagement setVersion( String version )
{
this.version = version;
return this;
}
/**
* Gets the new scope to apply to the dependency.
*
* @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
* unchanged.
*/
public String getScope()
{
return scope;
}
/**
* Sets the new scope to apply to the dependency.
*
* @param scope The new scope, may be {@code null} if the scope is not managed.
* @return This management update for chaining, never {@code null}.
*/
public DependencyManagement setScope( String scope )
{
this.scope = scope;
return this;
}
/**
* Gets the new optional flag to apply to the dependency.
*
* @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
* dependency should remain unchanged.
*/
public Boolean getOptional()
{
return optional;
}
/**
* Sets the new optional flag to apply to the dependency.
*
* @param optional The optional flag, may be {@code null} if the flag is not managed.
* @return This management update for chaining, never {@code null}.
*/
public DependencyManagement setOptional( Boolean optional )
{
this.optional = optional;
return this;
}
/**
* Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
* exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
* with information from dependency management or overridden by it.
*
* @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
* exclusions should remain unchanged.
*/
public Collection getExclusions()
{
return exclusions;
}
/**
* Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
* exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
* with information from dependency management or overridden by it.
*
* @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
* @return This management update for chaining, never {@code null}.
*/
public DependencyManagement setExclusions( Collection exclusions )
{
this.exclusions = exclusions;
return this;
}
/**
* Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
* i.e. the dependency manager controls whether any existing properties get merged with the information from
* dependency management or overridden by it.
*
* @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
* should remain unchanged.
*/
public Map getProperties()
{
return properties;
}
/**
* Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
* i.e. the dependency manager controls whether any existing properties get merged with the information from
* dependency management or overridden by it.
*
* @param properties The new artifact properties, may be {@code null} if the properties are not managed.
* @return This management update for chaining, never {@code null}.
*/
public DependencyManagement setProperties( Map properties )
{
this.properties = properties;
return this;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/DependencyManager.java0000664 0000000 0000000 00000004213 12455463561 0032564 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.graph.Dependency;
/**
* Applies dependency management to the dependencies of a dependency node.
*
* Note: Implementations must be stateless.
*
* Warning: This hook is called from a hot spot and therefore implementations should pay attention to
* performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
*
* @see org.eclipse.aether.RepositorySystemSession#getDependencyManager()
* @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
* CollectRequest)
*/
public interface DependencyManager
{
/**
* Applies dependency management to the specified dependency.
*
* @param dependency The dependency to manage, must not be {@code null}.
* @return The management update to apply to the dependency or {@code null} if the dependency is not managed at all.
*/
DependencyManagement manageDependency( Dependency dependency );
/**
* Derives a dependency manager for the specified collection context. When calculating the child manager,
* implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
*
* @param context The dependency collection context, must not be {@code null}.
* @return The dependency manager for the dependencies of the target node or {@code null} if dependency management
* should no longer be applied.
*/
DependencyManager deriveChildManager( DependencyCollectionContext context );
}
DependencySelector.java 0000664 0000000 0000000 00000004246 12455463561 0032721 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.graph.Dependency;
/**
* Decides what dependencies to include in the dependency graph.
*
* Note: Implementations must be stateless.
*
* Warning: This hook is called from a hot spot and therefore implementations should pay attention to
* performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
*
* @see org.eclipse.aether.RepositorySystemSession#getDependencySelector()
* @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
* CollectRequest)
*/
public interface DependencySelector
{
/**
* Decides whether the specified dependency should be included in the dependency graph.
*
* @param dependency The dependency to check, must not be {@code null}.
* @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
* otherwise.
*/
boolean selectDependency( Dependency dependency );
/**
* Derives a dependency selector for the specified collection context. When calculating the child selector,
* implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
*
* @param context The dependency collection context, must not be {@code null}.
* @return The dependency selector for the target node or {@code null} if dependencies should be unconditionally
* included in the sub graph.
*/
DependencySelector deriveChildSelector( DependencyCollectionContext context );
}
DependencyTraverser.java 0000664 0000000 0000000 00000004510 12455463561 0033110 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import org.eclipse.aether.graph.Dependency;
/**
* Decides whether the dependencies of a dependency node should be traversed as well.
*
* Note: Implementations must be stateless.
*
* Warning: This hook is called from a hot spot and therefore implementations should pay attention to
* performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
*
* @see org.eclipse.aether.RepositorySystemSession#getDependencyTraverser()
* @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
* CollectRequest)
*/
public interface DependencyTraverser
{
/**
* Decides whether the dependencies of the specified dependency should be traversed.
*
* @param dependency The dependency to check, must not be {@code null}.
* @return {@code true} if the dependency graph builder should recurse into the specified dependency and process its
* dependencies, {@code false} otherwise.
*/
boolean traverseDependency( Dependency dependency );
/**
* Derives a dependency traverser that will be used to decide whether the transitive dependencies of the dependency
* given in the collection context shall be traversed. When calculating the child traverser, implementors are
* strongly advised to simply return the current instance if nothing changed to help save memory.
*
* @param context The dependency collection context, must not be {@code null}.
* @return The dependency traverser for the target node or {@code null} if dependencies should be unconditionally
* traversed in the sub graph.
*/
DependencyTraverser deriveChildTraverser( DependencyCollectionContext context );
}
UnsolvableVersionConflictException.java 0000664 0000000 0000000 00000010407 12455463561 0036157 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import org.eclipse.aether.RepositoryException;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.version.VersionConstraint;
/**
* Thrown in case of an unsolvable conflict between different version constraints for a dependency.
*/
public class UnsolvableVersionConflictException
extends RepositoryException
{
private final transient Collection versions;
private final transient Collection extends List extends DependencyNode>> paths;
/**
* Creates a new exception with the specified paths to conflicting nodes in the dependency graph.
*
* @param paths The paths to the dependency nodes that participate in the version conflict, may be {@code null}.
*/
public UnsolvableVersionConflictException( Collection extends List extends DependencyNode>> paths )
{
super( "Could not resolve version conflict among " + toPaths( paths ) );
if ( paths == null )
{
this.paths = Collections.emptyList();
this.versions = Collections.emptyList();
}
else
{
this.paths = paths;
this.versions = new LinkedHashSet();
for ( List extends DependencyNode> path : paths )
{
VersionConstraint constraint = path.get( path.size() - 1 ).getVersionConstraint();
if ( constraint != null && constraint.getRange() != null )
{
versions.add( constraint.toString() );
}
}
}
}
private static String toPaths( Collection extends List extends DependencyNode>> paths )
{
String result = "";
if ( paths != null )
{
Collection strings = new LinkedHashSet();
for ( List extends DependencyNode> path : paths )
{
strings.add( toPath( path ) );
}
result = strings.toString();
}
return result;
}
private static String toPath( List extends DependencyNode> path )
{
StringBuilder buffer = new StringBuilder( 256 );
for ( Iterator extends DependencyNode> it = path.iterator(); it.hasNext(); )
{
DependencyNode node = it.next();
if ( node.getDependency() == null )
{
continue;
}
Artifact artifact = node.getDependency().getArtifact();
buffer.append( artifact.getGroupId() );
buffer.append( ':' ).append( artifact.getArtifactId() );
buffer.append( ':' ).append( artifact.getExtension() );
if ( artifact.getClassifier().length() > 0 )
{
buffer.append( ':' ).append( artifact.getClassifier() );
}
buffer.append( ':' ).append( node.getVersionConstraint() );
if ( it.hasNext() )
{
buffer.append( " -> " );
}
}
return buffer.toString();
}
/**
* Gets the paths leading to the conflicting dependencies.
*
* @return The (read-only) paths leading to the conflicting dependencies, never {@code null}.
*/
public Collection extends List extends DependencyNode>> getPaths()
{
return paths;
}
/**
* Gets the conflicting version constraints of the dependency.
*
* @return The (read-only) conflicting version constraints, never {@code null}.
*/
public Collection getVersions()
{
return versions;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/VersionFilter.java 0000664 0000000 0000000 00000012445 12455463561 0032014 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2013, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.aether.RepositoryException;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.ArtifactRepository;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint;
/**
* Decides which versions matching a version range should actually be considered for the dependency graph. The version
* filter is not invoked for dependencies that do not declare a version range but a single version.
*
* Note: Implementations must be stateless.
*
* Warning: This hook is called from a hot spot and therefore implementations should pay attention to
* performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
*
* @see org.eclipse.aether.RepositorySystemSession#getVersionFilter()
* @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
* CollectRequest)
*/
public interface VersionFilter
{
/**
* A context used during version filtering to hold relevant data.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
interface VersionFilterContext
extends Iterable
{
/**
* Gets the repository system session during which the version filtering happens.
*
* @return The repository system session, never {@code null}.
*/
RepositorySystemSession getSession();
/**
* Gets the dependency whose version range is being filtered.
*
* @return The dependency, never {@code null}.
*/
Dependency getDependency();
/**
* Gets the total number of available versions. This count reflects any removals made during version filtering.
*
* @return The total number of available versions.
*/
int getCount();
/**
* Gets an iterator over the available versions of the dependency. The iterator returns versions in ascending
* order. Use {@link Iterator#remove()} to exclude a version from further consideration in the dependency graph.
*
* @return The iterator of available versions, never {@code null}.
*/
Iterator iterator();
/**
* Gets the version constraint that was parsed from the dependency's version string.
*
* @return The parsed version constraint, never {@code null}.
*/
VersionConstraint getVersionConstraint();
/**
* Gets the repository from which the specified version was resolved.
*
* @param version The version whose source repository should be retrieved, must not be {@code null}.
* @return The repository from which the version was resolved or {@code null} if unknown.
*/
ArtifactRepository getRepository( Version version );
/**
* Gets the remote repositories from which the versions were resolved.
*
* @return The (read-only) list of repositories, never {@code null}.
*/
List getRepositories();
}
/**
* Filters the available versions for a given dependency. Implementations will usually call
* {@link VersionFilterContext#iterator() context.iterator()} to inspect the available versions and use
* {@link java.util.Iterator#remove()} to delete unacceptable versions. If no versions remain after all filtering
* has been performed, the dependency collection process will automatically fail, i.e. implementations need not
* handle this situation on their own.
*
* @param context The version filter context, must not be {@code null}.
* @throws RepositoryException If the filtering could not be performed.
*/
void filterVersions( VersionFilterContext context )
throws RepositoryException;
/**
* Derives a version filter for the specified collection context. The derived filter will be used to handle version
* ranges encountered in child dependencies of the current node. When calculating the child filter, implementors are
* strongly advised to simply return the current instance if nothing changed to help save memory.
*
* @param context The dependency collection context, must not be {@code null}.
* @return The version filter for the target node or {@code null} if versions should not be filtered any more.
*/
VersionFilter deriveChildFilter( DependencyCollectionContext context );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/collection/package-info.java 0000664 0000000 0000000 00000001270 12455463561 0031537 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The types and extension points for collecting the transitive dependencies of an artifact and building a dependency
* graph.
*/
package org.eclipse.aether.collection;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/deployment/ 0000775 0000000 0000000 00000000000 12455463561 0026375 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/deployment/DeployRequest.java 0000664 0000000 0000000 00000012232 12455463561 0032045 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.deployment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.RemoteRepository;
/**
* A request to deploy artifacts and their accompanying metadata into the a remote repository.
*
* @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
*/
public final class DeployRequest
{
private Collection artifacts = Collections.emptyList();
private Collection metadata = Collections.emptyList();
private RemoteRepository repository;
private RequestTrace trace;
/**
* Creates an uninitialized request.
*/
public DeployRequest()
{
}
/**
* Gets the artifact to deploy.
*
* @return The artifacts to deploy, never {@code null}.
*/
public Collection getArtifacts()
{
return artifacts;
}
/**
* Sets the artifacts to deploy.
*
* @param artifacts The artifacts to deploy, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest setArtifacts( Collection artifacts )
{
if ( artifacts == null )
{
this.artifacts = Collections.emptyList();
}
else
{
this.artifacts = artifacts;
}
return this;
}
/**
* Adds the specified artifacts for deployment.
*
* @param artifact The artifact to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest addArtifact( Artifact artifact )
{
if ( artifact != null )
{
if ( artifacts.isEmpty() )
{
artifacts = new ArrayList();
}
artifacts.add( artifact );
}
return this;
}
/**
* Gets the metadata to deploy.
*
* @return The metadata to deploy, never {@code null}.
*/
public Collection getMetadata()
{
return metadata;
}
/**
* Sets the metadata to deploy.
*
* @param metadata The metadata to deploy, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest setMetadata( Collection metadata )
{
if ( metadata == null )
{
this.metadata = Collections.emptyList();
}
else
{
this.metadata = metadata;
}
return this;
}
/**
* Adds the specified metadata for deployment.
*
* @param metadata The metadata to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest addMetadata( Metadata metadata )
{
if ( metadata != null )
{
if ( this.metadata.isEmpty() )
{
this.metadata = new ArrayList();
}
this.metadata.add( metadata );
}
return this;
}
/**
* Gets the repository to deploy to.
*
* @return The repository to deploy to or {@code null} if not set.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Sets the repository to deploy to.
*
* @param repository The repository to deploy to, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest setRepository( RemoteRepository repository )
{
this.repository = repository;
return this;
}
/**
* Gets the trace information that describes the higher level request/operation in which this request is issued.
*
* @return The trace information about the higher level operation or {@code null} if none.
*/
public RequestTrace getTrace()
{
return trace;
}
/**
* Sets the trace information that describes the higher level request/operation in which this request is issued.
*
* @param trace The trace information about the higher level operation, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public DeployRequest setTrace( RequestTrace trace )
{
this.trace = trace;
return this;
}
@Override
public String toString()
{
return getArtifacts() + ", " + getMetadata() + " > " + getRepository();
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java 0000664 0000000 0000000 00000010710 12455463561 0031672 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.deployment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
/**
* The result of deploying artifacts and their accompanying metadata into the a remote repository.
*
* @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
*/
public final class DeployResult
{
private final DeployRequest request;
private Collection artifacts;
private Collection metadata;
/**
* Creates a new result for the specified request.
*
* @param request The deployment request, must not be {@code null}.
*/
public DeployResult( DeployRequest request )
{
if ( request == null )
{
throw new IllegalArgumentException( "deploy request has not been specified" );
}
this.request = request;
artifacts = Collections.emptyList();
metadata = Collections.emptyList();
}
/**
* Gets the deploy request that was made.
*
* @return The deploy request, never {@code null}.
*/
public DeployRequest getRequest()
{
return request;
}
/**
* Gets the artifacts that got deployed.
*
* @return The deployed artifacts, never {@code null}.
*/
public Collection getArtifacts()
{
return artifacts;
}
/**
* Sets the artifacts that got deployed.
*
* @param artifacts The deployed artifacts, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public DeployResult setArtifacts( Collection artifacts )
{
if ( artifacts == null )
{
this.artifacts = Collections.emptyList();
}
else
{
this.artifacts = artifacts;
}
return this;
}
/**
* Adds the specified artifacts to the result.
*
* @param artifact The deployed artifact to add, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public DeployResult addArtifact( Artifact artifact )
{
if ( artifact != null )
{
if ( artifacts.isEmpty() )
{
artifacts = new ArrayList();
}
artifacts.add( artifact );
}
return this;
}
/**
* Gets the metadata that got deployed. Note that due to automatically generated metadata, there might have been
* more metadata deployed than originally specified in the deploy request.
*
* @return The deployed metadata, never {@code null}.
*/
public Collection getMetadata()
{
return metadata;
}
/**
* Sets the metadata that got deployed.
*
* @param metadata The deployed metadata, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public DeployResult setMetadata( Collection metadata )
{
if ( metadata == null )
{
this.metadata = Collections.emptyList();
}
else
{
this.metadata = metadata;
}
return this;
}
/**
* Adds the specified metadata to this result.
*
* @param metadata The deployed metadata to add, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public DeployResult addMetadata( Metadata metadata )
{
if ( metadata != null )
{
if ( this.metadata.isEmpty() )
{
this.metadata = new ArrayList();
}
this.metadata.add( metadata );
}
return this;
}
@Override
public String toString()
{
return getArtifacts() + ", " + getMetadata();
}
}
DeploymentException.java 0000664 0000000 0000000 00000002512 12455463561 0033160 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/deployment /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.deployment;
import org.eclipse.aether.RepositoryException;
/**
* Thrown in case of a deployment error like authentication failure.
*/
public class DeploymentException
extends RepositoryException
{
/**
* Creates a new exception with the specified detail message.
*
* @param message The detail message, may be {@code null}.
*/
public DeploymentException( String message )
{
super( message );
}
/**
* Creates a new exception with the specified detail message and cause.
*
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public DeploymentException( String message, Throwable cause )
{
super( message, cause );
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/deployment/package-info.java 0000664 0000000 0000000 00000001204 12455463561 0031561 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The types supporting the publishing of artifacts to a remote repository.
*/
package org.eclipse.aether.deployment;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/ 0000775 0000000 0000000 00000000000 12455463561 0025316 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java 0000664 0000000 0000000 00000023054 12455463561 0032356 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint;
/**
* A node within a dependency graph.
*/
public final class DefaultDependencyNode
implements DependencyNode
{
private List children;
private Dependency dependency;
private Artifact artifact;
private List extends Artifact> relocations;
private Collection extends Artifact> aliases;
private VersionConstraint versionConstraint;
private Version version;
private byte managedBits;
private List repositories;
private String context;
private Map data;
/**
* Creates a new node with the specified dependency.
*
* @param dependency The dependency associated with this node, may be {@code null} for a root node.
*/
public DefaultDependencyNode( Dependency dependency )
{
this.dependency = dependency;
artifact = ( dependency != null ) ? dependency.getArtifact() : null;
children = new ArrayList( 0 );
aliases = relocations = Collections.emptyList();
repositories = Collections.emptyList();
context = "";
data = Collections.emptyMap();
}
/**
* Creates a new root node with the specified artifact as its label. Note that the new node has no dependency, i.e.
* {@link #getDependency()} will return {@code null}. Put differently, the specified artifact will not be subject to
* dependency collection/resolution.
*
* @param artifact The artifact to use as label for this node, may be {@code null}.
*/
public DefaultDependencyNode( Artifact artifact )
{
this.artifact = artifact;
children = new ArrayList( 0 );
aliases = relocations = Collections.emptyList();
repositories = Collections.emptyList();
context = "";
data = Collections.emptyMap();
}
/**
* Creates a mostly shallow clone of the specified node. The new node has its own copy of any custom data and
* initially no children.
*
* @param node The node to copy, must not be {@code null}.
*/
public DefaultDependencyNode( DependencyNode node )
{
dependency = node.getDependency();
artifact = node.getArtifact();
children = new ArrayList( 0 );
setAliases( node.getAliases() );
setRequestContext( node.getRequestContext() );
setManagedBits( node.getManagedBits() );
setRelocations( node.getRelocations() );
setRepositories( node.getRepositories() );
setVersion( node.getVersion() );
setVersionConstraint( node.getVersionConstraint() );
Map, ?> data = node.getData();
setData( data.isEmpty() ? null : new HashMap( data ) );
}
public List getChildren()
{
return children;
}
public void setChildren( List children )
{
if ( children == null )
{
this.children = new ArrayList( 0 );
}
else
{
this.children = children;
}
}
public Dependency getDependency()
{
return dependency;
}
public Artifact getArtifact()
{
return artifact;
}
public void setArtifact( Artifact artifact )
{
if ( dependency == null )
{
throw new UnsupportedOperationException( "node does not have a dependency" );
}
dependency = dependency.setArtifact( artifact );
this.artifact = dependency.getArtifact();
}
public List extends Artifact> getRelocations()
{
return relocations;
}
/**
* Sets the sequence of relocations that was followed to resolve this dependency's artifact.
*
* @param relocations The sequence of relocations, may be {@code null}.
*/
public void setRelocations( List extends Artifact> relocations )
{
if ( relocations == null || relocations.isEmpty() )
{
this.relocations = Collections.emptyList();
}
else
{
this.relocations = relocations;
}
}
public Collection extends Artifact> getAliases()
{
return aliases;
}
/**
* Sets the known aliases for this dependency's artifact.
*
* @param aliases The known aliases, may be {@code null}.
*/
public void setAliases( Collection extends Artifact> aliases )
{
if ( aliases == null || aliases.isEmpty() )
{
this.aliases = Collections.emptyList();
}
else
{
this.aliases = aliases;
}
}
public VersionConstraint getVersionConstraint()
{
return versionConstraint;
}
/**
* Sets the version constraint that was parsed from the dependency's version declaration.
*
* @param versionConstraint The version constraint for this node, may be {@code null}.
*/
public void setVersionConstraint( VersionConstraint versionConstraint )
{
this.versionConstraint = versionConstraint;
}
public Version getVersion()
{
return version;
}
/**
* Sets the version that was selected for the dependency's target artifact.
*
* @param version The parsed version, may be {@code null}.
*/
public void setVersion( Version version )
{
this.version = version;
}
public void setScope( String scope )
{
if ( dependency == null )
{
throw new UnsupportedOperationException( "node does not have a dependency" );
}
dependency = dependency.setScope( scope );
}
public void setOptional( Boolean optional )
{
if ( dependency == null )
{
throw new UnsupportedOperationException( "node does not have a dependency" );
}
dependency = dependency.setOptional( optional );
}
public int getManagedBits()
{
return managedBits;
}
/**
* Sets a bit field indicating which attributes of this node were subject to dependency management.
*
* @param managedBits The bit field indicating the managed attributes or {@code 0} if dependency management wasn't
* applied.
*/
public void setManagedBits( int managedBits )
{
this.managedBits = (byte) ( managedBits & 0x1F );
}
public List getRepositories()
{
return repositories;
}
/**
* Sets the remote repositories from which this node's artifact shall be resolved.
*
* @param repositories The remote repositories to use for artifact resolution, may be {@code null}.
*/
public void setRepositories( List repositories )
{
if ( repositories == null || repositories.isEmpty() )
{
this.repositories = Collections.emptyList();
}
else
{
this.repositories = repositories;
}
}
public String getRequestContext()
{
return context;
}
public void setRequestContext( String context )
{
this.context = ( context != null ) ? context : "";
}
public Map getData()
{
return data;
}
public void setData( Map data )
{
if ( data == null )
{
this.data = Collections.emptyMap();
}
else
{
this.data = data;
}
}
public void setData( Object key, Object value )
{
if ( key == null )
{
throw new IllegalArgumentException( "key must not be null" );
}
if ( value == null )
{
if ( !data.isEmpty() )
{
data.remove( key );
if ( data.isEmpty() )
{
data = Collections.emptyMap();
}
}
}
else
{
if ( data.isEmpty() )
{
data = new HashMap( 1, 2 ); // nodes can be numerous so let's be space conservative
}
data.put( key, value );
}
}
public boolean accept( DependencyVisitor visitor )
{
if ( visitor.visitEnter( this ) )
{
for ( DependencyNode child : children )
{
if ( !child.accept( visitor ) )
{
break;
}
}
}
return visitor.visitLeave( this );
}
@Override
public String toString()
{
Dependency dep = getDependency();
if ( dep == null )
{
return String.valueOf( getArtifact() );
}
return dep.toString();
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/Dependency.java 0000664 0000000 0000000 00000023330 12455463561 0030240 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.NoSuchElementException;
import java.util.Set;
import org.eclipse.aether.artifact.Artifact;
/**
* A dependency to some artifact. Note: Instances of this class are immutable and the exposed mutators return
* new objects rather than changing the current instance.
*/
public final class Dependency
{
private final Artifact artifact;
private final String scope;
private final Boolean optional;
private final Set exclusions;
/**
* Creates a mandatory dependency on the specified artifact with the given scope.
*
* @param artifact The artifact being depended on, must not be {@code null}.
* @param scope The scope of the dependency, may be {@code null}.
*/
public Dependency( Artifact artifact, String scope )
{
this( artifact, scope, false );
}
/**
* Creates a dependency on the specified artifact with the given scope.
*
* @param artifact The artifact being depended on, must not be {@code null}.
* @param scope The scope of the dependency, may be {@code null}.
* @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
*/
public Dependency( Artifact artifact, String scope, Boolean optional )
{
this( artifact, scope, optional, null );
}
/**
* Creates a dependency on the specified artifact with the given scope and exclusions.
*
* @param artifact The artifact being depended on, must not be {@code null}.
* @param scope The scope of the dependency, may be {@code null}.
* @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
* @param exclusions The exclusions that apply to transitive dependencies, may be {@code null} if none.
*/
public Dependency( Artifact artifact, String scope, Boolean optional, Collection exclusions )
{
this( artifact, scope, Exclusions.copy( exclusions ), optional );
}
private Dependency( Artifact artifact, String scope, Set exclusions, Boolean optional )
{
// NOTE: This constructor assumes immutability of the provided exclusion collection, for internal use only
if ( artifact == null )
{
throw new IllegalArgumentException( "no artifact specified for dependency" );
}
this.artifact = artifact;
this.scope = ( scope != null ) ? scope : "";
this.optional = optional;
this.exclusions = exclusions;
}
/**
* Gets the artifact being depended on.
*
* @return The artifact, never {@code null}.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Sets the artifact being depended on.
*
* @param artifact The artifact, must not be {@code null}.
* @return The new dependency, never {@code null}.
*/
public Dependency setArtifact( Artifact artifact )
{
if ( this.artifact.equals( artifact ) )
{
return this;
}
return new Dependency( artifact, scope, exclusions, optional );
}
/**
* Gets the scope of the dependency. The scope defines in which context this dependency is relevant.
*
* @return The scope or an empty string if not set, never {@code null}.
*/
public String getScope()
{
return scope;
}
/**
* Sets the scope of the dependency, e.g. "compile".
*
* @param scope The scope of the dependency, may be {@code null}.
* @return The new dependency, never {@code null}.
*/
public Dependency setScope( String scope )
{
if ( this.scope.equals( scope ) || ( scope == null && this.scope.length() <= 0 ) )
{
return this;
}
return new Dependency( artifact, scope, exclusions, optional );
}
/**
* Indicates whether this dependency is optional or not. Optional dependencies can be ignored in some contexts.
*
* @return {@code true} if the dependency is (definitively) optional, {@code false} otherwise.
*/
public boolean isOptional()
{
return Boolean.TRUE.equals( optional );
}
/**
* Gets the optional flag for the dependency. Note: Most clients will usually call {@link #isOptional()} to
* determine the optional flag, this method is for advanced use cases where three-valued logic is required.
*
* @return The optional flag or {@code null} if unspecified.
*/
public Boolean getOptional()
{
return optional;
}
/**
* Sets the optional flag for the dependency.
*
* @param optional {@code true} if the dependency is optional, {@code false} if the dependency is mandatory, may be
* {@code null} if unspecified.
* @return The new dependency, never {@code null}.
*/
public Dependency setOptional( Boolean optional )
{
if ( eq( this.optional, optional ) )
{
return this;
}
return new Dependency( artifact, scope, exclusions, optional );
}
/**
* Gets the exclusions for this dependency. Exclusions can be used to remove transitive dependencies during
* resolution.
*
* @return The (read-only) exclusions, never {@code null}.
*/
public Collection getExclusions()
{
return exclusions;
}
/**
* Sets the exclusions for the dependency.
*
* @param exclusions The exclusions, may be {@code null}.
* @return The new dependency, never {@code null}.
*/
public Dependency setExclusions( Collection exclusions )
{
if ( hasEquivalentExclusions( exclusions ) )
{
return this;
}
return new Dependency( artifact, scope, optional, exclusions );
}
private boolean hasEquivalentExclusions( Collection exclusions )
{
if ( exclusions == null || exclusions.isEmpty() )
{
return this.exclusions.isEmpty();
}
if ( exclusions instanceof Set )
{
return this.exclusions.equals( exclusions );
}
return exclusions.size() >= this.exclusions.size() && this.exclusions.containsAll( exclusions )
&& exclusions.containsAll( this.exclusions );
}
@Override
public String toString()
{
return String.valueOf( getArtifact() ) + " (" + getScope() + ( isOptional() ? "?" : "" ) + ")";
}
@Override
public boolean equals( Object obj )
{
if ( obj == this )
{
return true;
}
else if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
Dependency that = (Dependency) obj;
return artifact.equals( that.artifact ) && scope.equals( that.scope ) && eq( optional, that.optional )
&& exclusions.equals( that.exclusions );
}
private static boolean eq( T o1, T o2 )
{
return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + artifact.hashCode();
hash = hash * 31 + scope.hashCode();
hash = hash * 31 + ( optional != null ? optional.hashCode() : 0 );
hash = hash * 31 + exclusions.size();
return hash;
}
private static class Exclusions
extends AbstractSet
{
private final Exclusion[] exclusions;
public static Set copy( Collection exclusions )
{
if ( exclusions == null || exclusions.isEmpty() )
{
return Collections.emptySet();
}
return new Exclusions( exclusions );
}
private Exclusions( Collection exclusions )
{
if ( exclusions.size() > 1 && !( exclusions instanceof Set ) )
{
exclusions = new LinkedHashSet( exclusions );
}
this.exclusions = exclusions.toArray( new Exclusion[exclusions.size()] );
}
@Override
public Iterator iterator()
{
return new Iterator()
{
private int cursor = 0;
public boolean hasNext()
{
return cursor < exclusions.length;
}
public Exclusion next()
{
try
{
Exclusion exclusion = exclusions[cursor];
cursor++;
return exclusion;
}
catch ( IndexOutOfBoundsException e )
{
throw new NoSuchElementException();
}
}
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
@Override
public int size()
{
return exclusions.length;
}
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/DependencyCycle.java 0000664 0000000 0000000 00000003504 12455463561 0031221 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2013, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
import java.util.List;
/**
* A cycle within a dependency graph, that is a sequence of dependencies d_1, d_2, ..., d_n where d_1 and d_n have the
* same versionless coordinates. In more practical terms, a cycle occurs when a project directly or indirectly depends
* on its own output artifact.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface DependencyCycle
{
/**
* Gets the dependencies that lead to the first dependency on the cycle, starting from the root of the dependency
* graph.
*
* @return The (read-only) sequence of dependencies that precedes the cycle in the graph, potentially empty but
* never {@code null}.
*/
List getPrecedingDependencies();
/**
* Gets the dependencies that actually form the cycle. For example, a -> b -> c -> a, i.e. the last
* dependency in this sequence duplicates the first element and closes the cycle. Hence the length of the cycle is
* the size of the returned sequence minus 1.
*
* @return The (read-only) sequence of dependencies that forms the cycle, never {@code null}.
*/
List getCyclicDependencies();
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/DependencyFilter.java 0000664 0000000 0000000 00000002677 12455463561 0031421 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
import java.util.List;
/**
* A filter to include/exclude dependency nodes during other operations.
*/
public interface DependencyFilter
{
/**
* Indicates whether the specified dependency node shall be included or excluded.
*
* @param node The dependency node to filter, must not be {@code null}.
* @param parents The (read-only) chain of parent nodes that leads to the node to be filtered, must not be
* {@code null}. Iterating this (possibly empty) list walks up the dependency graph towards the root
* node, i.e. the immediate parent node (if any) is the first node in the list. The size of the list also
* denotes the zero-based depth of the filtered node.
* @return {@code true} to include the dependency node, {@code false} to exclude it.
*/
boolean accept( DependencyNode node, List parents );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/DependencyNode.java 0000664 0000000 0000000 00000020661 12455463561 0031052 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint;
/**
* A node within a dependency graph. To conserve memory, dependency graphs may reuse a given node instance multiple
* times to represent reoccurring dependencies. As such clients traversing a dependency graph should be prepared to
* discover multiple paths leading to the same node instance unless the input graph is known to be a duplicate-free
* tree. Note: Unless otherwise noted, implementation classes are not thread-safe and dependency nodes should
* not be mutated by concurrent threads.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface DependencyNode
{
/**
* A bit flag indicating the dependency version was subject to dependency management
*
* @see #getManagedBits()
*/
int MANAGED_VERSION = 0x01;
/**
* A bit flag indicating the dependency scope was subject to dependency management
*
* @see #getManagedBits()
*/
int MANAGED_SCOPE = 0x02;
/**
* A bit flag indicating the optional flag was subject to dependency management
*
* @see #getManagedBits()
*/
int MANAGED_OPTIONAL = 0x04;
/**
* A bit flag indicating the artifact properties were subject to dependency management
*
* @see #getManagedBits()
*/
int MANAGED_PROPERTIES = 0x08;
/**
* A bit flag indicating the exclusions were subject to dependency management
*
* @see #getManagedBits()
*/
int MANAGED_EXCLUSIONS = 0x10;
/**
* Gets the child nodes of this node. To conserve memory, dependency nodes with equal dependencies may share the
* same child list instance. Hence clients mutating the child list need to be aware that these changes might affect
* more than this node. Where this is not desired, the child list should be copied before mutation if the client
* cannot be sure whether it might be shared with other nodes in the graph.
*
* @return The child nodes of this node, never {@code null}.
*/
List getChildren();
/**
* Sets the child nodes of this node.
*
* @param children The child nodes, may be {@code null}
*/
void setChildren( List children );
/**
* Gets the dependency associated with this node. Note: For dependency graphs that have been constructed
* without a root dependency, this method will yield {@code null} when invoked on the graph's root node. The root
* node of such graphs may however still have a label as returned by {@link #getArtifact()}.
*
* @return The dependency or {@code null} if none.
*/
Dependency getDependency();
/**
* Gets the artifact associated with this node. If this node is associated with a dependency, this is equivalent to
* {@code getDependency().getArtifact()}. Otherwise the artifact merely provides a label for this node in which case
* the artifact must not be subjected to dependency collection/resolution.
*
* @return The associated artifact or {@code null} if none.
*/
Artifact getArtifact();
/**
* Updates the artifact of the dependency after resolution. The new artifact must have the same coordinates as the
* original artifact. This method may only be invoked if this node actually has a dependency, i.e. if
* {@link #getDependency()} is not null.
*
* @param artifact The artifact satisfying the dependency, must not be {@code null}.
*/
void setArtifact( Artifact artifact );
/**
* Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.
*
* @return The (read-only) sequence of relocations, never {@code null}.
*/
List extends Artifact> getRelocations();
/**
* Gets the known aliases for this dependency's artifact. An alias can be used to mark a patched rebuild of some
* other artifact as such, thereby allowing conflict resolution to consider the patched and the original artifact as
* a conflict.
*
* @return The (read-only) set of known aliases, never {@code null}.
*/
Collection extends Artifact> getAliases();
/**
* Gets the version constraint that was parsed from the dependency's version declaration.
*
* @return The version constraint for this node or {@code null}.
*/
VersionConstraint getVersionConstraint();
/**
* Gets the version that was selected for the dependency's target artifact.
*
* @return The parsed version or {@code null}.
*/
Version getVersion();
/**
* Sets the scope of the dependency. This method may only be invoked if this node actually has a dependency, i.e. if
* {@link #getDependency()} is not null.
*
* @param scope The scope, may be {@code null}.
*/
void setScope( String scope );
/**
* Sets the optional flag of the dependency. This method may only be invoked if this node actually has a dependency,
* i.e. if {@link #getDependency()} is not null.
*
* @param optional The optional flag, may be {@code null}.
*/
void setOptional( Boolean optional );
/**
* Gets a bit field indicating which attributes of this node were subject to dependency management.
*
* @return A bit field containing any of the bits {@link #MANAGED_VERSION}, {@link #MANAGED_SCOPE},
* {@link #MANAGED_OPTIONAL}, {@link #MANAGED_PROPERTIES} and {@link #MANAGED_EXCLUSIONS} if the
* corresponding attribute was set via dependency management.
*/
int getManagedBits();
/**
* Gets the remote repositories from which this node's artifact shall be resolved.
*
* @return The (read-only) list of remote repositories to use for artifact resolution, never {@code null}.
*/
List getRepositories();
/**
* Gets the request context in which this dependency node was created.
*
* @return The request context, never {@code null}.
*/
String getRequestContext();
/**
* Sets the request context in which this dependency node was created.
*
* @param context The context, may be {@code null}.
*/
void setRequestContext( String context );
/**
* Gets the custom data associated with this dependency node. Clients of the repository system can use this data to
* annotate dependency nodes with domain-specific information. Note that the returned map is read-only and
* {@link #setData(Object, Object)} needs to be used to update the custom data.
*
* @return The (read-only) key-value mappings, never {@code null}.
*/
Map, ?> getData();
/**
* Sets the custom data associated with this dependency node.
*
* @param data The new custom data, may be {@code null}.
*/
void setData( Map data );
/**
* Associates the specified dependency node data with the given key. Note: This method must not be called
* while {@link #getData()} is being iterated.
*
* @param key The key under which to store the data, must not be {@code null}.
* @param value The data to associate with the key, may be {@code null} to remove the mapping.
*/
void setData( Object key, Object value );
/**
* Traverses this node and potentially its children using the specified visitor.
*
* @param visitor The visitor to call back, must not be {@code null}.
* @return {@code true} to visit siblings nodes of this node as well, {@code false} to skip siblings.
*/
boolean accept( DependencyVisitor visitor );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/DependencyVisitor.java 0000664 0000000 0000000 00000002755 12455463561 0031630 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
/**
* A visitor for nodes of the dependency graph.
*
* @see DependencyNode#accept(DependencyVisitor)
*/
public interface DependencyVisitor
{
/**
* Notifies the visitor of a node visit before its children have been processed.
*
* @param node The dependency node being visited, must not be {@code null}.
* @return {@code true} to visit child nodes of the specified node as well, {@code false} to skip children.
*/
boolean visitEnter( DependencyNode node );
/**
* Notifies the visitor of a node visit after its children have been processed. Note that this method is always
* invoked regardless whether any children have actually been visited.
*
* @param node The dependency node being visited, must not be {@code null}.
* @return {@code true} to visit siblings nodes of the specified node as well, {@code false} to skip siblings.
*/
boolean visitLeave( DependencyNode node );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/Exclusion.java 0000664 0000000 0000000 00000006747 12455463561 0030150 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.graph;
/**
* An exclusion of one or more transitive dependencies. Note: Instances of this class are immutable and the
* exposed mutators return new objects rather than changing the current instance.
*
* @see Dependency#getExclusions()
*/
public final class Exclusion
{
private final String groupId;
private final String artifactId;
private final String classifier;
private final String extension;
/**
* Creates an exclusion for artifacts with the specified coordinates.
*
* @param groupId The group identifier, may be {@code null}.
* @param artifactId The artifact identifier, may be {@code null}.
* @param classifier The classifier, may be {@code null}.
* @param extension The file extension, may be {@code null}.
*/
public Exclusion( String groupId, String artifactId, String classifier, String extension )
{
this.groupId = ( groupId != null ) ? groupId : "";
this.artifactId = ( artifactId != null ) ? artifactId : "";
this.classifier = ( classifier != null ) ? classifier : "";
this.extension = ( extension != null ) ? extension : "";
}
/**
* Gets the group identifier for artifacts to exclude.
*
* @return The group identifier, never {@code null}.
*/
public String getGroupId()
{
return groupId;
}
/**
* Gets the artifact identifier for artifacts to exclude.
*
* @return The artifact identifier, never {@code null}.
*/
public String getArtifactId()
{
return artifactId;
}
/**
* Gets the classifier for artifacts to exclude.
*
* @return The classifier, never {@code null}.
*/
public String getClassifier()
{
return classifier;
}
/**
* Gets the file extension for artifacts to exclude.
*
* @return The file extension of artifacts to exclude, never {@code null}.
*/
public String getExtension()
{
return extension;
}
@Override
public String toString()
{
return getGroupId() + ':' + getArtifactId() + ':' + getExtension()
+ ( getClassifier().length() > 0 ? ':' + getClassifier() : "" );
}
@Override
public boolean equals( Object obj )
{
if ( obj == this )
{
return true;
}
else if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
Exclusion that = (Exclusion) obj;
return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
&& extension.equals( that.extension ) && classifier.equals( that.classifier );
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + artifactId.hashCode();
hash = hash * 31 + groupId.hashCode();
hash = hash * 31 + classifier.hashCode();
hash = hash * 31 + extension.hashCode();
return hash;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/graph/package-info.java 0000664 0000000 0000000 00000001207 12455463561 0030505 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The representation of a dependency graph by means of connected dependency nodes.
*/
package org.eclipse.aether.graph;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/installation/ 0000775 0000000 0000000 00000000000 12455463561 0026716 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/installation/InstallRequest.java 0000664 0000000 0000000 00000010753 12455463561 0032546 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.installation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
/**
* A request to install artifacts and their accompanying metadata into the local repository.
*
* @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
*/
public final class InstallRequest
{
private Collection artifacts = Collections.emptyList();
private Collection metadata = Collections.emptyList();
private RequestTrace trace;
/**
* Creates an uninitialized request.
*/
public InstallRequest()
{
}
/**
* Gets the artifact to install.
*
* @return The artifacts to install, never {@code null}.
*/
public Collection getArtifacts()
{
return artifacts;
}
/**
* Sets the artifacts to install.
*
* @param artifacts The artifacts to install, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public InstallRequest setArtifacts( Collection artifacts )
{
if ( artifacts == null )
{
this.artifacts = Collections.emptyList();
}
else
{
this.artifacts = artifacts;
}
return this;
}
/**
* Adds the specified artifacts for installation.
*
* @param artifact The artifact to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public InstallRequest addArtifact( Artifact artifact )
{
if ( artifact != null )
{
if ( artifacts.isEmpty() )
{
artifacts = new ArrayList();
}
artifacts.add( artifact );
}
return this;
}
/**
* Gets the metadata to install.
*
* @return The metadata to install, never {@code null}.
*/
public Collection getMetadata()
{
return metadata;
}
/**
* Sets the metadata to install.
*
* @param metadata The metadata to install.
* @return This request for chaining, never {@code null}.
*/
public InstallRequest setMetadata( Collection metadata )
{
if ( metadata == null )
{
this.metadata = Collections.emptyList();
}
else
{
this.metadata = metadata;
}
return this;
}
/**
* Adds the specified metadata for installation.
*
* @param metadata The metadata to add, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public InstallRequest addMetadata( Metadata metadata )
{
if ( metadata != null )
{
if ( this.metadata.isEmpty() )
{
this.metadata = new ArrayList();
}
this.metadata.add( metadata );
}
return this;
}
/**
* Gets the trace information that describes the higher level request/operation in which this request is issued.
*
* @return The trace information about the higher level operation or {@code null} if none.
*/
public RequestTrace getTrace()
{
return trace;
}
/**
* Sets the trace information that describes the higher level request/operation in which this request is issued.
*
* @param trace The trace information about the higher level operation, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public InstallRequest setTrace( RequestTrace trace )
{
this.trace = trace;
return this;
}
@Override
public String toString()
{
return getArtifacts() + ", " + getMetadata();
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/installation/InstallResult.java 0000664 0000000 0000000 00000010747 12455463561 0032377 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.installation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
/**
* The result of installing artifacts and their accompanying metadata into the a remote repository.
*
* @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
*/
public final class InstallResult
{
private final InstallRequest request;
private Collection artifacts;
private Collection metadata;
/**
* Creates a new result for the specified request.
*
* @param request The installation request, must not be {@code null}.
*/
public InstallResult( InstallRequest request )
{
if ( request == null )
{
throw new IllegalArgumentException( "install request has not been specified" );
}
this.request = request;
artifacts = Collections.emptyList();
metadata = Collections.emptyList();
}
/**
* Gets the install request that was made.
*
* @return The install request, never {@code null}.
*/
public InstallRequest getRequest()
{
return request;
}
/**
* Gets the artifacts that got installed.
*
* @return The installed artifacts, never {@code null}.
*/
public Collection getArtifacts()
{
return artifacts;
}
/**
* Sets the artifacts that got installed.
*
* @param artifacts The installed artifacts, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public InstallResult setArtifacts( Collection artifacts )
{
if ( artifacts == null )
{
this.artifacts = Collections.emptyList();
}
else
{
this.artifacts = artifacts;
}
return this;
}
/**
* Adds the specified artifacts to the result.
*
* @param artifact The installed artifact to add, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public InstallResult addArtifact( Artifact artifact )
{
if ( artifact != null )
{
if ( artifacts.isEmpty() )
{
artifacts = new ArrayList();
}
artifacts.add( artifact );
}
return this;
}
/**
* Gets the metadata that got installed. Note that due to automatically generated metadata, there might have been
* more metadata installed than originally specified in the install request.
*
* @return The installed metadata, never {@code null}.
*/
public Collection getMetadata()
{
return metadata;
}
/**
* Sets the metadata that got installed.
*
* @param metadata The installed metadata, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public InstallResult setMetadata( Collection metadata )
{
if ( metadata == null )
{
this.metadata = Collections.emptyList();
}
else
{
this.metadata = metadata;
}
return this;
}
/**
* Adds the specified metadata to this result.
*
* @param metadata The installed metadata to add, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public InstallResult addMetadata( Metadata metadata )
{
if ( metadata != null )
{
if ( this.metadata.isEmpty() )
{
this.metadata = new ArrayList();
}
this.metadata.add( metadata );
}
return this;
}
@Override
public String toString()
{
return getArtifacts() + ", " + getMetadata();
}
}
InstallationException.java 0000664 0000000 0000000 00000002512 12455463561 0034022 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/installation /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.installation;
import org.eclipse.aether.RepositoryException;
/**
* Thrown in case of an installation error like an IO error.
*/
public class InstallationException
extends RepositoryException
{
/**
* Creates a new exception with the specified detail message.
*
* @param message The detail message, may be {@code null}.
*/
public InstallationException( String message )
{
super( message );
}
/**
* Creates a new exception with the specified detail message and cause.
*
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public InstallationException( String message, Throwable cause )
{
super( message, cause );
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/installation/package-info.java 0000664 0000000 0000000 00000001205 12455463561 0032103 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The types supporting the publishing of artifacts to a local repository.
*/
package org.eclipse.aether.installation;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/ 0000775 0000000 0000000 00000000000 12455463561 0025775 5 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java 0000664 0000000 0000000 00000011224 12455463561 0032044 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.metadata;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* A skeleton class for metadata.
*/
public abstract class AbstractMetadata
implements Metadata
{
private Metadata newInstance( Map properties, File file )
{
return new DefaultMetadata( getGroupId(), getArtifactId(), getVersion(), getType(), getNature(), file,
properties );
}
public Metadata setFile( File file )
{
File current = getFile();
if ( ( current == null ) ? file == null : current.equals( file ) )
{
return this;
}
return newInstance( getProperties(), file );
}
public Metadata setProperties( Map properties )
{
Map current = getProperties();
if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
{
return this;
}
return newInstance( copyProperties( properties ), getFile() );
}
public String getProperty( String key, String defaultValue )
{
String value = getProperties().get( key );
return ( value != null ) ? value : defaultValue;
}
/**
* Copies the specified metadata properties. This utility method should be used when creating new metadata instances
* with caller-supplied properties.
*
* @param properties The properties to copy, may be {@code null}.
* @return The copied and read-only properties, never {@code null}.
*/
protected static Map copyProperties( Map properties )
{
if ( properties != null && !properties.isEmpty() )
{
return Collections.unmodifiableMap( new HashMap( properties ) );
}
else
{
return Collections.emptyMap();
}
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder( 128 );
if ( getGroupId().length() > 0 )
{
buffer.append( getGroupId() );
}
if ( getArtifactId().length() > 0 )
{
buffer.append( ':' ).append( getArtifactId() );
}
if ( getVersion().length() > 0 )
{
buffer.append( ':' ).append( getVersion() );
}
buffer.append( '/' ).append( getType() );
return buffer.toString();
}
/**
* Compares this metadata with the specified object.
*
* @param obj The object to compare this metadata against, may be {@code null}.
* @return {@code true} if and only if the specified object is another {@link Metadata} with equal coordinates,
* type, nature, properties and file, {@code false} otherwise.
*/
@Override
public boolean equals( Object obj )
{
if ( obj == this )
{
return true;
}
else if ( !( obj instanceof Metadata ) )
{
return false;
}
Metadata that = (Metadata) obj;
return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
&& getVersion().equals( that.getVersion() ) && getType().equals( that.getType() )
&& getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() )
&& eq( getProperties(), that.getProperties() );
}
private static boolean eq( T s1, T s2 )
{
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
/**
* Returns a hash code for this metadata.
*
* @return A hash code for the metadata.
*/
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + getGroupId().hashCode();
hash = hash * 31 + getArtifactId().hashCode();
hash = hash * 31 + getType().hashCode();
hash = hash * 31 + getNature().hashCode();
hash = hash * 31 + getVersion().hashCode();
hash = hash * 31 + hash( getFile() );
return hash;
}
private static int hash( Object obj )
{
return ( obj != null ) ? obj.hashCode() : 0;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java 0000664 0000000 0000000 00000015313 12455463561 0031670 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.metadata;
import java.io.File;
import java.util.Map;
/**
* A basic metadata instance. Note: Instances of this class are immutable and the exposed mutators return new
* objects rather than changing the current instance.
*/
public final class DefaultMetadata
extends AbstractMetadata
{
private final String groupId;
private final String artifactId;
private final String version;
private final String type;
private final Nature nature;
private final File file;
private final Map properties;
/**
* Creates a new metadata for the repository root with the specific type and nature.
*
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
*/
public DefaultMetadata( String type, Nature nature )
{
this( "", "", "", type, nature, null, (File) null );
}
/**
* Creates a new metadata for the groupId level with the specific type and nature.
*
* @param groupId The group identifier to which this metadata applies, may be {@code null}.
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
*/
public DefaultMetadata( String groupId, String type, Nature nature )
{
this( groupId, "", "", type, nature, null, (File) null );
}
/**
* Creates a new metadata for the groupId:artifactId level with the specific type and nature.
*
* @param groupId The group identifier to which this metadata applies, may be {@code null}.
* @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
*/
public DefaultMetadata( String groupId, String artifactId, String type, Nature nature )
{
this( groupId, artifactId, "", type, nature, null, (File) null );
}
/**
* Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
*
* @param groupId The group identifier to which this metadata applies, may be {@code null}.
* @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
* @param version The version to which this metadata applies, may be {@code null}.
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
*/
public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature )
{
this( groupId, artifactId, version, type, nature, null, (File) null );
}
/**
* Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
*
* @param groupId The group identifier to which this metadata applies, may be {@code null}.
* @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
* @param version The version to which this metadata applies, may be {@code null}.
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
* @param file The resolved file of the metadata, may be {@code null}.
*/
public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file )
{
this( groupId, artifactId, version, type, nature, null, file );
}
/**
* Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
*
* @param groupId The group identifier to which this metadata applies, may be {@code null}.
* @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
* @param version The version to which this metadata applies, may be {@code null}.
* @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
* @param nature The nature of the metadata, must not be {@code null}.
* @param properties The properties of the metadata, may be {@code null} if none.
* @param file The resolved file of the metadata, may be {@code null}.
*/
public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature,
Map properties, File file )
{
this.groupId = emptify( groupId );
this.artifactId = emptify( artifactId );
this.version = emptify( version );
this.type = emptify( type );
if ( nature == null )
{
throw new IllegalArgumentException( "metadata nature was not specified" );
}
this.nature = nature;
this.file = file;
this.properties = copyProperties( properties );
}
DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file,
Map properties )
{
// NOTE: This constructor assumes immutability of the provided properties, for internal use only
this.groupId = emptify( groupId );
this.artifactId = emptify( artifactId );
this.version = emptify( version );
this.type = emptify( type );
this.nature = nature;
this.file = file;
this.properties = properties;
}
private static String emptify( String str )
{
return ( str == null ) ? "" : str;
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public String getType()
{
return type;
}
public Nature getNature()
{
return nature;
}
public File getFile()
{
return file;
}
public Map getProperties()
{
return properties;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/MergeableMetadata.java 0000664 0000000 0000000 00000003032 12455463561 0032162 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.metadata;
import java.io.File;
import org.eclipse.aether.RepositoryException;
/**
* A piece of metadata that needs to be merged with any current metadata before installation/deployment.
*/
public interface MergeableMetadata
extends Metadata
{
/**
* Merges this metadata into the current metadata (if any). Note that this method will be invoked regardless whether
* metadata currently exists or not.
*
* @param current The path to the current metadata file, may not exist but must not be {@code null}.
* @param result The path to the result file where the merged metadata should be stored, must not be {@code null}.
* @throws RepositoryException If the metadata could not be merged.
*/
void merge( File current, File result )
throws RepositoryException;
/**
* Indicates whether this metadata has been merged.
*
* @return {@code true} if the metadata has been merged, {@code false} otherwise.
*/
boolean isMerged();
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/Metadata.java 0000664 0000000 0000000 00000010215 12455463561 0030357 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.metadata;
import java.io.File;
import java.util.Map;
/**
* A piece of repository metadata, e.g. an index of available versions. In contrast to an artifact, which usually exists
* in only one repository, metadata usually exists in multiple repositories and each repository contains a different
* copy of the metadata. Note: Metadata instances are supposed to be immutable, e.g. any exposed mutator method
* returns a new metadata instance and leaves the original instance unchanged. Implementors are strongly advised to obey
* this contract. Note: Implementors are strongly advised to inherit from {@link AbstractMetadata} instead of
* directly implementing this interface.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface Metadata
{
/**
* The nature of the metadata.
*/
enum Nature
{
/**
* The metadata refers to release artifacts only.
*/
RELEASE,
/**
* The metadata refers to snapshot artifacts only.
*/
SNAPSHOT,
/**
* The metadata refers to either release or snapshot artifacts.
*/
RELEASE_OR_SNAPSHOT
}
/**
* Gets the group identifier of this metadata.
*
* @return The group identifier or an empty string if the metadata applies to the entire repository, never
* {@code null}.
*/
String getGroupId();
/**
* Gets the artifact identifier of this metadata.
*
* @return The artifact identifier or an empty string if the metadata applies to the groupId level only, never
* {@code null}.
*/
String getArtifactId();
/**
* Gets the version of this metadata.
*
* @return The version or an empty string if the metadata applies to the groupId:artifactId level only, never
* {@code null}.
*/
String getVersion();
/**
* Gets the type of the metadata, e.g. "maven-metadata.xml".
*
* @return The type of the metadata, never {@code null}.
*/
String getType();
/**
* Gets the nature of this metadata. The nature indicates to what artifact versions the metadata refers.
*
* @return The nature, never {@code null}.
*/
Nature getNature();
/**
* Gets the file of this metadata. Note that only resolved metadata has a file associated with it.
*
* @return The file or {@code null} if none.
*/
File getFile();
/**
* Sets the file of the metadata.
*
* @param file The file of the metadata, may be {@code null}
* @return The new metadata, never {@code null}.
*/
Metadata setFile( File file );
/**
* Gets the specified property.
*
* @param key The name of the property, must not be {@code null}.
* @param defaultValue The default value to return in case the property is not set, may be {@code null}.
* @return The requested property value or {@code null} if the property is not set and no default value was
* provided.
*/
String getProperty( String key, String defaultValue );
/**
* Gets the properties of this metadata.
*
* @return The (read-only) properties, never {@code null}.
*/
Map getProperties();
/**
* Sets the properties for the metadata.
*
* @param properties The properties for the metadata, may be {@code null}.
* @return The new metadata, never {@code null}.
*/
Metadata setProperties( Map properties );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/metadata/package-info.java 0000664 0000000 0000000 00000001247 12455463561 0031170 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The definition of metadata, that is an auxiliary entity managed by the repository system to locate artifacts.
*/
package org.eclipse.aether.metadata;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/package-info.java 0000664 0000000 0000000 00000001212 12455463561 0027400 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The primary API of the {@link org.eclipse.aether.RepositorySystem} and its functionality.
*/
package org.eclipse.aether;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/ 0000775 0000000 0000000 00000000000 12455463561 0026434 5 ustar 00root root 0000000 0000000 ArtifactRepository.java 0000664 0000000 0000000 00000002207 12455463561 0033056 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* A repository hosting artifacts.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface ArtifactRepository
{
/**
* Gets the type of the repository, for example "default".
*
* @return The (case-sensitive) type of the repository, never {@code null}.
*/
String getContentType();
/**
* Gets the identifier of this repository.
*
* @return The (case-sensitive) identifier, never {@code null}.
*/
String getId();
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/Authentication.java 0000664 0000000 0000000 00000004306 12455463561 0032261 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.Map;
/**
* The authentication to use for accessing a protected resource. This acts basically as an extensible callback mechanism
* from which network operations can request authentication data like username and password when needed.
*/
public interface Authentication
{
/**
* Fills the given authentication context with the data from this authentication callback. To do so, implementors
* have to call {@link AuthenticationContext#put(String, Object)}.
*
* The {@code key} parameter supplied to this method acts merely as a hint for interactive callbacks that want to
* prompt the user for only that authentication data which is required. Implementations are free to ignore this
* parameter and put all the data they have into the authentication context at once.
*
* @param context The authentication context to populate, must not be {@code null}.
* @param key The key denoting a specific piece of authentication data that is being requested for a network
* operation, may be {@code null}.
* @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
* authentication data, may be {@code null}.
*/
void fill( AuthenticationContext context, String key, Map data );
/**
* Updates the given digest with data from this authentication callback. To do so, implementors have to call the
* {@code update()} methods in {@link AuthenticationDigest}.
*
* @param digest The digest to update, must not be {@code null}.
*/
void digest( AuthenticationDigest digest );
}
AuthenticationContext.java 0000664 0000000 0000000 00000033757 12455463561 0033563 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2012, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.Closeable;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.aether.RepositorySystemSession;
/**
* A glorified map of key value pairs holding (cleartext) authentication data. Authentication contexts are used
* internally when network operations need to access secured repositories or proxies. Each authentication context
* manages the credentials required to access a single host. Unlike {@link Authentication} callbacks which exist for a
* potentially long time like the duration of a repository system session, an authentication context has a supposedly
* short lifetime and should be {@link #close() closed} as soon as the corresponding network operation has finished:
*
*
* AuthenticationContext context = AuthenticationContext.forRepository( session, repository );
* try {
* // get credentials
* char[] password = context.get( AuthenticationContext.PASSWORD, char[].class );
* // perform network operation using retrieved credentials
* ...
* } finally {
* // erase confidential authentication data from heap memory
* AuthenticationContext.close( context );
* }
*
*
* The same authentication data can often be presented using different data types, e.g. a password can be presented
* using a character array or (less securely) using a string. For ease of use, an authentication context treats the
* following groups of data types as equivalent and converts values automatically during retrieval:
*
* {@code String}, {@code char[]}
* {@code String}, {@code File}
*
* An authentication context is thread-safe.
*/
public final class AuthenticationContext
implements Closeable
{
/**
* The key used to store the username. The corresponding authentication data should be of type {@link String}.
*/
public static final String USERNAME = "username";
/**
* The key used to store the password. The corresponding authentication data should be of type {@code char[]} or
* {@link String}.
*/
public static final String PASSWORD = "password";
/**
* The key used to store the NTLM domain. The corresponding authentication data should be of type {@link String}.
*/
public static final String NTLM_DOMAIN = "ntlm.domain";
/**
* The key used to store the NTML workstation. The corresponding authentication data should be of type
* {@link String}.
*/
public static final String NTLM_WORKSTATION = "ntlm.workstation";
/**
* The key used to store the pathname to a private key file. The corresponding authentication data should be of type
* {@link String} or {@link File}.
*/
public static final String PRIVATE_KEY_PATH = "privateKey.path";
/**
* The key used to store the passphrase protecting the private key. The corresponding authentication data should be
* of type {@code char[]} or {@link String}.
*/
public static final String PRIVATE_KEY_PASSPHRASE = "privateKey.passphrase";
/**
* The key used to store the acceptance policy for unknown host keys. The corresponding authentication data should
* be of type {@link Boolean}. When querying this authentication data, the extra data should provide
* {@link #HOST_KEY_REMOTE} and {@link #HOST_KEY_LOCAL}, e.g. to enable a well-founded decision of the user during
* an interactive prompt.
*/
public static final String HOST_KEY_ACCEPTANCE = "hostKey.acceptance";
/**
* The key used to store the fingerprint of the public key advertised by remote host. Note that this key is used to
* query the extra data passed to {@link #get(String, Map, Class)} when getting {@link #HOST_KEY_ACCEPTANCE}, not
* the authentication data in a context.
*/
public static final String HOST_KEY_REMOTE = "hostKey.remote";
/**
* The key used to store the fingerprint of the public key expected from remote host as recorded in a known hosts
* database. Note that this key is used to query the extra data passed to {@link #get(String, Map, Class)} when
* getting {@link #HOST_KEY_ACCEPTANCE}, not the authentication data in a context.
*/
public static final String HOST_KEY_LOCAL = "hostKey.local";
/**
* The key used to store the SSL context. The corresponding authentication data should be of type
* {@link javax.net.ssl.SSLContext}.
*/
public static final String SSL_CONTEXT = "ssl.context";
/**
* The key used to store the SSL hostname verifier. The corresponding authentication data should be of type
* {@link javax.net.ssl.HostnameVerifier}.
*/
public static final String SSL_HOSTNAME_VERIFIER = "ssl.hostnameVerifier";
private final RepositorySystemSession session;
private final RemoteRepository repository;
private final Proxy proxy;
private final Authentication auth;
private final Map authData;
private boolean fillingAuthData;
/**
* Gets an authentication context for the specified repository.
*
* @param session The repository system session during which the repository is accessed, must not be {@code null}.
* @param repository The repository for which to create an authentication context, must not be {@code null}.
* @return An authentication context for the repository or {@code null} if no authentication is configured for it.
*/
public static AuthenticationContext forRepository( RepositorySystemSession session, RemoteRepository repository )
{
return newInstance( session, repository, null, repository.getAuthentication() );
}
/**
* Gets an authentication context for the proxy of the specified repository.
*
* @param session The repository system session during which the repository is accessed, must not be {@code null}.
* @param repository The repository for whose proxy to create an authentication context, must not be {@code null}.
* @return An authentication context for the proxy or {@code null} if no proxy is set or no authentication is
* configured for it.
*/
public static AuthenticationContext forProxy( RepositorySystemSession session, RemoteRepository repository )
{
Proxy proxy = repository.getProxy();
return newInstance( session, repository, proxy, ( proxy != null ) ? proxy.getAuthentication() : null );
}
private static AuthenticationContext newInstance( RepositorySystemSession session, RemoteRepository repository,
Proxy proxy, Authentication auth )
{
if ( auth == null )
{
return null;
}
return new AuthenticationContext( session, repository, proxy, auth );
}
private AuthenticationContext( RepositorySystemSession session, RemoteRepository repository, Proxy proxy,
Authentication auth )
{
if ( session == null )
{
throw new IllegalArgumentException( "repository system session missing" );
}
this.session = session;
this.repository = repository;
this.proxy = proxy;
this.auth = auth;
authData = new HashMap();
}
/**
* Gets the repository system session during which the authentication happens.
*
* @return The repository system session, never {@code null}.
*/
public RepositorySystemSession getSession()
{
return session;
}
/**
* Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
* this authentication context does not apply to the repository's host but rather the proxy.
*
* @return The repository to be contacted, never {@code null}.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Gets the proxy (if any) to be authenticated with.
*
* @return The proxy or {@code null} if authenticating directly with the repository's host.
*/
public Proxy getProxy()
{
return proxy;
}
/**
* Gets the authentication data for the specified key.
*
* @param key The key whose authentication data should be retrieved, must not be {@code null}.
* @return The requested authentication data or {@code null} if none.
*/
public String get( String key )
{
return get( key, null, String.class );
}
/**
* Gets the authentication data for the specified key.
*
* @param The data type of the authentication data.
* @param key The key whose authentication data should be retrieved, must not be {@code null}.
* @param type The expected type of the authentication data, must not be {@code null}.
* @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
*/
public T get( String key, Class type )
{
return get( key, null, type );
}
/**
* Gets the authentication data for the specified key.
*
* @param The data type of the authentication data.
* @param key The key whose authentication data should be retrieved, must not be {@code null}.
* @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
* authentication data, may be {@code null}.
* @param type The expected type of the authentication data, must not be {@code null}.
* @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
*/
public T get( String key, Map data, Class type )
{
if ( key == null )
{
throw new IllegalArgumentException( "authentication data key missing" );
}
Object value;
synchronized ( authData )
{
value = authData.get( key );
if ( value == null && !authData.containsKey( key ) && !fillingAuthData )
{
if ( auth != null )
{
try
{
fillingAuthData = true;
auth.fill( this, key, data );
}
finally
{
fillingAuthData = false;
}
value = authData.get( key );
}
if ( value == null )
{
authData.put( key, value );
}
}
}
return convert( value, type );
}
private T convert( Object value, Class type )
{
if ( !type.isInstance( value ) )
{
if ( String.class.equals( type ) )
{
if ( value instanceof File )
{
value = ( (File) value ).getPath();
}
else if ( value instanceof char[] )
{
value = new String( (char[]) value );
}
}
else if ( File.class.equals( type ) )
{
if ( value instanceof String )
{
value = new File( (String) value );
}
}
else if ( char[].class.equals( type ) )
{
if ( value instanceof String )
{
value = ( (String) value ).toCharArray();
}
}
}
if ( type.isInstance( value ) )
{
return type.cast( value );
}
return null;
}
/**
* Puts the specified authentication data into this context. This method should only be called from implementors of
* {@link Authentication#fill(AuthenticationContext, String, Map)}. Passed in character arrays are not cloned and
* become owned by this context, i.e. get erased when the context gets closed.
*
* @param key The key to associate the authentication data with, must not be {@code null}.
* @param value The (cleartext) authentication data to store, may be {@code null}.
*/
public void put( String key, Object value )
{
if ( key == null )
{
throw new IllegalArgumentException( "authentication data key missing" );
}
synchronized ( authData )
{
Object oldValue = authData.put( key, value );
if ( oldValue instanceof char[] )
{
Arrays.fill( (char[]) oldValue, '\0' );
}
}
}
/**
* Closes this authentication context and erases sensitive authentication data from heap memory. Closing an already
* closed context has no effect.
*/
public void close()
{
synchronized ( authData )
{
for ( Object value : authData.values() )
{
if ( value instanceof char[] )
{
Arrays.fill( (char[]) value, '\0' );
}
}
authData.clear();
}
}
/**
* Closes the specified authentication context. This is a convenience method doing a {@code null} check before
* calling {@link #close()} on the given context.
*
* @param context The authentication context to close, may be {@code null}.
*/
public static void close( AuthenticationContext context )
{
if ( context != null )
{
context.close();
}
}
}
AuthenticationDigest.java 0000664 0000000 0000000 00000015150 12455463561 0033341 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.eclipse.aether.RepositorySystemSession;
/**
* A helper to calculate a fingerprint/digest for the authentication data of a repository/proxy. Such a fingerprint can
* be used to detect changes in the authentication data across JVM restarts without exposing sensitive information.
*/
public final class AuthenticationDigest
{
private final MessageDigest digest;
private final RepositorySystemSession session;
private final RemoteRepository repository;
private final Proxy proxy;
/**
* Gets the fingerprint for the authentication of the specified repository.
*
* @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
* @param repository The repository whose authentication is to be fingerprinted, must not be {@code null}.
* @return The fingerprint of the repository authentication or an empty string if no authentication is configured,
* never {@code null}.
*/
public static String forRepository( RepositorySystemSession session, RemoteRepository repository )
{
String digest = "";
Authentication auth = repository.getAuthentication();
if ( auth != null )
{
AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, null );
auth.digest( authDigest );
digest = authDigest.digest();
}
return digest;
}
/**
* Gets the fingerprint for the authentication of the specified repository's proxy.
*
* @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
* @param repository The repository whose proxy authentication is to be fingerprinted, must not be {@code null}.
* @return The fingerprint of the proxy authentication or an empty string if no proxy is present or if no proxy
* authentication is configured, never {@code null}.
*/
public static String forProxy( RepositorySystemSession session, RemoteRepository repository )
{
String digest = "";
Proxy proxy = repository.getProxy();
if ( proxy != null )
{
Authentication auth = proxy.getAuthentication();
if ( auth != null )
{
AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, proxy );
auth.digest( authDigest );
digest = authDigest.digest();
}
}
return digest;
}
private AuthenticationDigest( RepositorySystemSession session, RemoteRepository repository, Proxy proxy )
{
this.session = session;
this.repository = repository;
this.proxy = proxy;
digest = newDigest();
}
private static MessageDigest newDigest()
{
try
{
return MessageDigest.getInstance( "SHA-1" );
}
catch ( NoSuchAlgorithmException e )
{
try
{
return MessageDigest.getInstance( "MD5" );
}
catch ( NoSuchAlgorithmException ne )
{
throw new IllegalStateException( ne );
}
}
}
/**
* Gets the repository system session during which the authentication fingerprint is calculated.
*
* @return The repository system session, never {@code null}.
*/
public RepositorySystemSession getSession()
{
return session;
}
/**
* Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
* this authentication digest does not apply to the repository's host but rather the proxy.
*
* @return The repository to be contacted, never {@code null}.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Gets the proxy (if any) to be authenticated with.
*
* @return The proxy or {@code null} if authenticating directly with the repository's host.
*/
public Proxy getProxy()
{
return proxy;
}
/**
* Updates the digest with the specified strings.
*
* @param strings The strings to update the digest with, may be {@code null} or contain {@code null} elements.
*/
public void update( String... strings )
{
if ( strings != null )
{
for ( String string : strings )
{
if ( string != null )
{
try
{
digest.update( string.getBytes( "UTF-8" ) );
}
catch ( UnsupportedEncodingException e )
{
throw new IllegalStateException( e );
}
}
}
}
}
/**
* Updates the digest with the specified characters.
*
* @param chars The characters to update the digest with, may be {@code null}.
*/
public void update( char... chars )
{
if ( chars != null )
{
for ( char c : chars )
{
digest.update( (byte) ( c >> 8 ) );
digest.update( (byte) ( c & 0xFF ) );
}
}
}
/**
* Updates the digest with the specified bytes.
*
* @param bytes The bytes to update the digest with, may be {@code null}.
*/
public void update( byte... bytes )
{
if ( bytes != null )
{
digest.update( bytes );
}
}
private String digest()
{
byte[] bytes = digest.digest();
StringBuilder buffer = new StringBuilder( bytes.length * 2 );
for ( byte aByte : bytes )
{
int b = aByte & 0xFF;
if ( b < 0x10 )
{
buffer.append( '0' );
}
buffer.append( Integer.toHexString( b ) );
}
return buffer.toString();
}
}
AuthenticationSelector.java 0000664 0000000 0000000 00000002102 12455463561 0033673 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* Selects authentication for a given remote repository.
*
* @see org.eclipse.aether.RepositorySystemSession#getAuthenticationSelector()
*/
public interface AuthenticationSelector
{
/**
* Selects authentication for the specified remote repository.
*
* @param repository The repository for which to select authentication, must not be {@code null}.
* @return The selected authentication or {@code null} if none.
*/
Authentication getAuthentication( RemoteRepository repository );
}
LocalArtifactRegistration.java 0000664 0000000 0000000 00000010253 12455463561 0034324 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
/**
* A request to register an artifact within the local repository. Certain local repository implementations can refuse to
* serve physically present artifacts if those haven't been previously registered to them.
*
* @see LocalRepositoryManager#add(RepositorySystemSession, LocalArtifactRegistration)
*/
public final class LocalArtifactRegistration
{
private Artifact artifact;
private RemoteRepository repository;
private Collection contexts = Collections.emptyList();
/**
* Creates an uninitialized registration.
*/
public LocalArtifactRegistration()
{
// enables default constructor
}
/**
* Creates a registration request for the specified (locally installed) artifact.
*
* @param artifact The artifact to register, may be {@code null}.
*/
public LocalArtifactRegistration( Artifact artifact )
{
setArtifact( artifact );
}
/**
* Creates a registration request for the specified artifact.
*
* @param artifact The artifact to register, may be {@code null}.
* @param repository The remote repository from which the artifact was resolved or {@code null} if the artifact was
* locally installed.
* @param contexts The resolution contexts, may be {@code null}.
*/
public LocalArtifactRegistration( Artifact artifact, RemoteRepository repository, Collection contexts )
{
setArtifact( artifact );
setRepository( repository );
setContexts( contexts );
}
/**
* Gets the artifact to register.
*
* @return The artifact or {@code null} if not set.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Sets the artifact to register.
*
* @param artifact The artifact, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public LocalArtifactRegistration setArtifact( Artifact artifact )
{
this.artifact = artifact;
return this;
}
/**
* Gets the remote repository from which the artifact was resolved.
*
* @return The remote repository or {@code null} if the artifact was locally installed.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Sets the remote repository from which the artifact was resolved.
*
* @param repository The remote repository or {@code null} if the artifact was locally installed.
* @return This request for chaining, never {@code null}.
*/
public LocalArtifactRegistration setRepository( RemoteRepository repository )
{
this.repository = repository;
return this;
}
/**
* Gets the resolution contexts in which the artifact is available.
*
* @return The resolution contexts in which the artifact is available, never {@code null}.
*/
public Collection getContexts()
{
return contexts;
}
/**
* Sets the resolution contexts in which the artifact is available.
*
* @param contexts The resolution contexts, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public LocalArtifactRegistration setContexts( Collection contexts )
{
if ( contexts != null )
{
this.contexts = contexts;
}
else
{
this.contexts = Collections.emptyList();
}
return this;
}
}
LocalArtifactRequest.java 0000664 0000000 0000000 00000007466 12455463561 0033316 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.Collections;
import java.util.List;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
/**
* A query to the local repository for the existence of an artifact.
*
* @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
*/
public final class LocalArtifactRequest
{
private Artifact artifact;
private String context = "";
private List repositories = Collections.emptyList();
/**
* Creates an uninitialized query.
*/
public LocalArtifactRequest()
{
// enables default constructor
}
/**
* Creates a query with the specified properties.
*
* @param artifact The artifact to query for, may be {@code null}.
* @param repositories The remote repositories that should be considered as potential sources for the artifact, may
* be {@code null} or empty to only consider locally installed artifacts.
* @param context The resolution context for the artifact, may be {@code null}.
*/
public LocalArtifactRequest( Artifact artifact, List repositories, String context )
{
setArtifact( artifact );
setRepositories( repositories );
setContext( context );
}
/**
* Gets the artifact to query for.
*
* @return The artifact or {@code null} if not set.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Sets the artifact to query for.
*
* @param artifact The artifact, may be {@code null}.
* @return This query for chaining, never {@code null}.
*/
public LocalArtifactRequest setArtifact( Artifact artifact )
{
this.artifact = artifact;
return this;
}
/**
* Gets the resolution context.
*
* @return The resolution context, never {@code null}.
*/
public String getContext()
{
return context;
}
/**
* Sets the resolution context.
*
* @param context The resolution context, may be {@code null}.
* @return This query for chaining, never {@code null}.
*/
public LocalArtifactRequest setContext( String context )
{
this.context = ( context != null ) ? context : "";
return this;
}
/**
* Gets the remote repositories to consider as sources of the artifact.
*
* @return The remote repositories, never {@code null}.
*/
public List getRepositories()
{
return repositories;
}
/**
* Sets the remote repositories to consider as sources of the artifact.
*
* @param repositories The remote repositories, may be {@code null} or empty to only consider locally installed
* artifacts.
* @return This query for chaining, never {@code null}.
*/
public LocalArtifactRequest setRepositories( List repositories )
{
if ( repositories != null )
{
this.repositories = repositories;
}
else
{
this.repositories = Collections.emptyList();
}
return this;
}
@Override
public String toString()
{
return getArtifact() + " @ " + getRepositories();
}
}
LocalArtifactResult.java 0000664 0000000 0000000 00000010756 12455463561 0033140 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.File;
import org.eclipse.aether.RepositorySystemSession;
/**
* A result from the local repository about the existence of an artifact.
*
* @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
*/
public final class LocalArtifactResult
{
private final LocalArtifactRequest request;
private File file;
private boolean available;
private RemoteRepository repository;
/**
* Creates a new result for the specified request.
*
* @param request The local artifact request, must not be {@code null}.
*/
public LocalArtifactResult( LocalArtifactRequest request )
{
if ( request == null )
{
throw new IllegalArgumentException( "local artifact request has not been specified" );
}
this.request = request;
}
/**
* Gets the request corresponding to this result.
*
* @return The corresponding request, never {@code null}.
*/
public LocalArtifactRequest getRequest()
{
return request;
}
/**
* Gets the file to the requested artifact. Note that this file must not be used unless {@link #isAvailable()}
* returns {@code true}. An artifact file can be found but considered unavailable if the artifact was cached from a
* remote repository that is not part of the list of remote repositories used for the query.
*
* @return The file to the requested artifact or {@code null} if the artifact does not exist locally.
*/
public File getFile()
{
return file;
}
/**
* Sets the file to requested artifact.
*
* @param file The artifact file, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public LocalArtifactResult setFile( File file )
{
this.file = file;
return this;
}
/**
* Indicates whether the requested artifact is available for use. As a minimum, the file needs to be physically
* existent in the local repository to be available. Additionally, a local repository manager can consider the list
* of supplied remote repositories to determine whether the artifact is logically available and mark an artifact
* unavailable (despite its physical existence) if it is not known to be hosted by any of the provided repositories.
*
* @return {@code true} if the artifact is available, {@code false} otherwise.
* @see LocalArtifactRequest#getRepositories()
*/
public boolean isAvailable()
{
return available;
}
/**
* Sets whether the artifact is available.
*
* @param available {@code true} if the artifact is available, {@code false} otherwise.
* @return This result for chaining, never {@code null}.
*/
public LocalArtifactResult setAvailable( boolean available )
{
this.available = available;
return this;
}
/**
* Gets the (first) remote repository from which the artifact was cached (if any).
*
* @return The remote repository from which the artifact was originally retrieved or {@code null} if unknown or if
* the artifact has been locally installed.
* @see LocalArtifactRequest#getRepositories()
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Sets the (first) remote repository from which the artifact was cached.
*
* @param repository The remote repository from which the artifact was originally retrieved, may be {@code null} if
* unknown or if the artifact has been locally installed.
* @return This result for chaining, never {@code null}.
*/
public LocalArtifactResult setRepository( RemoteRepository repository )
{
this.repository = repository;
return this;
}
@Override
public String toString()
{
return getFile() + " (" + ( isAvailable() ? "available" : "unavailable" ) + ")";
}
}
LocalMetadataRegistration.java 0000664 0000000 0000000 00000010122 12455463561 0034302 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.metadata.Metadata;
/**
* A request to register metadata within the local repository.
*
* @see LocalRepositoryManager#add(RepositorySystemSession, LocalMetadataRegistration)
*/
public final class LocalMetadataRegistration
{
private Metadata metadata;
private RemoteRepository repository;
private Collection contexts = Collections.emptyList();
/**
* Creates an uninitialized registration.
*/
public LocalMetadataRegistration()
{
// enables default constructor
}
/**
* Creates a registration request for the specified metadata accompanying a locally installed artifact.
*
* @param metadata The metadata to register, may be {@code null}.
*/
public LocalMetadataRegistration( Metadata metadata )
{
setMetadata( metadata );
}
/**
* Creates a registration request for the specified metadata.
*
* @param metadata The metadata to register, may be {@code null}.
* @param repository The remote repository from which the metadata was resolved or {@code null} if the metadata
* accompanies a locally installed artifact.
* @param contexts The resolution contexts, may be {@code null}.
*/
public LocalMetadataRegistration( Metadata metadata, RemoteRepository repository, Collection contexts )
{
setMetadata( metadata );
setRepository( repository );
setContexts( contexts );
}
/**
* Gets the metadata to register.
*
* @return The metadata or {@code null} if not set.
*/
public Metadata getMetadata()
{
return metadata;
}
/**
* Sets the metadata to register.
*
* @param metadata The metadata, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public LocalMetadataRegistration setMetadata( Metadata metadata )
{
this.metadata = metadata;
return this;
}
/**
* Gets the remote repository from which the metadata was resolved.
*
* @return The remote repository or {@code null} if the metadata was locally installed.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Sets the remote repository from which the metadata was resolved.
*
* @param repository The remote repository or {@code null} if the metadata accompanies a locally installed artifact.
* @return This request for chaining, never {@code null}.
*/
public LocalMetadataRegistration setRepository( RemoteRepository repository )
{
this.repository = repository;
return this;
}
/**
* Gets the resolution contexts in which the metadata is available.
*
* @return The resolution contexts in which the metadata is available, never {@code null}.
*/
public Collection getContexts()
{
return contexts;
}
/**
* Sets the resolution contexts in which the metadata is available.
*
* @param contexts The resolution contexts, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public LocalMetadataRegistration setContexts( Collection contexts )
{
if ( contexts != null )
{
this.contexts = contexts;
}
else
{
this.contexts = Collections.emptyList();
}
return this;
}
}
LocalMetadataRequest.java 0000664 0000000 0000000 00000006622 12455463561 0033272 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.metadata.Metadata;
/**
* A query to the local repository for the existence of metadata.
*
* @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
*/
public final class LocalMetadataRequest
{
private Metadata metadata;
private String context = "";
private RemoteRepository repository = null;
/**
* Creates an uninitialized query.
*/
public LocalMetadataRequest()
{
// enables default constructor
}
/**
* Creates a query with the specified properties.
*
* @param metadata The metadata to query for, may be {@code null}.
* @param repository The source remote repository for the metadata, may be {@code null} for local metadata.
* @param context The resolution context for the metadata, may be {@code null}.
*/
public LocalMetadataRequest( Metadata metadata, RemoteRepository repository, String context )
{
setMetadata( metadata );
setRepository( repository );
setContext( context );
}
/**
* Gets the metadata to query for.
*
* @return The metadata or {@code null} if not set.
*/
public Metadata getMetadata()
{
return metadata;
}
/**
* Sets the metadata to query for.
*
* @param metadata The metadata, may be {@code null}.
* @return This query for chaining, never {@code null}.
*/
public LocalMetadataRequest setMetadata( Metadata metadata )
{
this.metadata = metadata;
return this;
}
/**
* Gets the resolution context.
*
* @return The resolution context, never {@code null}.
*/
public String getContext()
{
return context;
}
/**
* Sets the resolution context.
*
* @param context The resolution context, may be {@code null}.
* @return This query for chaining, never {@code null}.
*/
public LocalMetadataRequest setContext( String context )
{
this.context = ( context != null ) ? context : "";
return this;
}
/**
* Gets the remote repository to use as source of the metadata.
*
* @return The remote repositories, may be {@code null} for local metadata.
*/
public RemoteRepository getRepository()
{
return repository;
}
/**
* Sets the remote repository to use as sources of the metadata.
*
* @param repository The remote repository, may be {@code null}.
* @return This query for chaining, may be {@code null} for local metadata.
*/
public LocalMetadataRequest setRepository( RemoteRepository repository )
{
this.repository = repository;
return this;
}
@Override
public String toString()
{
return getMetadata() + " @ " + getRepository();
}
}
LocalMetadataResult.java 0000664 0000000 0000000 00000005474 12455463561 0033124 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.File;
import org.eclipse.aether.RepositorySystemSession;
/**
* A result from the local repository about the existence of metadata.
*
* @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
*/
public final class LocalMetadataResult
{
private final LocalMetadataRequest request;
private File file;
private boolean stale;
/**
* Creates a new result for the specified request.
*
* @param request The local metadata request, must not be {@code null}.
*/
public LocalMetadataResult( LocalMetadataRequest request )
{
if ( request == null )
{
throw new IllegalArgumentException( "local metadata request has not been specified" );
}
this.request = request;
}
/**
* Gets the request corresponding to this result.
*
* @return The corresponding request, never {@code null}.
*/
public LocalMetadataRequest getRequest()
{
return request;
}
/**
* Gets the file to the requested metadata if the metadata is available in the local repository.
*
* @return The file to the requested metadata or {@code null}.
*/
public File getFile()
{
return file;
}
/**
* Sets the file to requested metadata.
*
* @param file The metadata file, may be {@code null}.
* @return This result for chaining, never {@code null}.
*/
public LocalMetadataResult setFile( File file )
{
this.file = file;
return this;
}
/**
* This value indicates whether the metadata is stale and should be updated.
*
* @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
*/
public boolean isStale()
{
return stale;
}
/**
* Sets whether the metadata is stale.
*
* @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
* @return This result for chaining, never {@code null}.
*/
public LocalMetadataResult setStale( boolean stale )
{
this.stale = stale;
return this;
}
@Override
public String toString()
{
return request.toString() + "(" + getFile() + ")";
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/LocalRepository.java 0000664 0000000 0000000 00000006403 12455463561 0032434 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.File;
/**
* A repository on the local file system used to cache contents of remote repositories and to store locally installed
* artifacts. Note that this class merely describes such a repository, actual access to the contained artifacts is
* handled by a {@link LocalRepositoryManager} which is usually determined from the {@link #getContentType() type} of
* the repository.
*/
public final class LocalRepository
implements ArtifactRepository
{
private final File basedir;
private final String type;
/**
* Creates a new local repository with the specified base directory and unknown type.
*
* @param basedir The base directory of the repository, may be {@code null}.
*/
public LocalRepository( String basedir )
{
this( ( basedir != null ) ? new File( basedir ) : null, "" );
}
/**
* Creates a new local repository with the specified base directory and unknown type.
*
* @param basedir The base directory of the repository, may be {@code null}.
*/
public LocalRepository( File basedir )
{
this( basedir, "" );
}
/**
* Creates a new local repository with the specified properties.
*
* @param basedir The base directory of the repository, may be {@code null}.
* @param type The type of the repository, may be {@code null}.
*/
public LocalRepository( File basedir, String type )
{
this.basedir = basedir;
this.type = ( type != null ) ? type : "";
}
public String getContentType()
{
return type;
}
public String getId()
{
return "local";
}
/**
* Gets the base directory of the repository.
*
* @return The base directory or {@code null} if none.
*/
public File getBasedir()
{
return basedir;
}
@Override
public String toString()
{
return getBasedir() + " (" + getContentType() + ")";
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
LocalRepository that = (LocalRepository) obj;
return eq( basedir, that.basedir ) && eq( type, that.type );
}
private static boolean eq( T s1, T s2 )
{
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + hash( basedir );
hash = hash * 31 + hash( type );
return hash;
}
private static int hash( Object obj )
{
return obj != null ? obj.hashCode() : 0;
}
}
LocalRepositoryManager.java 0000664 0000000 0000000 00000014300 12455463561 0033643 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.Metadata;
/**
* Manages access to a local repository.
*
* @see RepositorySystemSession#getLocalRepositoryManager()
* @see org.eclipse.aether.RepositorySystem#newLocalRepositoryManager(RepositorySystemSession, LocalRepository)
*/
public interface LocalRepositoryManager
{
/**
* Gets the description of the local repository being managed.
*
* @return The description of the local repository, never {@code null}.
*/
LocalRepository getRepository();
/**
* Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
* the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the
* forward slash as directory separator regardless of the underlying file system.
*
* @param artifact The artifact for which to determine the path, must not be {@code null}.
* @return The path, relative to the local repository's base directory.
*/
String getPathForLocalArtifact( Artifact artifact );
/**
* Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually
* exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The
* path uses the forward slash as directory separator regardless of the underlying file system.
*
* @param artifact The artifact for which to determine the path, must not be {@code null}.
* @param repository The source repository of the artifact, must not be {@code null}.
* @param context The resolution context in which the artifact is being requested, may be {@code null}.
* @return The path, relative to the local repository's base directory.
*/
String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context );
/**
* Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the
* returned location, the path merely indicates where the metadata would eventually be stored. The path uses the
* forward slash as directory separator regardless of the underlying file system.
*
* @param metadata The metadata for which to determine the path, must not be {@code null}.
* @return The path, relative to the local repository's base directory.
*/
String getPathForLocalMetadata( Metadata metadata );
/**
* Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually
* exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The
* path uses the forward slash as directory separator regardless of the underlying file system.
*
* @param metadata The metadata for which to determine the path, must not be {@code null}.
* @param repository The source repository of the metadata, must not be {@code null}.
* @param context The resolution context in which the metadata is being requested, may be {@code null}.
* @return The path, relative to the local repository's base directory.
*/
String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context );
/**
* Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally
* installed artifact or a previously downloaded artifact.
*
* @param session The repository system session during which the request is made, must not be {@code null}.
* @param request The artifact request, must not be {@code null}.
* @return The result of the request, never {@code null}.
*/
LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request );
/**
* Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely
* concerned about updating the local repository's internal state, not about actually installing the artifact or its
* accompanying metadata.
*
* @param session The repository system session during which the registration is made, must not be {@code null}.
* @param request The registration request, must not be {@code null}.
*/
void add( RepositorySystemSession session, LocalArtifactRegistration request );
/**
* Queries for the existence of metadata in the local repository. The request could be satisfied by locally
* installed or previously downloaded metadata.
*
* @param session The repository system session during which the request is made, must not be {@code null}.
* @param request The metadata request, must not be {@code null}.
* @return The result of the request, never {@code null}.
*/
LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request );
/**
* Registers installed or resolved metadata with the local repository. Note that metadata registration is merely
* concerned about updating the local repository's internal state, not about actually installing the metadata.
* However, this method MUST be called after the actual install to give the repository manager the opportunity to
* inspect the added metadata.
*
* @param session The repository system session during which the registration is made, must not be {@code null}.
* @param request The registration request, must not be {@code null}.
*/
void add( RepositorySystemSession session, LocalMetadataRegistration request );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/MirrorSelector.java 0000664 0000000 0000000 00000002074 12455463561 0032255 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* Selects a mirror for a given remote repository.
*
* @see org.eclipse.aether.RepositorySystemSession#getMirrorSelector()
*/
public interface MirrorSelector
{
/**
* Selects a mirror for the specified repository.
*
* @param repository The repository to select a mirror for, must not be {@code null}.
* @return The selected mirror or {@code null} if none.
* @see RemoteRepository#getMirroredRepositories()
*/
RemoteRepository getMirror( RemoteRepository repository );
}
NoLocalRepositoryManagerException.java 0000664 0000000 0000000 00000006235 12455463561 0036027 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import org.eclipse.aether.RepositoryException;
/**
* Thrown in case of an unsupported local repository type.
*/
public class NoLocalRepositoryManagerException
extends RepositoryException
{
private final transient LocalRepository repository;
/**
* Creates a new exception with the specified repository.
*
* @param repository The local repository for which no support is available, may be {@code null}.
*/
public NoLocalRepositoryManagerException( LocalRepository repository )
{
this( repository, toMessage( repository ) );
}
/**
* Creates a new exception with the specified repository and detail message.
*
* @param repository The local repository for which no support is available, may be {@code null}.
* @param message The detail message, may be {@code null}.
*/
public NoLocalRepositoryManagerException( LocalRepository repository, String message )
{
super( message );
this.repository = repository;
}
/**
* Creates a new exception with the specified repository and cause.
*
* @param repository The local repository for which no support is available, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public NoLocalRepositoryManagerException( LocalRepository repository, Throwable cause )
{
this( repository, toMessage( repository ), cause );
}
/**
* Creates a new exception with the specified repository, detail message and cause.
*
* @param repository The local repository for which no support is available, may be {@code null}.
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public NoLocalRepositoryManagerException( LocalRepository repository, String message, Throwable cause )
{
super( message, cause );
this.repository = repository;
}
private static String toMessage( LocalRepository repository )
{
if ( repository != null )
{
return "No manager available for local repository (" + repository.getBasedir().getAbsolutePath()
+ ") of type " + repository.getContentType();
}
else
{
return "No manager available for local repository";
}
}
/**
* Gets the local repository whose content type is not supported.
*
* @return The unsupported local repository or {@code null} if unknown.
*/
public LocalRepository getRepository()
{
return repository;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/Proxy.java 0000664 0000000 0000000 00000007257 12455463561 0030433 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* A proxy to use for connections to a repository.
*/
public final class Proxy
{
/**
* Type denoting a proxy for HTTP transfers.
*/
public static final String TYPE_HTTP = "http";
/**
* Type denoting a proxy for HTTPS transfers.
*/
public static final String TYPE_HTTPS = "https";
private final String type;
private final String host;
private final int port;
private final Authentication auth;
/**
* Creates a new proxy with the specified properties and no authentication.
*
* @param type The type of the proxy, e.g. "http", may be {@code null}.
* @param host The host of the proxy, may be {@code null}.
* @param port The port of the proxy.
*/
public Proxy( String type, String host, int port )
{
this( type, host, port, null );
}
/**
* Creates a new proxy with the specified properties.
*
* @param type The type of the proxy, e.g. "http", may be {@code null}.
* @param host The host of the proxy, may be {@code null}.
* @param port The port of the proxy.
* @param auth The authentication to use for the proxy connection, may be {@code null}.
*/
public Proxy( String type, String host, int port, Authentication auth )
{
this.type = ( type != null ) ? type : "";
this.host = ( host != null ) ? host : "";
this.port = port;
this.auth = auth;
}
/**
* Gets the type of this proxy.
*
* @return The type of this proxy, never {@code null}.
*/
public String getType()
{
return type;
}
/**
* Gets the host for this proxy.
*
* @return The host for this proxy, never {@code null}.
*/
public String getHost()
{
return host;
}
/**
* Gets the port number for this proxy.
*
* @return The port number for this proxy.
*/
public int getPort()
{
return port;
}
/**
* Gets the authentication to use for the proxy connection.
*
* @return The authentication to use or {@code null} if none.
*/
public Authentication getAuthentication()
{
return auth;
}
@Override
public String toString()
{
return getHost() + ':' + getPort();
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
Proxy that = (Proxy) obj;
return eq( type, that.type ) && eq( host, that.host ) && port == that.port && eq( auth, that.auth );
}
private static boolean eq( T s1, T s2 )
{
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + hash( host );
hash = hash * 31 + hash( type );
hash = hash * 31 + port;
hash = hash * 31 + hash( auth );
return hash;
}
private static int hash( Object obj )
{
return obj != null ? obj.hashCode() : 0;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/ProxySelector.java 0000664 0000000 0000000 00000002000 12455463561 0032111 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* Selects a proxy for a given remote repository.
*
* @see org.eclipse.aether.RepositorySystemSession#getProxySelector()
*/
public interface ProxySelector
{
/**
* Selects a proxy for the specified remote repository.
*
* @param repository The repository for which to select a proxy, must not be {@code null}.
* @return The selected proxy or {@code null} if none.
*/
Proxy getProxy( RemoteRepository repository );
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java 0000664 0000000 0000000 00000044603 12455463561 0032641 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A repository on a remote server.
*/
public final class RemoteRepository
implements ArtifactRepository
{
private static final Pattern URL_PATTERN =
Pattern.compile( "([^:/]+(:[^:/]{2,}+(?=://))?):(//([^@/]*@)?([^/:]+))?.*" );
private final String id;
private final String type;
private final String url;
private final String host;
private final String protocol;
private final RepositoryPolicy releasePolicy;
private final RepositoryPolicy snapshotPolicy;
private final Proxy proxy;
private final Authentication authentication;
private final List mirroredRepositories;
private final boolean repositoryManager;
RemoteRepository( Builder builder )
{
if ( builder.prototype != null )
{
id = ( builder.delta & Builder.ID ) != 0 ? builder.id : builder.prototype.id;
type = ( builder.delta & Builder.TYPE ) != 0 ? builder.type : builder.prototype.type;
url = ( builder.delta & Builder.URL ) != 0 ? builder.url : builder.prototype.url;
releasePolicy =
( builder.delta & Builder.RELEASES ) != 0 ? builder.releasePolicy : builder.prototype.releasePolicy;
snapshotPolicy =
( builder.delta & Builder.SNAPSHOTS ) != 0 ? builder.snapshotPolicy : builder.prototype.snapshotPolicy;
proxy = ( builder.delta & Builder.PROXY ) != 0 ? builder.proxy : builder.prototype.proxy;
authentication =
( builder.delta & Builder.AUTH ) != 0 ? builder.authentication : builder.prototype.authentication;
repositoryManager =
( builder.delta & Builder.REPOMAN ) != 0 ? builder.repositoryManager
: builder.prototype.repositoryManager;
mirroredRepositories =
( builder.delta & Builder.MIRRORED ) != 0 ? copy( builder.mirroredRepositories )
: builder.prototype.mirroredRepositories;
}
else
{
id = builder.id;
type = builder.type;
url = builder.url;
releasePolicy = builder.releasePolicy;
snapshotPolicy = builder.snapshotPolicy;
proxy = builder.proxy;
authentication = builder.authentication;
repositoryManager = builder.repositoryManager;
mirroredRepositories = copy( builder.mirroredRepositories );
}
Matcher m = URL_PATTERN.matcher( url );
if ( m.matches() )
{
protocol = m.group( 1 );
String host = m.group( 5 );
this.host = ( host != null ) ? host : "";
}
else
{
protocol = host = "";
}
}
private static List copy( List repos )
{
if ( repos == null || repos.isEmpty() )
{
return Collections.emptyList();
}
return Collections.unmodifiableList( Arrays.asList( repos.toArray( new RemoteRepository[repos.size()] ) ) );
}
public String getId()
{
return id;
}
public String getContentType()
{
return type;
}
/**
* Gets the (base) URL of this repository.
*
* @return The (base) URL of this repository, never {@code null}.
*/
public String getUrl()
{
return url;
}
/**
* Gets the protocol part from the repository's URL, for example {@code file} or {@code http}. As suggested by RFC
* 2396, section 3.1 "Scheme Component", the protocol name should be treated case-insensitively.
*
* @return The protocol or an empty string if none, never {@code null}.
*/
public String getProtocol()
{
return protocol;
}
/**
* Gets the host part from the repository's URL.
*
* @return The host or an empty string if none, never {@code null}.
*/
public String getHost()
{
return host;
}
/**
* Gets the policy to apply for snapshot/release artifacts.
*
* @param snapshot {@code true} to retrieve the snapshot policy, {@code false} to retrieve the release policy.
* @return The requested repository policy, never {@code null}.
*/
public RepositoryPolicy getPolicy( boolean snapshot )
{
return snapshot ? snapshotPolicy : releasePolicy;
}
/**
* Gets the proxy that has been selected for this repository.
*
* @return The selected proxy or {@code null} if none.
*/
public Proxy getProxy()
{
return proxy;
}
/**
* Gets the authentication that has been selected for this repository.
*
* @return The selected authentication or {@code null} if none.
*/
public Authentication getAuthentication()
{
return authentication;
}
/**
* Gets the repositories that this repository serves as a mirror for.
*
* @return The (read-only) repositories being mirrored by this repository, never {@code null}.
*/
public List getMirroredRepositories()
{
return mirroredRepositories;
}
/**
* Indicates whether this repository refers to a repository manager or not.
*
* @return {@code true} if this repository is a repository manager, {@code false} otherwise.
*/
public boolean isRepositoryManager()
{
return repositoryManager;
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder( 256 );
buffer.append( getId() );
buffer.append( " (" ).append( getUrl() );
buffer.append( ", " ).append( getContentType() );
boolean r = getPolicy( false ).isEnabled(), s = getPolicy( true ).isEnabled();
if ( r && s )
{
buffer.append( ", releases+snapshots" );
}
else if ( r )
{
buffer.append( ", releases" );
}
else if ( s )
{
buffer.append( ", snapshots" );
}
else
{
buffer.append( ", disabled" );
}
if ( isRepositoryManager() )
{
buffer.append( ", managed" );
}
buffer.append( ")" );
return buffer.toString();
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
RemoteRepository that = (RemoteRepository) obj;
return eq( url, that.url ) && eq( type, that.type ) && eq( id, that.id )
&& eq( releasePolicy, that.releasePolicy ) && eq( snapshotPolicy, that.snapshotPolicy )
&& eq( proxy, that.proxy ) && eq( authentication, that.authentication )
&& eq( mirroredRepositories, that.mirroredRepositories ) && repositoryManager == that.repositoryManager;
}
private static boolean eq( T s1, T s2 )
{
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + hash( url );
hash = hash * 31 + hash( type );
hash = hash * 31 + hash( id );
hash = hash * 31 + hash( releasePolicy );
hash = hash * 31 + hash( snapshotPolicy );
hash = hash * 31 + hash( proxy );
hash = hash * 31 + hash( authentication );
hash = hash * 31 + hash( mirroredRepositories );
hash = hash * 31 + ( repositoryManager ? 1 : 0 );
return hash;
}
private static int hash( Object obj )
{
return obj != null ? obj.hashCode() : 0;
}
/**
* A builder to create remote repositories.
*/
public static final class Builder
{
private static final RepositoryPolicy DEFAULT_POLICY = new RepositoryPolicy();
static final int ID = 0x0001, TYPE = 0x0002, URL = 0x0004, RELEASES = 0x0008, SNAPSHOTS = 0x0010,
PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100;
int delta;
RemoteRepository prototype;
String id;
String type;
String url;
RepositoryPolicy releasePolicy = DEFAULT_POLICY;
RepositoryPolicy snapshotPolicy = DEFAULT_POLICY;
Proxy proxy;
Authentication authentication;
List mirroredRepositories;
boolean repositoryManager;
/**
* Creates a new repository builder.
*
* @param id The identifier of the repository, may be {@code null}.
* @param type The type of the repository, may be {@code null}.
* @param url The (base) URL of the repository, may be {@code null}.
*/
public Builder( String id, String type, String url )
{
this.id = ( id != null ) ? id : "";
this.type = ( type != null ) ? type : "";
this.url = ( url != null ) ? url : "";
}
/**
* Creates a new repository builder which uses the specified remote repository as a prototype for the new one.
* All properties which have not been set on the builder will be copied from the prototype when building the
* repository.
*
* @param prototype The remote repository to use as prototype, must not be {@code null}.
*/
public Builder( RemoteRepository prototype )
{
if ( prototype == null )
{
throw new IllegalArgumentException( "repository prototype missing" );
}
this.prototype = prototype;
}
/**
* Builds a new remote repository from the current values of this builder. The state of the builder itself
* remains unchanged.
*
* @return The remote repository, never {@code null}.
*/
public RemoteRepository build()
{
if ( prototype != null && delta == 0 )
{
return prototype;
}
return new RemoteRepository( this );
}
private void delta( int flag, T builder, T prototype )
{
boolean equal = ( builder != null ) ? builder.equals( prototype ) : prototype == null;
if ( equal )
{
delta &= ~flag;
}
else
{
delta |= flag;
}
}
/**
* Sets the identifier of the repository.
*
* @param id The identifier of the repository, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setId( String id )
{
this.id = ( id != null ) ? id : "";
if ( prototype != null )
{
delta( ID, this.id, prototype.getId() );
}
return this;
}
/**
* Sets the type of the repository, e.g. "default".
*
* @param type The type of the repository, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setContentType( String type )
{
this.type = ( type != null ) ? type : "";
if ( prototype != null )
{
delta( TYPE, this.type, prototype.getContentType() );
}
return this;
}
/**
* Sets the (base) URL of the repository.
*
* @param url The URL of the repository, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setUrl( String url )
{
this.url = ( url != null ) ? url : "";
if ( prototype != null )
{
delta( URL, this.url, prototype.getUrl() );
}
return this;
}
/**
* Sets the policy to apply for snapshot and release artifacts.
*
* @param policy The repository policy to set, may be {@code null} to use a default policy.
* @return This builder for chaining, never {@code null}.
*/
public Builder setPolicy( RepositoryPolicy policy )
{
this.releasePolicy = this.snapshotPolicy = ( policy != null ) ? policy : DEFAULT_POLICY;
if ( prototype != null )
{
delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
}
return this;
}
/**
* Sets the policy to apply for release artifacts.
*
* @param releasePolicy The repository policy to set, may be {@code null} to use a default policy.
* @return This builder for chaining, never {@code null}.
*/
public Builder setReleasePolicy( RepositoryPolicy releasePolicy )
{
this.releasePolicy = ( releasePolicy != null ) ? releasePolicy : DEFAULT_POLICY;
if ( prototype != null )
{
delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
}
return this;
}
/**
* Sets the policy to apply for snapshot artifacts.
*
* @param snapshotPolicy The repository policy to set, may be {@code null} to use a default policy.
* @return This builder for chaining, never {@code null}.
*/
public Builder setSnapshotPolicy( RepositoryPolicy snapshotPolicy )
{
this.snapshotPolicy = ( snapshotPolicy != null ) ? snapshotPolicy : DEFAULT_POLICY;
if ( prototype != null )
{
delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
}
return this;
}
/**
* Sets the proxy to use in order to access the repository.
*
* @param proxy The proxy to use, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setProxy( Proxy proxy )
{
this.proxy = proxy;
if ( prototype != null )
{
delta( PROXY, this.proxy, prototype.getProxy() );
}
return this;
}
/**
* Sets the authentication to use in order to access the repository.
*
* @param authentication The authentication to use, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setAuthentication( Authentication authentication )
{
this.authentication = authentication;
if ( prototype != null )
{
delta( AUTH, this.authentication, prototype.getAuthentication() );
}
return this;
}
/**
* Sets the repositories being mirrored by the repository.
*
* @param mirroredRepositories The repositories being mirrored by the repository, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder setMirroredRepositories( List mirroredRepositories )
{
if ( this.mirroredRepositories == null )
{
this.mirroredRepositories = new ArrayList();
}
else
{
this.mirroredRepositories.clear();
}
if ( mirroredRepositories != null )
{
this.mirroredRepositories.addAll( mirroredRepositories );
}
if ( prototype != null )
{
delta( MIRRORED, this.mirroredRepositories, prototype.getMirroredRepositories() );
}
return this;
}
/**
* Adds the specified repository to the list of repositories being mirrored by the repository. If this builder
* was {@link #RemoteRepository.Builder(RemoteRepository) constructed from a prototype}, the given repository
* will be added to the list of mirrored repositories from the prototype.
*
* @param mirroredRepository The repository being mirrored by the repository, may be {@code null}.
* @return This builder for chaining, never {@code null}.
*/
public Builder addMirroredRepository( RemoteRepository mirroredRepository )
{
if ( mirroredRepository != null )
{
if ( this.mirroredRepositories == null )
{
this.mirroredRepositories = new ArrayList();
if ( prototype != null )
{
mirroredRepositories.addAll( prototype.getMirroredRepositories() );
}
}
mirroredRepositories.add( mirroredRepository );
if ( prototype != null )
{
delta |= MIRRORED;
}
}
return this;
}
/**
* Marks the repository as a repository manager or not.
*
* @param repositoryManager {@code true} if the repository points at a repository manager, {@code false} if the
* repository is just serving static contents.
* @return This builder for chaining, never {@code null}.
*/
public Builder setRepositoryManager( boolean repositoryManager )
{
this.repositoryManager = repositoryManager;
if ( prototype != null )
{
delta( REPOMAN, this.repositoryManager, prototype.isRepositoryManager() );
}
return this;
}
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java 0000664 0000000 0000000 00000010465 12455463561 0032644 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
/**
* A policy controlling access to a repository.
*/
public final class RepositoryPolicy
{
/**
* Never update locally cached data.
*/
public static final String UPDATE_POLICY_NEVER = "never";
/**
* Always update locally cached data.
*/
public static final String UPDATE_POLICY_ALWAYS = "always";
/**
* Update locally cached data once a day.
*/
public static final String UPDATE_POLICY_DAILY = "daily";
/**
* Update locally cached data every X minutes as given by "interval:X".
*/
public static final String UPDATE_POLICY_INTERVAL = "interval";
/**
* Verify checksums and fail the resolution if they do not match.
*/
public static final String CHECKSUM_POLICY_FAIL = "fail";
/**
* Verify checksums and warn if they do not match.
*/
public static final String CHECKSUM_POLICY_WARN = "warn";
/**
* Do not verify checksums.
*/
public static final String CHECKSUM_POLICY_IGNORE = "ignore";
private final boolean enabled;
private final String updatePolicy;
private final String checksumPolicy;
/**
* Creates a new policy with checksum warnings and daily update checks.
*/
public RepositoryPolicy()
{
this( true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN );
}
/**
* Creates a new policy with the specified settings.
*
* @param enabled A flag whether the associated repository should be accessed or not.
* @param updatePolicy The update interval after which locally cached data from the repository is considered stale
* and should be refetched, may be {@code null}.
* @param checksumPolicy The way checksum verification should be handled, may be {@code null}.
*/
public RepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy )
{
this.enabled = enabled;
this.updatePolicy = ( updatePolicy != null ) ? updatePolicy : "";
this.checksumPolicy = ( checksumPolicy != null ) ? checksumPolicy : "";
}
/**
* Indicates whether the associated repository should be contacted or not.
*
* @return {@code true} if the repository should be contacted, {@code false} otherwise.
*/
public boolean isEnabled()
{
return enabled;
}
/**
* Gets the update policy for locally cached data from the repository.
*
* @return The update policy, never {@code null}.
*/
public String getUpdatePolicy()
{
return updatePolicy;
}
/**
* Gets the policy for checksum validation.
*
* @return The checksum policy, never {@code null}.
*/
public String getChecksumPolicy()
{
return checksumPolicy;
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder( 256 );
buffer.append( "enabled=" ).append( isEnabled() );
buffer.append( ", checksums=" ).append( getChecksumPolicy() );
buffer.append( ", updates=" ).append( getUpdatePolicy() );
return buffer.toString();
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
RepositoryPolicy that = (RepositoryPolicy) obj;
return enabled == that.enabled && updatePolicy.equals( that.updatePolicy )
&& checksumPolicy.equals( that.checksumPolicy );
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + ( enabled ? 1 : 0 );
hash = hash * 31 + updatePolicy.hashCode();
hash = hash * 31 + checksumPolicy.hashCode();
return hash;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/WorkspaceReader.java 0000664 0000000 0000000 00000003205 12455463561 0032360 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.io.File;
import java.util.List;
import org.eclipse.aether.artifact.Artifact;
/**
* Manages a repository backed by the IDE workspace, a build session or a similar ad-hoc collection of artifacts.
*
* @see org.eclipse.aether.RepositorySystemSession#getWorkspaceReader()
*/
public interface WorkspaceReader
{
/**
* Gets a description of the workspace repository.
*
* @return The repository description, never {@code null}.
*/
WorkspaceRepository getRepository();
/**
* Locates the specified artifact.
*
* @param artifact The artifact to locate, must not be {@code null}.
* @return The path to the artifact or {@code null} if the artifact is not available.
*/
File findArtifact( Artifact artifact );
/**
* Determines all available versions of the specified artifact.
*
* @param artifact The artifact whose versions should be listed, must not be {@code null}.
* @return The available versions of the artifact, must not be {@code null}.
*/
List findVersions( Artifact artifact );
}
WorkspaceRepository.java 0000664 0000000 0000000 00000006642 12455463561 0033266 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository /*******************************************************************************
* Copyright (c) 2010, 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.repository;
import java.util.UUID;
/**
* A repository backed by an IDE workspace, the output of a build session or similar ad-hoc collection of artifacts. As
* far as the repository system is concerned, a workspace repository is read-only, i.e. can only be used for artifact
* resolution but not installation/deployment. Note that this class merely describes such a repository, actual access to
* the contained artifacts is handled by a {@link WorkspaceReader}.
*/
public final class WorkspaceRepository
implements ArtifactRepository
{
private final String type;
private final Object key;
/**
* Creates a new workspace repository of type {@code "workspace"} and a random key.
*/
public WorkspaceRepository()
{
this( "workspace" );
}
/**
* Creates a new workspace repository with the specified type and a random key.
*
* @param type The type of the repository, may be {@code null}.
*/
public WorkspaceRepository( String type )
{
this( type, null );
}
/**
* Creates a new workspace repository with the specified type and key. The key is used to distinguish one workspace
* from another and should be sensitive to the artifacts that are (potentially) available in the workspace.
*
* @param type The type of the repository, may be {@code null}.
* @param key The (comparison) key for the repository, may be {@code null} to generate a unique random key.
*/
public WorkspaceRepository( String type, Object key )
{
this.type = ( type != null ) ? type : "";
this.key = ( key != null ) ? key : UUID.randomUUID().toString().replace( "-", "" );
}
public String getContentType()
{
return type;
}
public String getId()
{
return "workspace";
}
/**
* Gets the key of this workspace repository. The key is used to distinguish one workspace from another and should
* be sensitive to the artifacts that are (potentially) available in the workspace.
*
* @return The (comparison) key for this workspace repository, never {@code null}.
*/
public Object getKey()
{
return key;
}
@Override
public String toString()
{
return "(" + getContentType() + ")";
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null || !getClass().equals( obj.getClass() ) )
{
return false;
}
WorkspaceRepository that = (WorkspaceRepository) obj;
return getContentType().equals( that.getContentType() ) && getKey().equals( that.getKey() );
}
@Override
public int hashCode()
{
int hash = 17;
hash = hash * 31 + getKey().hashCode();
hash = hash * 31 + getContentType().hashCode();
return hash;
}
}
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/repository/package-info.java 0000664 0000000 0000000 00000001200 12455463561 0031614 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* Copyright (c) 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
/**
* The definition of various kinds of repositories that host artifacts.
*/
package org.eclipse.aether.repository;
aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/resolution/ 0000775 0000000 0000000 00000000000 12455463561 0026420 5 ustar 00root root 0000000 0000000 ArtifactDescriptorException.java 0000664 0000000 0000000 00000005616 12455463561 0034667 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/resolution /*******************************************************************************
* Copyright (c) 2010, 2014 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.resolution;
import org.eclipse.aether.RepositoryException;
/**
* Thrown in case of an unreadable or unresolvable artifact descriptor.
*/
public class ArtifactDescriptorException
extends RepositoryException
{
private final transient ArtifactDescriptorResult result;
/**
* Creates a new exception with the specified result.
*
* @param result The descriptor result at the point the exception occurred, may be {@code null}.
*/
public ArtifactDescriptorException( ArtifactDescriptorResult result )
{
super( "Failed to read artifact descriptor"
+ ( result != null ? " for " + result.getRequest().getArtifact() : "" ), getCause( result ) );
this.result = result;
}
/**
* Creates a new exception with the specified result and detail message.
*
* @param result The descriptor result at the point the exception occurred, may be {@code null}.
* @param message The detail message, may be {@code null}.
*/
public ArtifactDescriptorException( ArtifactDescriptorResult result, String message )
{
super( message, getCause( result ) );
this.result = result;
}
/**
* Creates a new exception with the specified result, detail message and cause.
*
* @param result The descriptor result at the point the exception occurred, may be {@code null}.
* @param message The detail message, may be {@code null}.
* @param cause The exception that caused this one, may be {@code null}.
*/
public ArtifactDescriptorException( ArtifactDescriptorResult result, String message, Throwable cause )
{
super( message, cause );
this.result = result;
}
/**
* Gets the descriptor result at the point the exception occurred. Despite being incomplete, callers might want to
* use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
*
* @return The descriptor result or {@code null} if unknown.
*/
public ArtifactDescriptorResult getResult()
{
return result;
}
private static Throwable getCause( ArtifactDescriptorResult result )
{
Throwable cause = null;
if ( result != null && !result.getExceptions().isEmpty() )
{
cause = result.getExceptions().get( 0 );
}
return cause;
}
}
ArtifactDescriptorPolicy.java 0000664 0000000 0000000 00000003455 12455463561 0034167 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/resolution /*******************************************************************************
* Copyright (c) 2012, 2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.resolution;
import org.eclipse.aether.RepositorySystemSession;
/**
* Controls the handling of errors related to reading an artifact descriptor.
*
* @see RepositorySystemSession#getArtifactDescriptorPolicy()
*/
public interface ArtifactDescriptorPolicy
{
/**
* Bit mask indicating that errors while reading the artifact descriptor should not be tolerated.
*/
int STRICT = 0x00;
/**
* Bit flag indicating that missing artifact descriptors should be silently ignored.
*/
int IGNORE_MISSING = 0x01;
/**
* Bit flag indicating that existent but invalid artifact descriptors should be silently ignored.
*/
int IGNORE_INVALID = 0x02;
/**
* Bit mask indicating that all errors should be silently ignored.
*/
int IGNORE_ERRORS = IGNORE_MISSING | IGNORE_INVALID;
/**
* Gets the error policy for an artifact's descriptor.
*
* @param session The repository session during which the policy is determined, must not be {@code null}.
* @param request The policy request holding further details, must not be {@code null}.
* @return The bit mask describing the desired error policy.
*/
int getPolicy( RepositorySystemSession session, ArtifactDescriptorPolicyRequest request );
}
ArtifactDescriptorPolicyRequest.java 0000664 0000000 0000000 00000005361 12455463561 0035536 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/resolution /*******************************************************************************
* Copyright (c) 2012 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.resolution;
import org.eclipse.aether.artifact.Artifact;
/**
* A query for the error policy for a given artifact's descriptor.
*
* @see ArtifactDescriptorPolicy
*/
public final class ArtifactDescriptorPolicyRequest
{
private Artifact artifact;
private String context = "";
/**
* Creates an uninitialized request.
*/
public ArtifactDescriptorPolicyRequest()
{
// enables default constructor
}
/**
* Creates a request for the specified artifact.
*
* @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
* @param context The context in which this request is made, may be {@code null}.
*/
public ArtifactDescriptorPolicyRequest( Artifact artifact, String context )
{
setArtifact( artifact );
setRequestContext( context );
}
/**
* Gets the artifact for whose descriptor to determine the error policy.
*
* @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Sets the artifact for whose descriptor to determine the error policy.
*
* @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact )
{
this.artifact = artifact;
return this;
}
/**
* Gets the context in which this request is made.
*
* @return The context, never {@code null}.
*/
public String getRequestContext()
{
return context;
}
/**
* Sets the context in which this request is made.
*
* @param context The context, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public ArtifactDescriptorPolicyRequest setRequestContext( String context )
{
this.context = ( context != null ) ? context : "";
return this;
}
@Override
public String toString()
{
return String.valueOf( getArtifact() );
}
}
ArtifactDescriptorRequest.java 0000664 0000000 0000000 00000012414 12455463561 0034353 0 ustar 00root root 0000000 0000000 aether-1.0.2.v20150114/aether-api/src/main/java/org/eclipse/aether/resolution /*******************************************************************************
* Copyright (c) 2010, 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.aether.resolution;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.RemoteRepository;
/**
* A request to read an artifact descriptor.
*
* @see RepositorySystem#readArtifactDescriptor(RepositorySystemSession, ArtifactDescriptorRequest)
*/
public final class ArtifactDescriptorRequest
{
private Artifact artifact;
private List repositories = Collections.emptyList();
private String context = "";
private RequestTrace trace;
/**
* Creates an uninitialized request.
*/
public ArtifactDescriptorRequest()
{
// enables default constructor
}
/**
* Creates a request with the specified properties.
*
* @param artifact The artifact whose descriptor should be read, may be {@code null}.
* @param repositories The repositories to resolve the descriptor from, may be {@code null}.
* @param context The context in which this request is made, may be {@code null}.
*/
public ArtifactDescriptorRequest( Artifact artifact, List repositories, String context )
{
setArtifact( artifact );
setRepositories( repositories );
setRequestContext( context );
}
/**
* Gets the artifact whose descriptor shall be read.
*
* @return The artifact or {@code null} if not set.
*/
public Artifact getArtifact()
{
return artifact;
}
/**
* Sets the artifact whose descriptor shall be read. Eventually, a valid request must have an artifact set.
*
* @param artifact The artifact, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public ArtifactDescriptorRequest setArtifact( Artifact artifact )
{
this.artifact = artifact;
return this;
}
/**
* Gets the repositories to resolve the descriptor from.
*
* @return The repositories, never {@code null}.
*/
public List getRepositories()
{
return repositories;
}
/**
* Sets the repositories to resolve the descriptor from.
*
* @param repositories The repositories, may be {@code null}.
* @return This request for chaining, never {@code null}.
*/
public ArtifactDescriptorRequest setRepositories( List