本文整理汇总了Java中org.apache.maven.artifact.resolver.ArtifactResolutionRequest.setRemoteRepositories方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResolutionRequest.setRemoteRepositories方法的具体用法?Java ArtifactResolutionRequest.setRemoteRepositories怎么用?Java ArtifactResolutionRequest.setRemoteRepositories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.resolver.ArtifactResolutionRequest
的用法示例。
在下文中一共展示了ArtifactResolutionRequest.setRemoteRepositories方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPluginTransitiveDependencies
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
* Read transitive dependencies of given plugin and store them in map.
*
* @param plugin
* plugin to read
* @param map
* map, where founded transitive dependencies will be stored
* @param repoSystem
* repository system
* @param localRepository
* local repository
* @param remoteRepos
* list of remote repositories
*/
private static void getPluginTransitiveDependencies(final Plugin plugin,
final Map<Artifact, Collection<Artifact>> map, final RepositorySystem repoSystem,
final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepos) {
List<Dependency> pluginDependencies = plugin.getDependencies();
for (Dependency dep : pluginDependencies) {
Artifact artifact = repoSystem.createDependencyArtifact(dep);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setResolveTransitively(true);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepos);
ArtifactResolutionResult result = repoSystem.resolve(request);
Set<Artifact> pluginDependencyDependencies = result.getArtifacts();
map.put(artifact, pluginDependencyDependencies);
}
}
示例2: getArtifactResolutionRequestForAsc
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
* Create ArtifactResolutionRequest for asc file corresponding to artifact.
*
* @param artifact artifact
* @return new ArtifactResolutionRequest
*/
private ArtifactResolutionRequest getArtifactResolutionRequestForAsc(Artifact artifact) {
Artifact aAsc = repositorySystem.createArtifactWithClassifier(
artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
artifact.getType(), artifact.getClassifier());
ArtifactResolutionRequest rreq = new ArtifactResolutionRequest();
aAsc.setArtifactHandler(new AscArtifactHandler(aAsc));
rreq.setArtifact(aAsc);
rreq.setResolveTransitively(false);
rreq.setLocalRepository(localRepository);
rreq.setRemoteRepositories(pomRemoteRepositories);
return rreq;
}
示例3: collect
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers )
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
injectSession( request );
return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
conflictResolvers );
}
示例4: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
public Set<Artifact> resolve(MavenProject project, Artifact artifact) throws MavenExecutionException {
Set<Artifact> artifacts = new HashSet<>();
ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest();
artifactResolutionRequest.setResolveTransitively(true);
artifactResolutionRequest.setRemoteRepositories(project.getRemoteArtifactRepositories());
artifactResolutionRequest.setLocalRepository(project.getProjectBuildingRequest().getLocalRepository());
artifactResolutionRequest.setArtifact(artifact);
ArtifactResolutionResult artifactResolutionResult = mavenRepoSystem.resolve(artifactResolutionRequest);
artifactResolutionResult.getArtifacts().stream()
.peek(d -> { if (Flag.verbose()) logger.info("RESOLVED '{}' FROM '{}'", d, artifact); })
.filter(d -> "jar".equals(d.getType()))
.filter(d -> "compile".equals(d.getScope()) || "provided".equals(d.getScope()) || "runtime".equals(d.getScope()))
.forEach(d -> artifacts.add(d));
return artifacts;
}
示例5: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
*
* @param sources
* @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository()
* or by using instances from MavenProject
* @param localRepository
* @throws ArtifactResolutionException
* @throws ArtifactNotFoundException
*/
public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException {
setUpLegacySupport();
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(localRepository);
req.setRemoteRepositories(remoteRepositories);
req.setArtifact(sources);
req.setOffline(isOffline());
ArtifactResolutionResult result = repositorySystem.resolve(req);
normalizePath(sources);
// XXX check result for exceptions and throw them now?
for (Exception ex : result.getExceptions()) {
LOG.log(Level.FINE, null, ex);
}
}
示例6: resolveDependency
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private void resolveDependency(Dependency dep,
TreeSet<File> includes,
File workingDir,
Set<Artifact> resolvedArtifacts) throws MojoFailureException, MojoExecutionException {
Artifact artifact = repositorySystem.createDependencyArtifact(dep);
// Avoid resolving stuff we already have resolved.
if (resolvedArtifacts.contains(artifact)) {
return;
}
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepositories);
request.setManagedVersionMap(project.getManagedVersionMap());
request.setResolveTransitively(false);
request.setArtifact(artifact);
ArtifactResolutionResult result = artifactResolver.resolve(request);
boolean found = false;
for (Artifact resolved : result.getArtifacts()) {
if (artifact.equals(resolved)) {
resolvedArtifacts.add(resolved);
addDependencyInclude(workingDir, includes, resolved);
found = true;
break;
}
}
if (!found) {
throw new MojoFailureException("Unable to resolve providence dependency: " +
artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
artifact.getVersion() + ":" + artifact.getClassifier());
}
}
示例7: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private Set<Artifact> resolve(final Set<Artifact> dependencies) {
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(getProject().getArtifact());
request.setArtifactDependencies(dependencies);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepositories);
request.setManagedVersionMap(getProject().getManagedVersionMap());
request.setResolveTransitively(true);
ArtifactResolutionResult result = artifactResolver.resolve(request);
return result.getArtifacts();
}
示例8: resolveArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
private void resolveArtifact(Artifact baselineArtifact) {
final ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(baselineArtifact);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepositories);
request.setOffline(session.isOffline());
repositorySystem.resolve(request);
}
示例9: unpackBaseImage
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
protected void unpackBaseImage(File buildDir, boolean useDefaultPrefix) throws Exception {
String imageName = project.getProperties().getProperty(DOCKER_BASE_IMAGE_PROPERTY);
Objects.notNull(imageName, DOCKER_BASE_IMAGE_PROPERTY);
ImageMavenCoords baseImageCoords = ImageMavenCoords.parse(imageName, useDefaultPrefix);
String coords = baseImageCoords.getAetherCoords();
Artifact artifact = repositorySystem.createArtifactWithClassifier(baseImageCoords.getGroupId(),
baseImageCoords.getArtifactId(), baseImageCoords.getVersion(), baseImageCoords.getType(),
baseImageCoords.getClassifier());
getLog().info("Resolving Jube image: " + artifact);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(pomRemoteRepositories);
ArtifactResolutionResult result = artifactResolver.resolve(request);
if (!result.isSuccess()) {
throw new ArtifactNotFoundException("Cannot download Jube image", artifact);
}
getLog().info("Resolved Jube image: " + artifact);
if (artifact.getFile() != null) {
File file = artifact.getFile();
getLog().info("File: " + file);
if (!file.exists() || file.isDirectory()) {
throw new MojoExecutionException("Resolved file for " + coords + " is not a valid file: " + file.getAbsolutePath());
}
getLog().info("Unpacking base image " + file.getAbsolutePath() + " to build dir: " + buildDir);
Zips.unzip(new FileInputStream(file), buildDir);
}
}
示例10: getArtifactResolutionRequestForPom
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
* Create ArtifactResolutionRequest for pom file corresponding to artifact.
*
* @param artifact artifact
* @return new ArtifactResolutionRequest
*/
private ArtifactResolutionRequest getArtifactResolutionRequestForPom(Artifact artifact) {
Artifact aAsc = repositorySystem.createProjectArtifact(
artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
ArtifactResolutionRequest rreq = new ArtifactResolutionRequest();
rreq.setArtifact(aAsc);
rreq.setResolveTransitively(false);
rreq.setLocalRepository(localRepository);
rreq.setRemoteRepositories(pomRemoteRepositories);
return rreq;
}
示例11: resolveArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
* Resolve an artifact from repository
*
* @param project MavenProject
* @param artifact Artifact
* @throws org.apache.maven.plugin.MojoExecutionException
*/
public void resolveArtifact(final MavenProject project, final Artifact artifact) throws MojoExecutionException {
logger.debug("Resolving artifact " + artifact.toString());
final ArtifactResolutionRequest artifactRequest = new ArtifactResolutionRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setLocalRepository(localRepository);
artifactRequest.setRemoteRepositories(project.getRemoteArtifactRepositories());
final ArtifactResolutionResult resolutionResult = repositorySystem.resolve(artifactRequest);
if (!resolutionResult.isSuccess()) {
logger.debug("Failed to resolved " + artifact.toString() +" artifact.");
}
}
示例12: resolveArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入方法依赖的package包/类
/**
* Resolves an artifact to a particular repository.
*
* @param artifact Artifact to resolve
* @return fully resolved artifact.
*/
private Artifact resolveArtifact( Artifact artifact ) throws MojoExecutionException
{
final ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest();
artifactResolutionRequest.setArtifact( artifact );
if ( remoteArtifactRepositories != null && !remoteArtifactRepositories.isEmpty() )
{
artifactResolutionRequest.setRemoteRepositories( remoteArtifactRepositories );
}
final ArtifactResolutionResult resolutionResult = this.artifactResolver.resolve( artifactResolutionRequest );
log.debug( "Resolving : " + artifact );
if ( resolutionResult.getArtifacts().size() == 0 )
{
throw new MojoExecutionException( "Could not resolve artifact " + artifact
+ ". Please install it with \"mvn install:install-file ...\" or deploy it to a repository "
+ "with \"mvn deploy:deploy-file ...\"" );
}
if ( resolutionResult.getArtifacts().size() > 1 )
{
log.debug( "Resolved artifacts : " + resolutionResult.getArtifacts() );
throw new MojoExecutionException( "Could not resolve artifact " + artifact
+ " to single target. Found the following possible options : " + resolutionResult.getArtifacts() );
}
final Artifact resolvedArtifact = resolutionResult.getArtifacts().iterator().next();
log.debug( "Resolved : " + resolvedArtifact );
return resolvedArtifact;
}