本文整理汇总了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;
}