mirror of https://github.com/apache/maven.git
o Introduced RepositoryRequest to hold the bare minimum of items required for repo accesses
o Added cache for metadata.xml git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
483a0d1f90
commit
24bd8d772f
|
@ -37,6 +37,9 @@ public interface ArtifactMetadataSource
|
||||||
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
|
List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
package org.apache.maven.artifact.repository;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects basic settings to access the repository system.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public class DefaultRepositoryRequest
|
||||||
|
implements RepositoryRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
|
private RepositoryCache cache;
|
||||||
|
|
||||||
|
public ArtifactRepository getLocalRepository()
|
||||||
|
{
|
||||||
|
return localRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultRepositoryRequest setLocalRepository( ArtifactRepository localRepository )
|
||||||
|
{
|
||||||
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ArtifactRepository> getRemoteRepositories()
|
||||||
|
{
|
||||||
|
if ( remoteRepositories == null )
|
||||||
|
{
|
||||||
|
remoteRepositories = new ArrayList<ArtifactRepository>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultRepositoryRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
|
||||||
|
{
|
||||||
|
this.remoteRepositories = remoteRepositories;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getCache()
|
||||||
|
{
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultRepositoryRequest setCache( RepositoryCache cache )
|
||||||
|
{
|
||||||
|
this.cache = cache;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.apache.maven.artifact.repository;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public interface RepositoryCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts the specified data into the cache. <strong>Warning:</strong> 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 request The repository request from which this cache was retrieved, must not be {@code null}.
|
||||||
|
* @param key The key to use associate the data with, must not be {@code null}.
|
||||||
|
* @param data The data to store in the cache, may be {@code null}.
|
||||||
|
*/
|
||||||
|
void put( RepositoryRequest request, Object key, Object data );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the specified data from the cache. <strong>Warning:</strong> 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 request The repository request from which this cache was retrieved, 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( RepositoryRequest request, Object key );
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.apache.maven.artifact.repository;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects basic settings to access the repository system.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public interface RepositoryRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
ArtifactRepository getLocalRepository();
|
||||||
|
|
||||||
|
RepositoryRequest setLocalRepository( ArtifactRepository localRepository );
|
||||||
|
|
||||||
|
List<ArtifactRepository> getRemoteRepositories();
|
||||||
|
|
||||||
|
RepositoryRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
|
||||||
|
|
||||||
|
RepositoryCache getCache();
|
||||||
|
|
||||||
|
RepositoryRequest setCache( RepositoryCache cache );
|
||||||
|
|
||||||
|
}
|
|
@ -82,6 +82,11 @@ public class ArtifactRepositoryMetadata
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactRepository getRepository()
|
||||||
|
{
|
||||||
|
return artifact.getRepository();
|
||||||
|
}
|
||||||
|
|
||||||
public void setRepository( ArtifactRepository remoteRepository )
|
public void setRepository( ArtifactRepository remoteRepository )
|
||||||
{
|
{
|
||||||
artifact.setRepository( remoteRepository );
|
artifact.setRepository( remoteRepository );
|
||||||
|
|
|
@ -20,12 +20,16 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
import org.apache.maven.repository.legacy.UpdateCheckManager;
|
import org.apache.maven.repository.legacy.UpdateCheckManager;
|
||||||
import org.apache.maven.repository.legacy.WagonManager;
|
import org.apache.maven.repository.legacy.WagonManager;
|
||||||
|
@ -34,7 +38,6 @@ import org.apache.maven.wagon.TransferFailedException;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
@ -56,6 +59,53 @@ public class DefaultRepositoryMetadataManager
|
||||||
public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||||
throws RepositoryMetadataResolutionException
|
throws RepositoryMetadataResolutionException
|
||||||
{
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
resolve( metadata, request );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resolve( RepositoryMetadata metadata, RepositoryRequest request )
|
||||||
|
throws RepositoryMetadataResolutionException
|
||||||
|
{
|
||||||
|
RepositoryCache cache = request.getCache();
|
||||||
|
|
||||||
|
CacheKey cacheKey = null;
|
||||||
|
|
||||||
|
if ( cache != null )
|
||||||
|
{
|
||||||
|
cacheKey = new CacheKey( metadata, request );
|
||||||
|
|
||||||
|
CacheRecord cacheRecord = (CacheRecord) cache.get( request, cacheKey );
|
||||||
|
|
||||||
|
if ( cacheRecord != null )
|
||||||
|
{
|
||||||
|
if ( getLogger().isDebugEnabled() )
|
||||||
|
{
|
||||||
|
getLogger().debug( "Resolved metadata from cache: " + metadata );
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata.setMetadata( MetadataUtils.cloneMetadata( cacheRecord.metadata ) );
|
||||||
|
|
||||||
|
if ( cacheRecord.repository != null )
|
||||||
|
{
|
||||||
|
for ( ArtifactRepository repository : request.getRemoteRepositories() )
|
||||||
|
{
|
||||||
|
if ( cacheRecord.repository.equals( repository.getId() ) )
|
||||||
|
{
|
||||||
|
metadata.setRepository( repository );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtifactRepository localRepository = request.getLocalRepository();
|
||||||
|
List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
|
||||||
|
|
||||||
for ( ArtifactRepository repository : remoteRepositories )
|
for ( ArtifactRepository repository : remoteRepositories )
|
||||||
{
|
{
|
||||||
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
|
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
|
||||||
|
@ -114,6 +164,133 @@ public class DefaultRepositoryMetadataManager
|
||||||
{
|
{
|
||||||
throw new RepositoryMetadataResolutionException( "Unable to read local copy of metadata: " + e.getMessage(), e );
|
throw new RepositoryMetadataResolutionException( "Unable to read local copy of metadata: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( cache != null )
|
||||||
|
{
|
||||||
|
cache.put( request, cacheKey, new CacheRecord( metadata ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class CacheKey
|
||||||
|
{
|
||||||
|
|
||||||
|
final Object metadataKey;
|
||||||
|
|
||||||
|
final ArtifactRepository localRepository;
|
||||||
|
|
||||||
|
final List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
|
final int hashCode;
|
||||||
|
|
||||||
|
CacheKey( RepositoryMetadata metadata, RepositoryRequest request )
|
||||||
|
{
|
||||||
|
metadataKey = metadata.getKey();
|
||||||
|
localRepository = request.getLocalRepository();
|
||||||
|
remoteRepositories = request.getRemoteRepositories();
|
||||||
|
|
||||||
|
int hash = 17;
|
||||||
|
hash = hash * 31 + metadata.getKey().hashCode();
|
||||||
|
hash = hash * 31 + repoHashCode( localRepository );
|
||||||
|
for ( ArtifactRepository remoteRepository : remoteRepositories )
|
||||||
|
{
|
||||||
|
hash = hash * 31 + repoHashCode( remoteRepository );
|
||||||
|
}
|
||||||
|
hashCode = hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int repoHashCode( ArtifactRepository repository )
|
||||||
|
{
|
||||||
|
return ( repository != null && repository.getUrl() != null ) ? repository.getUrl().hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean repoEquals( ArtifactRepository repo1, ArtifactRepository repo2 )
|
||||||
|
{
|
||||||
|
if ( repo1 == repo2 )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( repo1 == null || repo2 == null )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return equal( repo1.getUrl(), repo2.getUrl() ) && repo1.getClass() == repo2.getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> boolean equal( T s1, T s2 )
|
||||||
|
{
|
||||||
|
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals( Object obj )
|
||||||
|
{
|
||||||
|
if ( this == obj )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( obj instanceof CacheKey ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheKey that = (CacheKey) obj;
|
||||||
|
|
||||||
|
if ( !this.metadataKey.equals( that.metadataKey ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !repoEquals( this.localRepository, that.localRepository ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( Iterator<ArtifactRepository> it1 = this.remoteRepositories.iterator(), it2 =
|
||||||
|
that.remoteRepositories.iterator();; )
|
||||||
|
{
|
||||||
|
if ( !it1.hasNext() || !it2.hasNext() )
|
||||||
|
{
|
||||||
|
if ( it1.hasNext() != it2.hasNext() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ArtifactRepository repo1 = it1.next();
|
||||||
|
ArtifactRepository repo2 = it2.next();
|
||||||
|
if ( !repoEquals( repo1, repo2 ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class CacheRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
final Metadata metadata;
|
||||||
|
|
||||||
|
final String repository;
|
||||||
|
|
||||||
|
CacheRecord( RepositoryMetadata metadata )
|
||||||
|
{
|
||||||
|
this.metadata = MetadataUtils.cloneMetadata( metadata.getMetadata() );
|
||||||
|
this.repository = ( metadata.getRepository() != null ) ? metadata.getRepository().getId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeMetadata( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
private void mergeMetadata( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||||
|
@ -355,4 +532,5 @@ public class DefaultRepositoryMetadataManager
|
||||||
throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e );
|
throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,11 @@ public class GroupRepositoryMetadata
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactRepository getRepository()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRepository( ArtifactRepository remoteRepository )
|
public void setRepository( ArtifactRepository remoteRepository )
|
||||||
{
|
{
|
||||||
// intentionally blank
|
// intentionally blank
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package org.apache.maven.artifact.repository.metadata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assists in handling repository metadata.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
class MetadataUtils
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: Kill this class once MODELLO-191 is released
|
||||||
|
|
||||||
|
public static Metadata cloneMetadata( Metadata src )
|
||||||
|
{
|
||||||
|
if ( src == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Metadata target = new Metadata();
|
||||||
|
|
||||||
|
target.setGroupId( src.getGroupId() );
|
||||||
|
target.setArtifactId( src.getArtifactId() );
|
||||||
|
target.setVersion( src.getVersion() );
|
||||||
|
target.setVersioning( cloneVersioning( src.getVersioning() ) );
|
||||||
|
|
||||||
|
for ( Plugin plugin : src.getPlugins() )
|
||||||
|
{
|
||||||
|
target.addPlugin( clonePlugin( plugin ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Plugin clonePlugin( Plugin src )
|
||||||
|
{
|
||||||
|
if ( src == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugin target = new Plugin();
|
||||||
|
|
||||||
|
target.setArtifactId( src.getArtifactId() );
|
||||||
|
target.setName( src.getName() );
|
||||||
|
target.setPrefix( src.getPrefix() );
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Versioning cloneVersioning( Versioning src )
|
||||||
|
{
|
||||||
|
if ( src == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Versioning target = new Versioning();
|
||||||
|
|
||||||
|
target.setLastUpdated( src.getLastUpdated() );
|
||||||
|
target.setLatest( src.getLatest() );
|
||||||
|
target.setRelease( src.getRelease() );
|
||||||
|
target.setSnapshot( cloneSnapshot( src.getSnapshot() ) );
|
||||||
|
target.setVersions( new ArrayList<String>( src.getVersions() ) );
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snapshot cloneSnapshot( Snapshot src )
|
||||||
|
{
|
||||||
|
if ( src == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Snapshot target = new Snapshot();
|
||||||
|
|
||||||
|
target.setBuildNumber( src.getBuildNumber() );
|
||||||
|
target.setLocalCopy( src.isLocalCopy() );
|
||||||
|
target.setTimestamp( src.getTimestamp() );
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,13 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
public interface RepositoryMetadata
|
public interface RepositoryMetadata
|
||||||
extends org.apache.maven.artifact.metadata.ArtifactMetadata
|
extends org.apache.maven.artifact.metadata.ArtifactMetadata
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get the repository the metadata was located in.
|
||||||
|
*
|
||||||
|
* @return the repository
|
||||||
|
*/
|
||||||
|
ArtifactRepository getRepository();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the repository the metadata was located in.
|
* Set the repository the metadata was located in.
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,9 +23,14 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
|
|
||||||
public interface RepositoryMetadataManager
|
public interface RepositoryMetadataManager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void resolve( RepositoryMetadata repositoryMetadata, RepositoryRequest repositoryRequest )
|
||||||
|
throws RepositoryMetadataResolutionException;
|
||||||
|
|
||||||
void resolve( RepositoryMetadata repositoryMetadata, List<ArtifactRepository> repositories, ArtifactRepository localRepository )
|
void resolve( RepositoryMetadata repositoryMetadata, List<ArtifactRepository> repositories, ArtifactRepository localRepository )
|
||||||
throws RepositoryMetadataResolutionException;
|
throws RepositoryMetadataResolutionException;
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,11 @@ public class SnapshotArtifactRepositoryMetadata
|
||||||
return artifact.isSnapshot();
|
return artifact.isSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactRepository getRepository()
|
||||||
|
{
|
||||||
|
return artifact.getRepository();
|
||||||
|
}
|
||||||
|
|
||||||
public void setRepository( ArtifactRepository remoteRepository )
|
public void setRepository( ArtifactRepository remoteRepository )
|
||||||
{
|
{
|
||||||
artifact.setRepository( remoteRepository );
|
artifact.setRepository( remoteRepository );
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.wagon.events.TransferListener;
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
|
|
||||||
|
@ -36,7 +38,9 @@ import org.apache.maven.wagon.events.TransferListener;
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
*/
|
*/
|
||||||
public class ArtifactResolutionRequest
|
public class ArtifactResolutionRequest
|
||||||
|
implements RepositoryRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
private Artifact artifact;
|
private Artifact artifact;
|
||||||
|
|
||||||
// Needs to go away
|
// Needs to go away
|
||||||
|
@ -48,6 +52,8 @@ public class ArtifactResolutionRequest
|
||||||
|
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
|
private RepositoryCache cache;
|
||||||
|
|
||||||
private ArtifactFilter filter;
|
private ArtifactFilter filter;
|
||||||
|
|
||||||
// Needs to go away
|
// Needs to go away
|
||||||
|
@ -61,12 +67,19 @@ public class ArtifactResolutionRequest
|
||||||
private boolean resolveRoot = true;
|
private boolean resolveRoot = true;
|
||||||
|
|
||||||
private boolean resolveTransitively = false;
|
private boolean resolveTransitively = false;
|
||||||
|
|
||||||
public ArtifactResolutionRequest( )
|
public ArtifactResolutionRequest()
|
||||||
{
|
{
|
||||||
// nothing here
|
// nothing here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionRequest( RepositoryRequest request )
|
||||||
|
{
|
||||||
|
setLocalRepository( request.getLocalRepository() );
|
||||||
|
setRemoteRepositories( request.getRemoteRepositories() );
|
||||||
|
setCache( request.getCache() );
|
||||||
|
}
|
||||||
|
|
||||||
public Artifact getArtifact()
|
public Artifact getArtifact()
|
||||||
{
|
{
|
||||||
return artifact;
|
return artifact;
|
||||||
|
@ -204,4 +217,17 @@ public class ArtifactResolutionRequest
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getCache()
|
||||||
|
{
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionRequest setCache( RepositoryCache cache )
|
||||||
|
{
|
||||||
|
this.cache = cache;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
||||||
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
||||||
|
@ -86,16 +88,22 @@ public class DefaultArtifactResolver
|
||||||
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
|
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository, resolutionListener, false );
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
resolve( artifact, request, resolutionListener, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository, null, true );
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
resolve( artifact, request, null, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor, boolean force )
|
private void resolve( Artifact artifact, RepositoryRequest request, TransferListener downloadMonitor, boolean force )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
if ( artifact == null )
|
if ( artifact == null )
|
||||||
|
@ -128,7 +136,11 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArtifactRepository localRepository = request.getLocalRepository();
|
||||||
|
|
||||||
|
List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
|
||||||
|
|
||||||
if ( !artifact.isResolved() )
|
if ( !artifact.isResolved() )
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -144,7 +156,7 @@ public class DefaultArtifactResolver
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
|
transformationManager.transformForResolve( artifact, request );
|
||||||
|
|
||||||
boolean localCopy = isLocalCopy( artifact );
|
boolean localCopy = isLocalCopy( artifact );
|
||||||
|
|
||||||
|
@ -358,8 +370,6 @@ public class DefaultArtifactResolver
|
||||||
Artifact rootArtifact = request.getArtifact();
|
Artifact rootArtifact = request.getArtifact();
|
||||||
Set<Artifact> artifacts = request.getArtifactDependencies();
|
Set<Artifact> artifacts = request.getArtifactDependencies();
|
||||||
Map managedVersions = request.getManagedVersionMap();
|
Map managedVersions = request.getManagedVersionMap();
|
||||||
ArtifactRepository localRepository = request.getLocalRepository();
|
|
||||||
List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
|
|
||||||
List<ResolutionListener> listeners = request.getListeners();
|
List<ResolutionListener> listeners = request.getListeners();
|
||||||
ArtifactFilter filter = request.getFilter();
|
ArtifactFilter filter = request.getFilter();
|
||||||
|
|
||||||
|
@ -399,7 +409,7 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resolve( rootArtifact, remoteRepositories, localRepository );
|
resolve( rootArtifact, request, request.getTransferListener(), false );
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( ArtifactResolutionException e )
|
||||||
{
|
{
|
||||||
|
@ -415,11 +425,9 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
if ( request.isResolveTransitively() )
|
if ( request.isResolveTransitively() )
|
||||||
{
|
{
|
||||||
MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest();
|
MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( request );
|
||||||
|
|
||||||
metadataRequest.setArtifact( rootArtifact );
|
metadataRequest.setArtifact( rootArtifact );
|
||||||
metadataRequest.setLocalRepository( localRepository );
|
|
||||||
metadataRequest.setRemoteRepositories( remoteRepositories );
|
|
||||||
metadataRequest.setResolveManagedVersions( managedVersions == null );
|
metadataRequest.setResolveManagedVersions( managedVersions == null );
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -473,7 +481,7 @@ public class DefaultArtifactResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
// After the collection we will have the artifact object in the result but they will not be resolved yet.
|
// After the collection we will have the artifact object in the result but they will not be resolved yet.
|
||||||
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null );
|
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, request, source, filter, listeners, null );
|
||||||
|
|
||||||
// We have metadata retrieval problems, or there are cycles that have been detected
|
// We have metadata retrieval problems, or there are cycles that have been detected
|
||||||
// so we give this back to the calling code and let them deal with this information
|
// so we give this back to the calling code and let them deal with this information
|
||||||
|
@ -490,7 +498,7 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository, request.getTransferListener() );
|
resolve( artifact, request, request.getTransferListener(), false );
|
||||||
}
|
}
|
||||||
catch ( ArtifactNotFoundException anfe )
|
catch ( ArtifactNotFoundException anfe )
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a request to retrieve artifact metadata.
|
* Forms a request to retrieve artifact metadata.
|
||||||
|
@ -39,8 +41,22 @@ public class DefaultMetadataResolutionRequest
|
||||||
|
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
|
private RepositoryCache cache;
|
||||||
|
|
||||||
private boolean resolveManagedVersions;
|
private boolean resolveManagedVersions;
|
||||||
|
|
||||||
|
public DefaultMetadataResolutionRequest()
|
||||||
|
{
|
||||||
|
// does nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultMetadataResolutionRequest( RepositoryRequest request )
|
||||||
|
{
|
||||||
|
setLocalRepository( request.getLocalRepository() );
|
||||||
|
setRemoteRepositories( request.getRemoteRepositories() );
|
||||||
|
setCache( request.getCache() );
|
||||||
|
}
|
||||||
|
|
||||||
public Artifact getArtifact()
|
public Artifact getArtifact()
|
||||||
{
|
{
|
||||||
return artifact;
|
return artifact;
|
||||||
|
@ -88,4 +104,16 @@ public class DefaultMetadataResolutionRequest
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getCache()
|
||||||
|
{
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataResolutionRequest setCache( RepositoryCache cache )
|
||||||
|
{
|
||||||
|
this.cache = cache;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a request to retrieve artifact metadata.
|
* Forms a request to retrieve artifact metadata.
|
||||||
|
@ -30,6 +31,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
*/
|
*/
|
||||||
public interface MetadataResolutionRequest
|
public interface MetadataResolutionRequest
|
||||||
|
extends RepositoryRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,6 +32,8 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.CyclicDependencyException;
|
import org.apache.maven.artifact.resolver.CyclicDependencyException;
|
||||||
|
@ -45,6 +47,8 @@ import org.apache.maven.artifact.versioning.ManagedVersionMap;
|
||||||
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
|
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException;
|
||||||
|
import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
|
||||||
|
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
|
||||||
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
|
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
|
@ -73,6 +77,22 @@ public class DefaultLegacyArtifactCollector
|
||||||
ArtifactFilter filter,
|
ArtifactFilter filter,
|
||||||
List<ResolutionListener> listeners,
|
List<ResolutionListener> listeners,
|
||||||
List<ConflictResolver> conflictResolvers )
|
List<ConflictResolver> conflictResolvers )
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
|
||||||
|
conflictResolvers );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
||||||
|
Artifact originatingArtifact,
|
||||||
|
Map managedVersions,
|
||||||
|
RepositoryRequest repositoryRequest,
|
||||||
|
ArtifactMetadataSource source,
|
||||||
|
ArtifactFilter filter,
|
||||||
|
List<ResolutionListener> listeners,
|
||||||
|
List<ConflictResolver> conflictResolvers )
|
||||||
{
|
{
|
||||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||||
|
|
||||||
|
@ -85,11 +105,11 @@ public class DefaultLegacyArtifactCollector
|
||||||
|
|
||||||
Map<Object, List<ResolutionNode>> resolvedArtifacts = new LinkedHashMap<Object, List<ResolutionNode>>();
|
Map<Object, List<ResolutionNode>> resolvedArtifacts = new LinkedHashMap<Object, List<ResolutionNode>>();
|
||||||
|
|
||||||
ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
|
ResolutionNode root = new ResolutionNode( originatingArtifact, repositoryRequest.getRemoteRepositories() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
root.addDependencies( artifacts, remoteRepositories, filter );
|
root.addDependencies( artifacts, repositoryRequest.getRemoteRepositories(), filter );
|
||||||
}
|
}
|
||||||
catch ( CyclicDependencyException e )
|
catch ( CyclicDependencyException e )
|
||||||
{
|
{
|
||||||
|
@ -108,7 +128,7 @@ public class DefaultLegacyArtifactCollector
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
recurse( result, root, resolvedArtifacts, versionMap, localRepository, remoteRepositories, source, filter, listeners, conflictResolvers );
|
recurse( result, root, resolvedArtifacts, versionMap, repositoryRequest, source, filter, listeners, conflictResolvers );
|
||||||
}
|
}
|
||||||
catch ( CyclicDependencyException e )
|
catch ( CyclicDependencyException e )
|
||||||
{
|
{
|
||||||
|
@ -205,8 +225,7 @@ public class DefaultLegacyArtifactCollector
|
||||||
ResolutionNode node,
|
ResolutionNode node,
|
||||||
Map<Object, List<ResolutionNode>> resolvedArtifacts,
|
Map<Object, List<ResolutionNode>> resolvedArtifacts,
|
||||||
ManagedVersionMap managedVersions,
|
ManagedVersionMap managedVersions,
|
||||||
ArtifactRepository localRepository,
|
RepositoryRequest request,
|
||||||
List<ArtifactRepository> remoteRepositories,
|
|
||||||
ArtifactMetadataSource source,
|
ArtifactMetadataSource source,
|
||||||
ArtifactFilter filter,
|
ArtifactFilter filter,
|
||||||
List<ResolutionListener> listeners,
|
List<ResolutionListener> listeners,
|
||||||
|
@ -275,13 +294,16 @@ public class DefaultLegacyArtifactCollector
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
versions = source.retrieveAvailableVersions( resetArtifact, localRepository, remoteRepositories );
|
MetadataResolutionRequest metadataRequest =
|
||||||
|
new DefaultMetadataResolutionRequest( request );
|
||||||
|
metadataRequest.setArtifact( resetArtifact );
|
||||||
|
versions = source.retrieveAvailableVersions( metadataRequest );
|
||||||
resetArtifact.setAvailableVersions( versions );
|
resetArtifact.setAvailableVersions( versions );
|
||||||
}
|
}
|
||||||
catch ( ArtifactMetadataRetrievalException e )
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
{
|
{
|
||||||
resetArtifact.setDependencyTrail( node.getDependencyTrail() );
|
resetArtifact.setDependencyTrail( node.getDependencyTrail() );
|
||||||
throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), resetArtifact, remoteRepositories, e );
|
throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), resetArtifact, request.getRemoteRepositories(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// end hack
|
// end hack
|
||||||
|
@ -398,6 +420,11 @@ public class DefaultLegacyArtifactCollector
|
||||||
artifact.setDependencyTrail( node.getDependencyTrail() );
|
artifact.setDependencyTrail( node.getDependencyTrail() );
|
||||||
List<ArtifactRepository> childRemoteRepositories = child.getRemoteRepositories();
|
List<ArtifactRepository> childRemoteRepositories = child.getRemoteRepositories();
|
||||||
|
|
||||||
|
MetadataResolutionRequest metadataRequest =
|
||||||
|
new DefaultMetadataResolutionRequest( request );
|
||||||
|
metadataRequest.setArtifact( artifact );
|
||||||
|
metadataRequest.setRemoteRepositories( childRemoteRepositories );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ResolutionGroup rGroup;
|
ResolutionGroup rGroup;
|
||||||
|
@ -449,7 +476,7 @@ public class DefaultLegacyArtifactCollector
|
||||||
List<ArtifactVersion> versions = artifact.getAvailableVersions();
|
List<ArtifactVersion> versions = artifact.getAvailableVersions();
|
||||||
if ( versions == null )
|
if ( versions == null )
|
||||||
{
|
{
|
||||||
versions = source.retrieveAvailableVersions( artifact, localRepository, childRemoteRepositories );
|
versions = source.retrieveAvailableVersions( metadataRequest );
|
||||||
artifact.setAvailableVersions( versions );
|
artifact.setAvailableVersions( versions );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +510,7 @@ public class DefaultLegacyArtifactCollector
|
||||||
fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child );
|
fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child );
|
||||||
}
|
}
|
||||||
|
|
||||||
rGroup = source.retrieve( artifact, localRepository, childRemoteRepositories );
|
rGroup = source.retrieve( metadataRequest );
|
||||||
|
|
||||||
if ( rGroup == null )
|
if ( rGroup == null )
|
||||||
{
|
{
|
||||||
|
@ -496,6 +523,7 @@ public class DefaultLegacyArtifactCollector
|
||||||
relocated.setDependencyFilter( artifact.getDependencyFilter() );
|
relocated.setDependencyFilter( artifact.getDependencyFilter() );
|
||||||
artifact = relocated;
|
artifact = relocated;
|
||||||
child.setArtifact( artifact );
|
child.setArtifact( artifact );
|
||||||
|
metadataRequest.setArtifact( artifact );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( !childKey.equals( child.getKey() ) );
|
while( !childKey.equals( child.getKey() ) );
|
||||||
|
@ -539,8 +567,8 @@ public class DefaultLegacyArtifactCollector
|
||||||
+ e.getMessage(), artifact, childRemoteRepositories, e );
|
+ e.getMessage(), artifact, childRemoteRepositories, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
recurse( result, child, resolvedArtifacts, managedVersions, localRepository,
|
recurse( result, child, resolvedArtifacts, managedVersions, metadataRequest, source, filter,
|
||||||
childRemoteRepositories, source, filter, listeners, conflictResolvers );
|
listeners, conflictResolvers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( OverConstrainedVersionException e )
|
catch ( OverConstrainedVersionException e )
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.ResolutionListener;
|
import org.apache.maven.artifact.resolver.ResolutionListener;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
@ -42,6 +43,15 @@ import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
|
||||||
public interface LegacyArtifactCollector
|
public interface LegacyArtifactCollector
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
||||||
|
Artifact originatingArtifact,
|
||||||
|
Map managedVersions,
|
||||||
|
RepositoryRequest repositoryRequest,
|
||||||
|
ArtifactMetadataSource source,
|
||||||
|
ArtifactFilter filter,
|
||||||
|
List<ResolutionListener> listeners,
|
||||||
|
List<ConflictResolver> conflictResolvers );
|
||||||
|
|
||||||
ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
ArtifactResolutionResult collect( Set<Artifact> artifacts,
|
||||||
Artifact originatingArtifact,
|
Artifact originatingArtifact,
|
||||||
Map managedVersions,
|
Map managedVersions,
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||||
|
@ -30,6 +32,8 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
|
||||||
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.Versioning;
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.repository.legacy.WagonManager;
|
import org.apache.maven.repository.legacy.WagonManager;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
@ -51,7 +55,23 @@ public abstract class AbstractVersionTransformation
|
||||||
@Requirement
|
@Requirement
|
||||||
protected WagonManager wagonManager;
|
protected WagonManager wagonManager;
|
||||||
|
|
||||||
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public void transformForResolve( Artifact artifact, RepositoryRequest request )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
|
{
|
||||||
|
transformForResolve( artifact, request.getRemoteRepositories(), request.getLocalRepository() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository,
|
||||||
|
List<ArtifactRepository> remoteRepositories )
|
||||||
|
throws RepositoryMetadataResolutionException
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
return resolveVersion( artifact, request );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String resolveVersion( Artifact artifact, RepositoryRequest request )
|
||||||
throws RepositoryMetadataResolutionException
|
throws RepositoryMetadataResolutionException
|
||||||
{
|
{
|
||||||
RepositoryMetadata metadata;
|
RepositoryMetadata metadata;
|
||||||
|
@ -65,7 +85,7 @@ public abstract class AbstractVersionTransformation
|
||||||
metadata = new SnapshotArtifactRepositoryMetadata( artifact );
|
metadata = new SnapshotArtifactRepositoryMetadata( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
|
repositoryMetadataManager.resolve( metadata, request );
|
||||||
|
|
||||||
artifact.addMetadata( metadata );
|
artifact.addMetadata( metadata );
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
|
|
||||||
|
@ -37,6 +38,17 @@ public interface ArtifactTransformation
|
||||||
{
|
{
|
||||||
String ROLE = ArtifactTransformation.class.getName();
|
String ROLE = ArtifactTransformation.class.getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
||||||
|
* transformation has occured the original artifact is returned.
|
||||||
|
*
|
||||||
|
* @param artifact Artifact to be transformed.
|
||||||
|
* @param request the repositories to check
|
||||||
|
* @param localRepository the local repository
|
||||||
|
*/
|
||||||
|
void transformForResolve( Artifact artifact, RepositoryRequest request )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
||||||
* transformation has occured the original artifact is returned.
|
* transformation has occured the original artifact is returned.
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
|
|
||||||
|
@ -33,6 +34,17 @@ public interface ArtifactTransformationManager
|
||||||
{
|
{
|
||||||
String ROLE = ArtifactTransformationManager.class.getName();
|
String ROLE = ArtifactTransformationManager.class.getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
||||||
|
* transformation has occured the original artifact is returned.
|
||||||
|
*
|
||||||
|
* @param artifact Artifact to be transformed.
|
||||||
|
* @param request the repositories to check
|
||||||
|
* @param localRepository the local repository
|
||||||
|
*/
|
||||||
|
void transformForResolve( Artifact artifact, RepositoryRequest request )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
||||||
* transformation has occured the original artifact is returned.
|
* transformation has occured the original artifact is returned.
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
@ -40,6 +41,15 @@ public class DefaultArtifactTransformationManager
|
||||||
@Requirement(role=ArtifactTransformation.class, hints={"release", "latest", "snapshot"})
|
@Requirement(role=ArtifactTransformation.class, hints={"release", "latest", "snapshot"})
|
||||||
private List<ArtifactTransformation> artifactTransformations;
|
private List<ArtifactTransformation> artifactTransformations;
|
||||||
|
|
||||||
|
public void transformForResolve( Artifact artifact, RepositoryRequest request )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
|
{
|
||||||
|
for ( ArtifactTransformation transform : artifactTransformations )
|
||||||
|
{
|
||||||
|
transform.transformForResolve( artifact, request );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void transformForResolve( Artifact artifact,
|
public void transformForResolve( Artifact artifact,
|
||||||
List<ArtifactRepository> remoteRepositories,
|
List<ArtifactRepository> remoteRepositories,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
|
|
|
@ -28,12 +28,15 @@ import java.util.TimeZone;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
|
||||||
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
||||||
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.Versioning;
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
@ -53,8 +56,17 @@ public class SnapshotTransformation
|
||||||
|
|
||||||
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
|
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
|
||||||
|
|
||||||
|
public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
transformForResolve( artifact, request );
|
||||||
|
}
|
||||||
|
|
||||||
public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
public void transformForResolve( Artifact artifact, RepositoryRequest request )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
// Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456)
|
// Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456)
|
||||||
|
@ -62,8 +74,8 @@ public class SnapshotTransformation
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String version = resolveVersion( artifact, localRepository, remoteRepositories );
|
String version = resolveVersion( artifact, request );
|
||||||
artifact.updateVersion( version, localRepository );
|
artifact.updateVersion( version, request.getLocalRepository() );
|
||||||
}
|
}
|
||||||
catch ( RepositoryMetadataResolutionException e )
|
catch ( RepositoryMetadataResolutionException e )
|
||||||
{
|
{
|
||||||
|
@ -173,4 +185,5 @@ public class SnapshotTransformation
|
||||||
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
|
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
|
||||||
return utcDateFormatter;
|
return utcDateFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,4 +75,10 @@ public class TestMetadataSource
|
||||||
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,12 @@ public class ArtifactResolverTest
|
||||||
{
|
{
|
||||||
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ArtifactResolutionResult result = null;
|
ArtifactResolutionResult result = null;
|
||||||
|
|
|
@ -974,5 +974,11 @@ public class DefaultArtifactCollectorTest
|
||||||
{
|
{
|
||||||
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package org.apache.maven;
|
package org.apache.maven;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
|
@ -30,7 +29,7 @@ public class DefaultProjectDependenciesResolver
|
||||||
@Requirement
|
@Requirement
|
||||||
private ResolutionErrorHandler resolutionErrorHandler;
|
private ResolutionErrorHandler resolutionErrorHandler;
|
||||||
|
|
||||||
public Set<Artifact> resolve( MavenProject project, Collection<String> scopes, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public Set<Artifact> resolve( MavenProject project, Collection<String> scopes, RepositoryRequest repositoryRequest )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -73,12 +72,10 @@ public class DefaultProjectDependenciesResolver
|
||||||
|
|
||||||
ArtifactFilter filter = scopeFilter;
|
ArtifactFilter filter = scopeFilter;
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest )
|
||||||
.setArtifact( new ProjectArtifact( project ) )
|
.setArtifact( new ProjectArtifact( project ) )
|
||||||
.setResolveRoot( false )
|
.setResolveRoot( false )
|
||||||
.setResolveTransitively( true )
|
.setResolveTransitively( true )
|
||||||
.setLocalRepository( localRepository )
|
|
||||||
.setRemoteRepositories( remoteRepositories )
|
|
||||||
.setManagedVersionMap( project.getManagedVersionMap() )
|
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||||
.setFilter( filter );
|
.setFilter( filter );
|
||||||
// FIXME setTransferListener
|
// FIXME setTransferListener
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package org.apache.maven;
|
package org.apache.maven;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
|
||||||
public interface ProjectDependenciesResolver
|
public interface ProjectDependenciesResolver
|
||||||
{
|
{
|
||||||
public Set<Artifact> resolve( MavenProject project, Collection<String> scopes, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public Set<Artifact> resolve( MavenProject project, Collection<String> scopes, RepositoryRequest repositoryRequest )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException;
|
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||||
import org.apache.maven.project.ProjectBuildingRequest;
|
import org.apache.maven.project.ProjectBuildingRequest;
|
||||||
|
@ -35,6 +36,8 @@ public class DefaultMavenExecutionRequest
|
||||||
implements MavenExecutionRequest
|
implements MavenExecutionRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private RepositoryCache repositoryCache = new SessionRepositoryCache();
|
||||||
|
|
||||||
private ArtifactRepository localRepository;
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
private File localRepositoryPath;
|
private File localRepositoryPath;
|
||||||
|
@ -156,6 +159,7 @@ public class DefaultMavenExecutionRequest
|
||||||
copy.setUpdateSnapshots( original.isUpdateSnapshots() );
|
copy.setUpdateSnapshots( original.isUpdateSnapshots() );
|
||||||
copy.setRemoteRepositories( original.getRemoteRepositories() );
|
copy.setRemoteRepositories( original.getRemoteRepositories() );
|
||||||
copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
|
copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
|
||||||
|
copy.setRepositoryCache( original.getRepositoryCache() );
|
||||||
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
|
copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
@ -893,6 +897,7 @@ public class DefaultMavenExecutionRequest
|
||||||
projectBuildingRequest.setUserProperties( getUserProperties() );
|
projectBuildingRequest.setUserProperties( getUserProperties() );
|
||||||
projectBuildingRequest.setRemoteRepositories( getRemoteRepositories() );
|
projectBuildingRequest.setRemoteRepositories( getRemoteRepositories() );
|
||||||
projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories() );
|
projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories() );
|
||||||
|
projectBuildingRequest.setRepositoryCache( getRepositoryCache() );
|
||||||
projectBuildingRequest.setActiveProfileIds( getActiveProfiles() );
|
projectBuildingRequest.setActiveProfileIds( getActiveProfiles() );
|
||||||
projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() );
|
projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() );
|
||||||
projectBuildingRequest.setProfiles( getProfiles() );
|
projectBuildingRequest.setProfiles( getProfiles() );
|
||||||
|
@ -923,4 +928,16 @@ public class DefaultMavenExecutionRequest
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getRepositoryCache()
|
||||||
|
{
|
||||||
|
return repositoryCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache )
|
||||||
|
{
|
||||||
|
this.repositoryCache = repositoryCache;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.project.ProjectBuildingRequest;
|
import org.apache.maven.project.ProjectBuildingRequest;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
|
@ -256,6 +257,9 @@ public interface MavenExecutionRequest
|
||||||
MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> repositories );
|
MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> repositories );
|
||||||
List<ArtifactRepository> getPluginArtifactRepositories();
|
List<ArtifactRepository> getPluginArtifactRepositories();
|
||||||
|
|
||||||
|
MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache );
|
||||||
|
RepositoryCache getRepositoryCache();
|
||||||
|
|
||||||
File getUserToolchainsFile();
|
File getUserToolchainsFile();
|
||||||
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.ProjectBuildingRequest;
|
import org.apache.maven.project.ProjectBuildingRequest;
|
||||||
|
@ -101,6 +102,11 @@ public class MavenSession
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getRepositoryCache()
|
||||||
|
{
|
||||||
|
return request.getRepositoryCache();
|
||||||
|
}
|
||||||
|
|
||||||
public ArtifactRepository getLocalRepository()
|
public ArtifactRepository getLocalRepository()
|
||||||
{
|
{
|
||||||
return request.getLocalRepository();
|
return request.getLocalRepository();
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.apache.maven.execution;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a simple repository cache whose lifetime is scoped to a single Maven session.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
class SessionRepositoryCache
|
||||||
|
implements RepositoryCache
|
||||||
|
{
|
||||||
|
|
||||||
|
private Map<Object, Object> cache = new HashMap<Object, Object>( 256 );
|
||||||
|
|
||||||
|
public Object get( RepositoryRequest request, Object key )
|
||||||
|
{
|
||||||
|
return cache.get( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put( RepositoryRequest request, Object key, Object data )
|
||||||
|
{
|
||||||
|
cache.put( key, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,8 @@ import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.maven.ProjectDependenciesResolver;
|
import org.apache.maven.ProjectDependenciesResolver;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataReadException;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataReadException;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
|
@ -154,6 +156,10 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
MavenExecutionResult result = session.getResult();
|
MavenExecutionResult result = session.getResult();
|
||||||
|
|
||||||
|
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
|
||||||
|
repositoryRequest.setLocalRepository( session.getLocalRepository() );
|
||||||
|
repositoryRequest.setCache( session.getRepositoryCache() );
|
||||||
|
|
||||||
for ( MavenProject currentProject : session.getProjects() )
|
for ( MavenProject currentProject : session.getProjects() )
|
||||||
{
|
{
|
||||||
if ( session.isBlackListed( currentProject ) )
|
if ( session.isBlackListed( currentProject ) )
|
||||||
|
@ -185,7 +191,8 @@ public class DefaultLifecycleExecutor
|
||||||
// the project dependencies. Having it happen in the plugin manager is a tangled mess. We can optimize this
|
// the project dependencies. Having it happen in the plugin manager is a tangled mess. We can optimize this
|
||||||
// later by looking at the build plan. Would be better to just batch download everything required by the reactor.
|
// later by looking at the build plan. Would be better to just batch download everything required by the reactor.
|
||||||
|
|
||||||
projectDependenciesResolver.resolve( currentProject, executionPlan.getRequiredResolutionScopes(), session.getLocalRepository(), currentProject.getRemoteArtifactRepositories() );
|
repositoryRequest.setRemoteRepositories( currentProject.getRemoteArtifactRepositories() );
|
||||||
|
projectDependenciesResolver.resolve( currentProject, executionPlan.getRequiredResolutionScopes(), repositoryRequest );
|
||||||
|
|
||||||
if ( logger.isDebugEnabled() )
|
if ( logger.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
|
@ -330,8 +337,7 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
mojoDescriptor =
|
mojoDescriptor =
|
||||||
pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
|
pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
|
||||||
session.getLocalRepository(),
|
getRepositoryRequest( session, project ) );
|
||||||
project.getPluginArtifactRepositories() );
|
|
||||||
|
|
||||||
mojoExecution.setMojoDescriptor( mojoDescriptor );
|
mojoExecution.setMojoDescriptor( mojoDescriptor );
|
||||||
}
|
}
|
||||||
|
@ -354,6 +360,16 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
return new MavenExecutionPlan( lifecyclePlan, requiredDependencyResolutionScopes );
|
return new MavenExecutionPlan( lifecyclePlan, requiredDependencyResolutionScopes );
|
||||||
}
|
}
|
||||||
|
private RepositoryRequest getRepositoryRequest( MavenSession session, MavenProject project )
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
|
||||||
|
request.setCache( session.getRepositoryCache() );
|
||||||
|
request.setLocalRepository( session.getLocalRepository() );
|
||||||
|
request.setRemoteRepositories( project.getPluginArtifactRepositories() );
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
private void collectDependencyResolutionScopes( Collection<String> requiredDependencyResolutionScopes,
|
private void collectDependencyResolutionScopes( Collection<String> requiredDependencyResolutionScopes,
|
||||||
MojoExecution mojoExecution )
|
MojoExecution mojoExecution )
|
||||||
|
@ -511,8 +527,7 @@ public class DefaultLifecycleExecutor
|
||||||
for ( String goal : execution.getGoals() )
|
for ( String goal : execution.getGoals() )
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor =
|
MojoDescriptor mojoDescriptor =
|
||||||
pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(),
|
pluginManager.getMojoDescriptor( plugin, goal, getRepositoryRequest( session, project ) );
|
||||||
project.getPluginArtifactRepositories() );
|
|
||||||
|
|
||||||
List<MojoExecution> mojoExecutions = lifecycleMappings.get( mojoDescriptor.getPhase() );
|
List<MojoExecution> mojoExecutions = lifecycleMappings.get( mojoDescriptor.getPhase() );
|
||||||
if ( mojoExecutions != null )
|
if ( mojoExecutions != null )
|
||||||
|
@ -557,8 +572,7 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
MojoDescriptor forkedMojoDescriptor =
|
MojoDescriptor forkedMojoDescriptor =
|
||||||
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(),
|
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(),
|
||||||
session.getLocalRepository(),
|
getRepositoryRequest( session, project ) );
|
||||||
project.getPluginArtifactRepositories() );
|
|
||||||
|
|
||||||
forkedExecution.setMojoDescriptor( forkedMojoDescriptor );
|
forkedExecution.setMojoDescriptor( forkedMojoDescriptor );
|
||||||
}
|
}
|
||||||
|
@ -875,20 +889,24 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
injectPluginDeclarationFromProject( plugin, project );
|
injectPluginDeclarationFromProject( plugin, project );
|
||||||
|
|
||||||
|
RepositoryRequest repositoryRequest = getRepositoryRequest( session, project );
|
||||||
|
|
||||||
// If there is no version to be found then we need to look in the repository metadata for
|
// If there is no version to be found then we need to look in the repository metadata for
|
||||||
// this plugin and see what's specified as the latest release.
|
// this plugin and see what's specified as the latest release.
|
||||||
//
|
//
|
||||||
if ( plugin.getVersion() == null )
|
if ( plugin.getVersion() == null )
|
||||||
{
|
{
|
||||||
resolvePluginVersion( plugin, session.getLocalRepository(), project.getPluginArtifactRepositories() );
|
resolvePluginVersion( plugin, repositoryRequest );
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), project.getPluginArtifactRepositories() );
|
return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolvePluginVersion( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException
|
throws PluginNotFoundException
|
||||||
{
|
{
|
||||||
|
ArtifactRepository localRepository = repositoryRequest.getLocalRepository();
|
||||||
|
|
||||||
File artifactMetadataFile = null;
|
File artifactMetadataFile = null;
|
||||||
|
|
||||||
String localPath;
|
String localPath;
|
||||||
|
@ -899,7 +917,7 @@ public class DefaultLifecycleExecutor
|
||||||
//
|
//
|
||||||
//TODO: we should cycle through the repositories but take the repository which actually
|
//TODO: we should cycle through the repositories but take the repository which actually
|
||||||
// satisfied the prefix.
|
// satisfied the prefix.
|
||||||
for ( ArtifactRepository repository : remoteRepositories )
|
for ( ArtifactRepository repository : repositoryRequest.getRemoteRepositories() )
|
||||||
{
|
{
|
||||||
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + repository.getId() + ".xml";
|
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + repository.getId() + ".xml";
|
||||||
|
|
||||||
|
@ -974,7 +992,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( plugin.getVersion() ) )
|
if ( StringUtils.isEmpty( plugin.getVersion() ) )
|
||||||
{
|
{
|
||||||
throw new PluginNotFoundException( plugin, remoteRepositories );
|
throw new PluginNotFoundException( plugin, repositoryRequest.getRemoteRepositories() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,14 +1143,14 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateDefaultConfigurationForPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
private void populateDefaultConfigurationForPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
|
||||||
throws LifecycleExecutionException
|
throws LifecycleExecutionException
|
||||||
{
|
{
|
||||||
if ( plugin.getVersion() == null )
|
if ( plugin.getVersion() == null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resolvePluginVersion( plugin, localRepository, remoteRepositories );
|
resolvePluginVersion( plugin, repositoryRequest );
|
||||||
}
|
}
|
||||||
catch ( PluginNotFoundException e )
|
catch ( PluginNotFoundException e )
|
||||||
{
|
{
|
||||||
|
@ -1144,29 +1162,29 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
for( String goal : pluginExecution.getGoals() )
|
for( String goal : pluginExecution.getGoals() )
|
||||||
{
|
{
|
||||||
Xpp3Dom dom = getDefaultPluginConfiguration( plugin, goal, localRepository, remoteRepositories );
|
Xpp3Dom dom = getDefaultPluginConfiguration( plugin, goal, repositoryRequest );
|
||||||
pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(), dom, Boolean.TRUE ) );
|
pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(), dom, Boolean.TRUE ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest )
|
||||||
throws LifecycleExecutionException
|
throws LifecycleExecutionException
|
||||||
{
|
{
|
||||||
for( Plugin plugin : plugins )
|
for( Plugin plugin : plugins )
|
||||||
{
|
{
|
||||||
populateDefaultConfigurationForPlugin( plugin, localRepository, remoteRepositories );
|
populateDefaultConfigurationForPlugin( plugin, repositoryRequest );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Xpp3Dom getDefaultPluginConfiguration( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
private Xpp3Dom getDefaultPluginConfiguration( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
|
||||||
throws LifecycleExecutionException
|
throws LifecycleExecutionException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor;
|
MojoDescriptor mojoDescriptor;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, remoteRepositories );
|
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
|
||||||
}
|
}
|
||||||
catch ( PluginNotFoundException e )
|
catch ( PluginNotFoundException e )
|
||||||
{
|
{
|
||||||
|
@ -1252,13 +1270,13 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
if ( project != null )
|
if ( project != null )
|
||||||
{
|
{
|
||||||
|
RepositoryRequest repositoryRequest = getRepositoryRequest( session, project );
|
||||||
|
|
||||||
for ( Plugin buildPlugin : project.getBuildPlugins() )
|
for ( Plugin buildPlugin : project.getBuildPlugins() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor =
|
PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( buildPlugin, repositoryRequest );
|
||||||
pluginManager.loadPlugin( buildPlugin, session.getLocalRepository(),
|
|
||||||
project.getPluginArtifactRepositories() );
|
|
||||||
|
|
||||||
if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
|
if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
|
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
|
||||||
|
@ -72,7 +73,7 @@ public interface LifecycleExecutor
|
||||||
// Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can lookup the plugin
|
// Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can lookup the plugin
|
||||||
// descriptor and populate the default configuration.
|
// descriptor and populate the default configuration.
|
||||||
//
|
//
|
||||||
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest )
|
||||||
throws LifecycleExecutionException;
|
throws LifecycleExecutionException;
|
||||||
|
|
||||||
void execute( MavenSession session );
|
void execute( MavenSession session );
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.apache.maven.ArtifactFilterManager;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
|
@ -106,8 +108,7 @@ public class DefaultPluginManager
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin
|
||||||
* @param localRepository
|
* @param repositoryRequest
|
||||||
* @param remoteRepositories
|
|
||||||
* @return PluginDescriptor The component descriptor for the Maven plugin.
|
* @return PluginDescriptor The component descriptor for the Maven plugin.
|
||||||
* @throws PluginNotFoundException The plugin could not be found in any repositories.
|
* @throws PluginNotFoundException The plugin could not be found in any repositories.
|
||||||
* @throws PluginResolutionException The plugin could be found but could not be resolved.
|
* @throws PluginResolutionException The plugin could be found but could not be resolved.
|
||||||
|
@ -116,10 +117,12 @@ public class DefaultPluginManager
|
||||||
* happen but if someone has made a descriptor by hand it's possible.
|
* happen but if someone has made a descriptor by hand it's possible.
|
||||||
* @throws CycleDetectedInComponentGraphException A cycle has been detected in the component graph for a plugin that has been dynamically loaded.
|
* @throws CycleDetectedInComponentGraphException A cycle has been detected in the component graph for a plugin that has been dynamically loaded.
|
||||||
*/
|
*/
|
||||||
public synchronized PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public synchronized PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = pluginCache.getPluginDescriptor( plugin, localRepository, remoteRepositories );
|
PluginDescriptor pluginDescriptor =
|
||||||
|
pluginCache.getPluginDescriptor( plugin, repositoryRequest.getLocalRepository(),
|
||||||
|
repositoryRequest.getRemoteRepositories() );
|
||||||
|
|
||||||
if ( pluginDescriptor != null )
|
if ( pluginDescriptor != null )
|
||||||
{
|
{
|
||||||
|
@ -128,10 +131,8 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
|
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest )
|
||||||
.setArtifact( pluginArtifact )
|
.setArtifact( pluginArtifact )
|
||||||
.setLocalRepository( localRepository )
|
|
||||||
.setRemoteRepositories( remoteRepositories )
|
|
||||||
.setResolveTransitively( false );
|
.setResolveTransitively( false );
|
||||||
// FIXME setTransferListener
|
// FIXME setTransferListener
|
||||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||||
|
@ -207,7 +208,8 @@ public class DefaultPluginManager
|
||||||
pluginDescriptor.setPlugin( plugin );
|
pluginDescriptor.setPlugin( plugin );
|
||||||
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
||||||
|
|
||||||
pluginCache.putPluginDescriptor( plugin, localRepository, remoteRepositories, pluginDescriptor );
|
pluginCache.putPluginDescriptor( plugin, repositoryRequest.getLocalRepository(),
|
||||||
|
repositoryRequest.getRemoteRepositories(), pluginDescriptor );
|
||||||
|
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
|
|
||||||
|
@ -242,7 +244,7 @@ public class DefaultPluginManager
|
||||||
* no file set is meant to be excluded from the plugin realm in favor of the equivalent library from the current
|
* no file set is meant to be excluded from the plugin realm in favor of the equivalent library from the current
|
||||||
* core distro.
|
* core distro.
|
||||||
*/
|
*/
|
||||||
List<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedInPom, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
List<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedInPom, RepositoryRequest repositoryRequest )
|
||||||
throws ArtifactNotFoundException, ArtifactResolutionException
|
throws ArtifactNotFoundException, ArtifactResolutionException
|
||||||
{
|
{
|
||||||
ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
|
ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
|
||||||
|
@ -269,12 +271,10 @@ public class DefaultPluginManager
|
||||||
dependenciesToResolveForPlugin.add( a );
|
dependenciesToResolveForPlugin.add( a );
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest )
|
||||||
.setArtifact( pluginArtifact )
|
.setArtifact( pluginArtifact )
|
||||||
// So this in fact are overrides ...
|
// So this in fact are overrides ...
|
||||||
.setArtifactDependencies( dependenciesToResolveForPlugin )
|
.setArtifactDependencies( dependenciesToResolveForPlugin )
|
||||||
.setLocalRepository( localRepository )
|
|
||||||
.setRemoteRepositories( remoteRepositories )
|
|
||||||
.setFilter( filter )
|
.setFilter( filter )
|
||||||
.setResolveRoot( true )
|
.setResolveRoot( true )
|
||||||
.setResolveTransitively( true );
|
.setResolveTransitively( true );
|
||||||
|
@ -396,6 +396,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin plugin = pluginDescriptor.getPlugin();
|
Plugin plugin = pluginDescriptor.getPlugin();
|
||||||
|
|
||||||
ArtifactRepository localRepository = session.getLocalRepository();
|
ArtifactRepository localRepository = session.getLocalRepository();
|
||||||
List<ArtifactRepository> remoteRepositories = session.getCurrentProject().getPluginArtifactRepositories();
|
List<ArtifactRepository> remoteRepositories = session.getCurrentProject().getPluginArtifactRepositories();
|
||||||
|
|
||||||
|
@ -417,7 +418,11 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository, remoteRepositories );
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
request.setCache( session.getRepositoryCache() );
|
||||||
|
pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, request );
|
||||||
}
|
}
|
||||||
catch ( ArtifactNotFoundException e )
|
catch ( ArtifactNotFoundException e )
|
||||||
{
|
{
|
||||||
|
@ -686,7 +691,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
Plugin plugin = new Plugin();
|
Plugin plugin = new Plugin();
|
||||||
|
@ -694,13 +699,13 @@ public class DefaultPluginManager
|
||||||
plugin.setArtifactId( artifactId );
|
plugin.setArtifactId( artifactId );
|
||||||
plugin.setVersion( version );
|
plugin.setVersion( version );
|
||||||
|
|
||||||
return getMojoDescriptor( plugin, goal, localRepository, remoteRepositories );
|
return getMojoDescriptor( plugin, goal, repositoryRequest );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, localRepository, remoteRepositories );
|
PluginDescriptor pluginDescriptor = loadPlugin( plugin, repositoryRequest );
|
||||||
|
|
||||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,7 @@ package org.apache.maven.plugin;
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
@ -30,15 +28,15 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
public interface PluginManager
|
public interface PluginManager
|
||||||
{
|
{
|
||||||
// igorf: Way too many declared exceptions!
|
// igorf: Way too many declared exceptions!
|
||||||
PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException;
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException;
|
||||||
|
|
||||||
// igorf: Way too many declared exceptions!
|
// igorf: Way too many declared exceptions!
|
||||||
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
||||||
|
|
||||||
// igorf: Way too many declared exceptions!
|
// igorf: Way too many declared exceptions!
|
||||||
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
||||||
|
|
||||||
void executeMojo( MavenSession session, MojoExecution execution )
|
void executeMojo( MavenSession session, MojoExecution execution )
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.List;
|
||||||
import org.apache.maven.Maven;
|
import org.apache.maven.Maven;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
|
@ -162,8 +164,12 @@ public class DefaultProjectBuilder
|
||||||
private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration,
|
private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration,
|
||||||
ReactorModelPool reactorModelPool )
|
ReactorModelPool reactorModelPool )
|
||||||
{
|
{
|
||||||
|
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
|
||||||
|
repositoryRequest.setCache( configuration.getRepositoryCache() );
|
||||||
|
repositoryRequest.setLocalRepository( configuration.getLocalRepository() );
|
||||||
|
|
||||||
ModelResolver resolver =
|
ModelResolver resolver =
|
||||||
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration.getLocalRepository(),
|
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
|
||||||
configuration.getRemoteRepositories(), reactorModelPool );
|
configuration.getRemoteRepositories(), reactorModelPool );
|
||||||
|
|
||||||
ModelBuildingRequest request = new DefaultModelBuildingRequest();
|
ModelBuildingRequest request = new DefaultModelBuildingRequest();
|
||||||
|
@ -191,6 +197,7 @@ public class DefaultProjectBuilder
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||||
.setArtifact( artifact )
|
.setArtifact( artifact )
|
||||||
|
.setCache( configuration.getRepositoryCache() )
|
||||||
.setLocalRepository( configuration.getLocalRepository() )
|
.setLocalRepository( configuration.getLocalRepository() )
|
||||||
.setRemoteRepositories( configuration.getRemoteRepositories() );
|
.setRemoteRepositories( configuration.getRemoteRepositories() );
|
||||||
// FIXME setTransferListener
|
// FIXME setTransferListener
|
||||||
|
@ -257,6 +264,7 @@ public class DefaultProjectBuilder
|
||||||
.setArtifact( artifact )
|
.setArtifact( artifact )
|
||||||
.setResolveRoot( false )
|
.setResolveRoot( false )
|
||||||
.setResolveTransitively( true )
|
.setResolveTransitively( true )
|
||||||
|
.setCache( request.getRepositoryCache() )
|
||||||
.setLocalRepository( request.getLocalRepository() )
|
.setLocalRepository( request.getLocalRepository() )
|
||||||
.setRemoteRepositories( project.getRemoteArtifactRepositories() )
|
.setRemoteRepositories( project.getRemoteArtifactRepositories() )
|
||||||
.setManagedVersionMap( project.getManagedVersionMap() );
|
.setManagedVersionMap( project.getManagedVersionMap() );
|
||||||
|
@ -492,9 +500,12 @@ public class DefaultProjectBuilder
|
||||||
{
|
{
|
||||||
if ( configuration.isProcessPlugins() )
|
if ( configuration.isProcessPlugins() )
|
||||||
{
|
{
|
||||||
lifecycle.populateDefaultConfigurationForPlugins( model.getBuild().getPlugins(),
|
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
|
||||||
configuration.getLocalRepository(),
|
repositoryRequest.setLocalRepository( configuration.getLocalRepository() );
|
||||||
project.getPluginArtifactRepositories() );
|
repositoryRequest.setRemoteRepositories( project.getPluginArtifactRepositories() );
|
||||||
|
repositoryRequest.setCache( configuration.getRepositoryCache() );
|
||||||
|
|
||||||
|
lifecycle.populateDefaultConfigurationForPlugins( model.getBuild().getPlugins(), repositoryRequest );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( LifecycleExecutionException e )
|
catch ( LifecycleExecutionException e )
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||||
import org.apache.maven.model.building.ModelEventListener;
|
import org.apache.maven.model.building.ModelEventListener;
|
||||||
|
@ -32,6 +33,9 @@ import org.apache.maven.model.building.ModelEventListener;
|
||||||
public class DefaultProjectBuildingRequest
|
public class DefaultProjectBuildingRequest
|
||||||
implements ProjectBuildingRequest
|
implements ProjectBuildingRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private RepositoryCache repositoryCache;
|
||||||
|
|
||||||
private ArtifactRepository localRepository;
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
@ -80,6 +84,18 @@ public class DefaultProjectBuildingRequest
|
||||||
this.topProject = mavenProject;
|
this.topProject = mavenProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache )
|
||||||
|
{
|
||||||
|
this.repositoryCache = repositoryCache;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RepositoryCache getRepositoryCache()
|
||||||
|
{
|
||||||
|
return repositoryCache;
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
|
public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
|
||||||
{
|
{
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
|
@ -25,12 +25,18 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.MavenTransferListener;
|
import org.apache.maven.MavenTransferListener;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryCache;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.model.building.ModelBuildingRequest;
|
import org.apache.maven.model.building.ModelBuildingRequest;
|
||||||
import org.apache.maven.wagon.events.TransferListener;
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
|
|
||||||
public interface ProjectBuildingRequest
|
public interface ProjectBuildingRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache );
|
||||||
|
|
||||||
|
RepositoryCache getRepositoryCache();
|
||||||
|
|
||||||
ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository );
|
ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository );
|
||||||
|
|
||||||
ArtifactRepository getLocalRepository();
|
ArtifactRepository getLocalRepository();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
|
@ -51,14 +52,14 @@ class RepositoryModelResolver
|
||||||
|
|
||||||
private ResolutionErrorHandler resolutionErrorHandler;
|
private ResolutionErrorHandler resolutionErrorHandler;
|
||||||
|
|
||||||
private ArtifactRepository localRepository;
|
private RepositoryRequest repositoryRequest;
|
||||||
|
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
private List<ArtifactRepository> remoteRepositories;
|
||||||
|
|
||||||
private ReactorModelPool reactorModelPool;
|
private ReactorModelPool reactorModelPool;
|
||||||
|
|
||||||
public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler resolutionErrorHandler,
|
public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler resolutionErrorHandler,
|
||||||
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
|
RepositoryRequest repositoryRequest, List<ArtifactRepository> remoteRepositories,
|
||||||
ReactorModelPool reactorModelPool )
|
ReactorModelPool reactorModelPool )
|
||||||
{
|
{
|
||||||
if ( repositorySystem == null )
|
if ( repositorySystem == null )
|
||||||
|
@ -73,11 +74,11 @@ class RepositoryModelResolver
|
||||||
}
|
}
|
||||||
this.resolutionErrorHandler = resolutionErrorHandler;
|
this.resolutionErrorHandler = resolutionErrorHandler;
|
||||||
|
|
||||||
if ( localRepository == null )
|
if ( repositoryRequest == null )
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException( "no local repository specified" );
|
throw new IllegalArgumentException( "no repository request specified" );
|
||||||
}
|
}
|
||||||
this.localRepository = localRepository;
|
this.repositoryRequest = repositoryRequest;
|
||||||
|
|
||||||
if ( remoteRepositories == null )
|
if ( remoteRepositories == null )
|
||||||
{
|
{
|
||||||
|
@ -90,7 +91,7 @@ class RepositoryModelResolver
|
||||||
|
|
||||||
public ModelResolver newCopy()
|
public ModelResolver newCopy()
|
||||||
{
|
{
|
||||||
return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, localRepository,
|
return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
|
||||||
remoteRepositories, reactorModelPool );
|
remoteRepositories, reactorModelPool );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,9 +128,8 @@ class RepositoryModelResolver
|
||||||
{
|
{
|
||||||
Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId, version );
|
Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId, version );
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
|
||||||
request.setArtifact( artifactParent );
|
request.setArtifact( artifactParent );
|
||||||
request.setLocalRepository( localRepository );
|
|
||||||
request.setRemoteRepositories( remoteRepositories );
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
// FIXME setTransferListener
|
// FIXME setTransferListener
|
||||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||||
|
@ -55,6 +56,7 @@ import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.ProjectBuilder;
|
import org.apache.maven.project.ProjectBuilder;
|
||||||
import org.apache.maven.project.ProjectBuildingException;
|
import org.apache.maven.project.ProjectBuildingException;
|
||||||
import org.apache.maven.project.ProjectBuildingRequest;
|
import org.apache.maven.project.ProjectBuildingRequest;
|
||||||
|
import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
|
||||||
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
|
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
|
||||||
import org.codehaus.plexus.PlexusContainer;
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
@ -88,13 +90,6 @@ public class MavenMetadataSource
|
||||||
@Requirement
|
@Requirement
|
||||||
private MavenMetadataCache cache;
|
private MavenMetadataCache cache;
|
||||||
|
|
||||||
public ResolutionGroup retrieve( MetadataResolutionRequest request )
|
|
||||||
throws ArtifactMetadataRetrievalException
|
|
||||||
{
|
|
||||||
return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories(),
|
|
||||||
request.isResolveManagedVersions() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
||||||
List<ArtifactRepository> remoteRepositories )
|
List<ArtifactRepository> remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
|
@ -106,6 +101,19 @@ public class MavenMetadataSource
|
||||||
List<ArtifactRepository> remoteRepositories, boolean resolveManagedVersions )
|
List<ArtifactRepository> remoteRepositories, boolean resolveManagedVersions )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
|
MetadataResolutionRequest request = new DefaultMetadataResolutionRequest();
|
||||||
|
request.setArtifact( artifact );
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
request.setResolveManagedVersions( resolveManagedVersions );
|
||||||
|
return retrieve( request );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResolutionGroup retrieve( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
Artifact artifact = request.getArtifact();
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we have a system scoped artifact then we do not want any searching in local or remote repositories
|
// If we have a system scoped artifact then we do not want any searching in local or remote repositories
|
||||||
// and we want artifact resolution to only return the system scoped artifact itself.
|
// and we want artifact resolution to only return the system scoped artifact itself.
|
||||||
|
@ -114,8 +122,10 @@ public class MavenMetadataSource
|
||||||
{
|
{
|
||||||
return new ResolutionGroup( null, null, null );
|
return new ResolutionGroup( null, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolutionGroup cached = cache.get( artifact, resolveManagedVersions, localRepository, remoteRepositories );
|
ResolutionGroup cached =
|
||||||
|
cache.get( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
|
||||||
|
request.getRemoteRepositories() );
|
||||||
|
|
||||||
if ( cached != null )
|
if ( cached != null )
|
||||||
{
|
{
|
||||||
|
@ -142,7 +152,7 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
|
ProjectRelocation rel = retrieveRelocatedProject( artifact, request );
|
||||||
|
|
||||||
if ( rel == null )
|
if ( rel == null )
|
||||||
{
|
{
|
||||||
|
@ -188,7 +198,7 @@ public class MavenMetadataSource
|
||||||
|
|
||||||
Map<String, Artifact> managedVersions = null;
|
Map<String, Artifact> managedVersions = null;
|
||||||
|
|
||||||
if ( managedDependencies != null && resolveManagedVersions )
|
if ( managedDependencies != null && request.isResolveManagedVersions() )
|
||||||
{
|
{
|
||||||
managedVersions = new HashMap<String, Artifact>();
|
managedVersions = new HashMap<String, Artifact>();
|
||||||
|
|
||||||
|
@ -201,9 +211,10 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolutionGroup result =
|
ResolutionGroup result =
|
||||||
new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, remoteRepositories );
|
new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, request.getRemoteRepositories() );
|
||||||
|
|
||||||
cache.put( artifact, resolveManagedVersions, localRepository, remoteRepositories, result );
|
cache.put( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
|
||||||
|
request.getRemoteRepositories(), result );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -319,15 +330,25 @@ public class MavenMetadataSource
|
||||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
|
MetadataResolutionRequest request = new DefaultMetadataResolutionRequest();
|
||||||
|
request.setArtifact( artifact );
|
||||||
|
request.setLocalRepository( localRepository );
|
||||||
|
request.setRemoteRepositories( remoteRepositories );
|
||||||
|
return retrieveAvailableVersions( request );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( request.getArtifact() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
|
repositoryMetadataManager.resolve( metadata, request );
|
||||||
}
|
}
|
||||||
catch ( RepositoryMetadataResolutionException e )
|
catch ( RepositoryMetadataResolutionException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
|
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, request.getArtifact() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
|
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
|
||||||
|
@ -416,8 +437,7 @@ public class MavenMetadataSource
|
||||||
return projectBuilder;
|
return projectBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
|
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, RepositoryRequest repositoryRequest )
|
||||||
List<ArtifactRepository> remoteRepositories )
|
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
MavenProject project = null;
|
MavenProject project = null;
|
||||||
|
@ -446,8 +466,9 @@ public class MavenMetadataSource
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
|
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
|
||||||
configuration.setLocalRepository( localRepository );
|
configuration.setRepositoryCache( repositoryRequest.getCache() );
|
||||||
configuration.setRemoteRepositories( remoteRepositories );
|
configuration.setLocalRepository( repositoryRequest.getLocalRepository() );
|
||||||
|
configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories() );
|
||||||
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||||
configuration.setProcessPlugins( false );
|
configuration.setProcessPlugins( false );
|
||||||
configuration.setSystemProperties( System.getProperties() );
|
configuration.setSystemProperties( System.getProperties() );
|
||||||
|
@ -509,8 +530,10 @@ public class MavenMetadataSource
|
||||||
List<ArtifactVersion> available = artifact.getAvailableVersions();
|
List<ArtifactVersion> available = artifact.getAvailableVersions();
|
||||||
if ( available != null && !available.isEmpty() )
|
if ( available != null && !available.isEmpty() )
|
||||||
{
|
{
|
||||||
available =
|
MetadataResolutionRequest metadataRequest =
|
||||||
retrieveAvailableVersions( relocatedArtifact, localRepository, remoteRepositories );
|
new DefaultMetadataResolutionRequest( repositoryRequest );
|
||||||
|
metadataRequest.setArtifact( relocatedArtifact );
|
||||||
|
available = retrieveAvailableVersions( metadataRequest );
|
||||||
relocatedArtifact.setAvailableVersions( available );
|
relocatedArtifact.setAvailableVersions( available );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Exclusion;
|
import org.apache.maven.model.Exclusion;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -38,6 +41,15 @@ public class ProjectDependenciesResolverTest
|
||||||
return "src/test/projects/project-dependencies-resolver";
|
return "src/test/projects/project-dependencies-resolver";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RepositoryRequest getRepositoryRequest()
|
||||||
|
throws InvalidRepositoryException
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
request.setLocalRepository( getLocalRepository() );
|
||||||
|
request.setRemoteRepositories( getRemoteRepositories() );
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
public void testExclusionsInDependencies()
|
public void testExclusionsInDependencies()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -50,13 +62,11 @@ public class ProjectDependenciesResolverTest
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
Set<Artifact> artifactDependencies =
|
Set<Artifact> artifactDependencies =
|
||||||
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
|
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest() );
|
||||||
getRemoteRepositories() );
|
|
||||||
assertEquals( 0, artifactDependencies.size() );
|
assertEquals( 0, artifactDependencies.size() );
|
||||||
|
|
||||||
artifactDependencies =
|
artifactDependencies =
|
||||||
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), getLocalRepository(),
|
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), getRepositoryRequest() );
|
||||||
getRemoteRepositories() );
|
|
||||||
assertEquals( 1, artifactDependencies.size() );
|
assertEquals( 1, artifactDependencies.size() );
|
||||||
assertEquals( "maven-core-it-support" , artifactDependencies.iterator().next().getArtifactId() );
|
assertEquals( "maven-core-it-support" , artifactDependencies.iterator().next().getArtifactId() );
|
||||||
}
|
}
|
||||||
|
@ -69,8 +79,7 @@ public class ProjectDependenciesResolverTest
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
Set<Artifact> artifactDependencies =
|
Set<Artifact> artifactDependencies =
|
||||||
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
|
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest() );
|
||||||
getRemoteRepositories() );
|
|
||||||
assertEquals( 1, artifactDependencies.size() );
|
assertEquals( 1, artifactDependencies.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +94,7 @@ public class ProjectDependenciesResolverTest
|
||||||
MavenSession session = createMavenSession( pom, eps );
|
MavenSession session = createMavenSession( pom, eps );
|
||||||
MavenProject project = session.getCurrentProject();
|
MavenProject project = session.getCurrentProject();
|
||||||
|
|
||||||
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
|
resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest() );
|
||||||
getRemoteRepositories() );
|
|
||||||
|
|
||||||
List<String> elements = project.getCompileClasspathElements();
|
List<String> elements = project.getCompileClasspathElements();
|
||||||
assertEquals( 2, elements.size() );
|
assertEquals( 2, elements.size() );
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
@ -38,7 +40,17 @@ public class PluginManagerTest
|
||||||
{
|
{
|
||||||
return "src/test/projects/plugin-manager";
|
return "src/test/projects/plugin-manager";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RepositoryRequest getRepositoryRequest( MavenSession session )
|
||||||
|
{
|
||||||
|
RepositoryRequest request = new DefaultRepositoryRequest();
|
||||||
|
|
||||||
|
request.setLocalRepository( session.getLocalRepository() );
|
||||||
|
request.setRemoteRepositories( session.getCurrentProject().getPluginArtifactRepositories() );
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
public void testPluginLoading()
|
public void testPluginLoading()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -47,7 +59,7 @@ public class PluginManagerTest
|
||||||
plugin.setGroupId( "org.codehaus.plexus" );
|
plugin.setGroupId( "org.codehaus.plexus" );
|
||||||
plugin.setArtifactId( "plexus-component-metadata" );
|
plugin.setArtifactId( "plexus-component-metadata" );
|
||||||
plugin.setVersion( plexusVersion );
|
plugin.setVersion( plexusVersion );
|
||||||
PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getLocalRepository(), session.getCurrentProject().getPluginArtifactRepositories() );
|
PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, getRepositoryRequest( session ) );
|
||||||
assertNotNull( pluginDescriptor );
|
assertNotNull( pluginDescriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +73,7 @@ public class PluginManagerTest
|
||||||
plugin.setArtifactId( "plexus-component-metadata" );
|
plugin.setArtifactId( "plexus-component-metadata" );
|
||||||
plugin.setVersion( plexusVersion );
|
plugin.setVersion( plexusVersion );
|
||||||
|
|
||||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), session.getCurrentProject().getPluginArtifactRepositories() );
|
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, getRepositoryRequest( session ) );
|
||||||
assertNotNull( mojoDescriptor );
|
assertNotNull( mojoDescriptor );
|
||||||
assertEquals( "generate-metadata", mojoDescriptor.getGoal() );
|
assertEquals( "generate-metadata", mojoDescriptor.getGoal() );
|
||||||
// igorf: plugin realm comes later
|
// igorf: plugin realm comes later
|
||||||
|
@ -225,7 +237,11 @@ public class PluginManagerTest
|
||||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
List<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact, plugin, getLocalRepository(), getPluginArtifactRepositories() );
|
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
|
||||||
|
repositoryRequest.setLocalRepository( getLocalRepository() );
|
||||||
|
repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() );
|
||||||
|
|
||||||
|
List<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact, plugin, repositoryRequest );
|
||||||
|
|
||||||
for ( Artifact a : artifacts )
|
for ( Artifact a : artifacts )
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.RepositoryRequest;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
|
@ -75,7 +76,7 @@ public class EmptyLifecycleExecutor
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest )
|
||||||
throws LifecycleExecutionException
|
throws LifecycleExecutionException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue