本文整理汇总了Java中org.sonatype.aether.resolution.ArtifactRequest类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactRequest类的具体用法?Java ArtifactRequest怎么用?Java ArtifactRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactRequest类属于org.sonatype.aether.resolution包,在下文中一共展示了ArtifactRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolveModel
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public ModelSource resolveModel( String groupId, String artifactId, String version )
throws UnresolvableModelException
{
Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
try
{
ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
request.setTrace( trace );
pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
}
catch ( ArtifactResolutionException e )
{
throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
}
File pomFile = pomArtifact.getFile();
return new FileModelSource( pomFile );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:DefaultModelResolver.java
示例2: testResolveArtifacts
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public void testResolveArtifacts()
throws Exception
{
ArtifactRequest req1 = new ArtifactRequest();
req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) );
req1.addRepository( newTestRepository() );
ArtifactRequest req2 = new ArtifactRequest();
req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) );
req2.addRepository( newTestRepository() );
ArtifactRequest req3 = new ArtifactRequest();
req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) );
req3.addRepository( newTestRepository() );
List<ArtifactRequest> requests = Arrays.asList( new ArtifactRequest[] { req1, req2, req3 } );
List<ArtifactResult> results = system.resolveArtifacts( session, requests );
assertEquals( 3, results.size() );
checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" );
checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" );
checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:RepositorySystemTest.java
示例3: resolve
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
@Override
public File resolve(Object artifact, Log log) {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact((Artifact) artifact);
request.setRepositories(projectRepositories);
log.debug("Resolving artifact " + artifact + " from " + projectRepositories);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repositorySystemSession, request);
} catch (ArtifactResolutionException e) {
log.warn("Could not resolve " + artifact, e);
return null;
}
log.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile();
}
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:21,代码来源:Dependency30Helper.java
示例4: resolveById
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
@Override
public File resolveById(String id, Log log) throws MojoFailureException {
id = MavenUtil.mvnToAether(id);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(id));
request.setRepositories((List<RemoteRepository>) projectRepositories);
log.debug("Resolving artifact " + id + " from " + projectRepositories);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repositorySystemSession, request);
} catch (ArtifactResolutionException e) {
log.warn("Could not resolve " + id, e);
throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e);
}
log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile();
}
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:22,代码来源:Dependency30Helper.java
示例5: getPropertyFromPom
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
private String getPropertyFromPom(String propertyName, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
Properties properties = pomInformation.getProperties();
String property = properties.getProperty(propertyName);
if (property == null) {
if (pomInformation.getParentPomInformation() == null) {
if (pomInformation.getParent() != null) {
Artifact artifact = new DefaultArtifact(pomInformation.getParent().getGroupId(),
pomInformation.getParent().getArtifactId(), "pom", pomInformation.getParent().getVersion());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
if (pomInformation.getRepositories() != null) {
for (RemoteRepository repository : pomInformation.getRepositories()) {
artifactRequest.addRepository(repository);
}
}
artifactRequest.addRepository(remoteRepository);
ArtifactResult artifactResult = system.resolveArtifact(mvnRepository, artifactRequest);
File parentPOM = artifactResult.getArtifact().getFile();
pomInformation.parseParentPom(parentPOM);
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
} else {
return null;
}
} else {
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
}
} else {
return property;
}
}
开发者ID:motech,项目名称:motech,代码行数:37,代码来源:ModuleAdminServiceImpl.java
示例6: resolveArtifacts
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
Collection<? extends ArtifactRequest> requests )
throws ArtifactResolutionException
{
List<ArtifactResult> results = new ArrayList<ArtifactResult>();
for ( ArtifactRequest request : requests )
{
ArtifactResult result = new ArtifactResult( request );
results.add( result );
Artifact artifact = request.getArtifact();
if ( "maven-test".equals( artifact.getGroupId() ) )
{
String scope = artifact.getArtifactId().substring( "scope-".length() );
try
{
artifact =
artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir
+ "transitive-" + scope + "-dep.xml" ) );
result.setArtifact( artifact );
}
catch ( FileNotFoundException e )
{
throw new IllegalStateException( "Missing test POM for " + artifact );
}
}
else
{
result.addException( new ArtifactNotFoundException( artifact, null ) );
throw new ArtifactResolutionException( results );
}
}
return results;
}
开发者ID:gems-uff,项目名称:oceano,代码行数:38,代码来源:ClasspathArtifactResolver.java
示例7: resolveModel
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public ModelSource resolveModel( String groupId, String artifactId, String version )
throws UnresolvableModelException
{
File pomFile = null;
if ( modelPool != null )
{
pomFile = modelPool.get( groupId, artifactId, version );
}
if ( pomFile == null )
{
Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );
try
{
ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
request.setTrace( trace );
pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
}
catch ( ArtifactResolutionException e )
{
throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
}
pomFile = pomArtifact.getFile();
}
return new FileModelSource( pomFile );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:31,代码来源:ProjectModelResolver.java
示例8: resolveArtifact
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
throws ArtifactResolutionException
{
return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:6,代码来源:ClasspathArtifactResolver.java
示例9: build
import org.sonatype.aether.resolution.ArtifactRequest; //导入依赖的package包/类
public ProjectBuildingResult build( Artifact artifact, boolean allowStubModel, ProjectBuildingRequest request )
throws ProjectBuildingException
{
org.sonatype.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact );
pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact );
InternalConfig config = new InternalConfig( request, null );
boolean localProject;
try
{
ArtifactRequest pomRequest = new ArtifactRequest();
pomRequest.setArtifact( pomArtifact );
pomRequest.setRepositories( config.repositories );
ArtifactResult pomResult = repoSystem.resolveArtifact( config.session, pomRequest );
pomArtifact = pomResult.getArtifact();
localProject = pomResult.getRepository() instanceof WorkspaceRepository;
}
catch ( org.sonatype.aether.resolution.ArtifactResolutionException e )
{
if ( e.getResults().get( 0 ).isMissing() && allowStubModel )
{
return build( null, createStubModelSource( artifact ), config );
}
throw new ProjectBuildingException( artifact.getId(),
"Error resolving project artifact: " + e.getMessage(), e );
}
File pomFile = pomArtifact.getFile();
if ( "pom".equals( artifact.getType() ) )
{
artifact.selectVersion( pomArtifact.getVersion() );
artifact.setFile( pomFile );
artifact.setResolved( true );
}
return build( localProject ? pomFile : null, new FileModelSource( pomFile ), config );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:42,代码来源:DefaultProjectBuilder.java
注:本文中的org.sonatype.aether.resolution.ArtifactRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论