本文整理匯總了Java中org.sonatype.aether.resolution.MetadataResult類的典型用法代碼示例。如果您正苦於以下問題:Java MetadataResult類的具體用法?Java MetadataResult怎麽用?Java MetadataResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MetadataResult類屬於org.sonatype.aether.resolution包,在下文中一共展示了MetadataResult類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMetadata
import org.sonatype.aether.resolution.MetadataResult; //導入依賴的package包/類
public static Metadata getMetadata(RepositorySystem system, RepositorySystemSession session, Artifact artifact)
{
Metadata metadata = new DefaultMetadata(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getArtifactId() + "-" + artifact.getBaseVersion() + ".pom",
Metadata.Nature.RELEASE_OR_SNAPSHOT);
MetadataRequest request = new MetadataRequest(metadata, central(), null);
MetadataResult result = system.resolveMetadata(session, Collections.singleton(request)).get(0);
return result.getMetadata();
}
示例2: processResults
import org.sonatype.aether.resolution.MetadataResult; //導入依賴的package包/類
private PluginPrefixResult processResults( PluginPrefixRequest request, RequestTrace trace,
List<MetadataResult> results, List<MetadataRequest> requests )
{
for ( MetadataResult res : results )
{
org.sonatype.aether.metadata.Metadata metadata = res.getMetadata();
if ( metadata != null )
{
ArtifactRepository repository = res.getRequest().getRepository();
if ( repository == null )
{
repository = request.getRepositorySession().getLocalRepository();
}
PluginPrefixResult result =
resolveFromRepository( request, trace, metadata.getGroupId(), metadata, repository );
if ( result != null )
{
return result;
}
}
if ( requests != null && !res.isUpdated() )
{
requests.add( res.getRequest() );
}
}
return null;
}
示例3: resolveFromRepository
import org.sonatype.aether.resolution.MetadataResult; //導入依賴的package包/類
private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request )
{
RequestTrace trace = DefaultRequestTrace.newChild( null, request );
List<MetadataRequest> requests = new ArrayList<MetadataRequest>();
for ( String pluginGroup : request.getPluginGroups() )
{
org.sonatype.aether.metadata.Metadata metadata =
new DefaultMetadata( pluginGroup, "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT );
requests.add( new MetadataRequest( metadata, null, REPOSITORY_CONTEXT ).setTrace( trace ) );
for ( RemoteRepository repository : request.getRepositories() )
{
requests.add( new MetadataRequest( metadata, repository, REPOSITORY_CONTEXT ).setTrace( trace ) );
}
}
// initial try, use locally cached metadata
List<MetadataResult> results = repositorySystem.resolveMetadata( request.getRepositorySession(), requests );
requests.clear();
PluginPrefixResult result = processResults( request, trace, results, requests );
if ( result != null )
{
return result;
}
// second try, refetch all (possibly outdated) metadata that wasn't updated in the first attempt
if ( !request.getRepositorySession().isOffline() && !requests.isEmpty() )
{
DefaultRepositorySystemSession session =
new DefaultRepositorySystemSession( request.getRepositorySession() );
session.setUpdatePolicy( RepositoryPolicy.UPDATE_POLICY_ALWAYS );
results = repositorySystem.resolveMetadata( session, requests );
return processResults( request, trace, results, null );
}
return null;
}