本文整理匯總了Java中org.eclipse.aether.resolution.ArtifactRequest.setRepositories方法的典型用法代碼示例。如果您正苦於以下問題:Java ArtifactRequest.setRepositories方法的具體用法?Java ArtifactRequest.setRepositories怎麽用?Java ArtifactRequest.setRepositories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.aether.resolution.ArtifactRequest
的用法示例。
在下文中一共展示了ArtifactRequest.setRepositories方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: load
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
@Override
public Optional<ArtifactResult> load(ArtifactCoordinates coordinates) throws Exception {
Artifact artifact = new DefaultArtifact(coordinates.toString());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(this.remoteProjectRepos);
ArtifactResult artifactResult;
try {
artifactResult = this.repoSystem.resolveArtifact(this.repoSession, artifactRequest);
} catch (ArtifactResolutionException e) {
// must not throw the error or log as an error since this is an expected behavior
artifactResult = null;
}
return Optional.fromNullable(artifactResult);
}
示例2: resolvePluginDependency
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
/**
* Uses the aether to resolve a plugin dependency and returns the file for further processing.
*
* @param d the dependency to resolve.
* @param pluginRepos the plugin repositories to use for dependency resolution.
* @param resolver the resolver for aether access.
* @param repoSystemSession the session for the resolver.
* @return optionally a file which is the resolved dependency.
*/
public static Optional<File> resolvePluginDependency(Dependency d, List<RemoteRepository> pluginRepos,
ArtifactResolver resolver, RepositorySystemSession repoSystemSession) {
Artifact a = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(a);
artifactRequest.setRepositories(pluginRepos);
try {
ArtifactResult artifactResult = resolver.resolveArtifact(repoSystemSession, artifactRequest);
if (artifactResult.getArtifact() != null) {
return Optional.fromNullable(artifactResult.getArtifact().getFile());
}
return Optional.absent();
} catch (ArtifactResolutionException e) {
return Optional.absent();
}
}
示例3: fetchDependency
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
private Path fetchDependency(final String artifactIdentifier) throws MojoExecutionException {
ArtifactRequest request = new ArtifactRequest();
final DefaultArtifact artifact = new DefaultArtifact(artifactIdentifier);
request.setArtifact(artifact);
request.setRepositories(remoteRepos);
LogProvider.debug("Resolving artifact " + artifact + " from " + remoteRepos);
ArtifactResult result;
try {
result = repoSystem.resolveArtifact(repoSession, request);
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
LogProvider.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile().toPath();
}
示例4: get
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
public Path get(@NotNull String groupName, @NotNull String artifactName, @NotNull String version, @NotNull String artifactFileExtension) {
Artifact artifact = new DefaultArtifact(groupName, artifactName, artifactFileExtension, version);
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(repositories(system, session));
try {
ArtifactResult artifactResult = system.resolveArtifact(session, request);
artifact = artifactResult.getArtifact();
Log.info(artifact + " resolved to " + artifact.getFile());
return artifact.getFile().toPath();
} catch (ArtifactResolutionException e) {
throw new RuntimeException(format("Couldn't resolve a '%s' artifact for '%s:%s:%s'",
artifactFileExtension, groupName, artifactName, version
), e);
}
}
示例5: resolve
import org.eclipse.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("Cound not resolve " + artifact, e);
return null;
}
log.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile();
}
示例6: resolveById
import org.eclipse.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(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();
}
示例7: resolve
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
/**
* Resolves the specified artifact (using its GAV, classifier and packaging).
*
* @param mojo the mojo
* @param groupId the groupId of the artifact to resolve
* @param artifactId the artifactId of the artifact to resolve
* @param version the version
* @param type the type
* @param classifier the classifier
* @return the artifact's file if it can be revolved. The file is located in the local maven repository.
* @throws MojoExecutionException if the artifact cannot be resolved
*/
public static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
String type, String classifier) throws MojoExecutionException {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(
new DefaultArtifact(groupId, artifactId, classifier, type, version));
request.setRepositories(mojo.remoteRepos);
mojo.getLog().info("Resolving artifact " + artifactId +
" from " + mojo.remoteRepos);
ArtifactResult result;
try {
result = mojo.repoSystem.resolveArtifact(mojo.repoSession, request);
} catch (ArtifactResolutionException e) {
mojo.getLog().error("Cannot resolve " + groupId + ":" + artifactId + ":" + version + ":" + type);
throw new MojoExecutionException(e.getMessage(), e);
}
mojo.getLog().info("Resolved artifact " + artifactId + " to " +
result.getArtifact().getFile() + " from "
+ result.getRepository());
return result.getArtifact().getFile();
}
示例8: resolve
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
@Override
public File resolve(final MavenProject project, final String artifact) {
final ArtifactResult result;
try {
final ProjectBuildingRequest projectBuildingRequest = project.getProjectBuildingRequest();
final ArtifactRequest request = new ArtifactRequest();
final ArtifactNameSplitter splitter = ArtifactNameSplitter.of(artifact).split();
final Artifact defaultArtifact = new DefaultArtifact(splitter.getGroupId(), splitter.getArtifactId(), splitter.getClassifier(), splitter.getPackaging(), splitter.getVersion());
request.setArtifact(defaultArtifact);
final List<RemoteRepository> repos = project.getRemoteProjectRepositories();
request.setRepositories(repos);
result = repoSystem.resolveArtifact(projectBuildingRequest.getRepositorySession(), request);
} catch (ArtifactResolutionException e) {
throw new RuntimeException(e.getMessage(), e);
}
return result.getArtifact().getFile();
}
示例9: retrieveArtifact
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
/**
* Uses Aether to retrieve an artifact from the repository.
*
* @param coordinates as in groupId:artifactId:version
* @return the located artifact
*/
Artifact retrieveArtifact(final String coordinates)
{
final ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(coordinates));
request.setRepositories(remoteRepos);
ArtifactResult result = null;
try {
result = repoSystem.resolveArtifact(repoSession, request);
} catch (final ArtifactResolutionException e) {
getLog().error("Could not resolve parent artifact (" + coordinates + "): " + e.getMessage());
}
if (result != null) {
return RepositoryUtils.toArtifact(result.getArtifact());
}
return null;
}
示例10: downloadAndInstallArtifact
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
protected ArtifactResult downloadAndInstallArtifact(String artifact) throws MojoExecutionException {
ArtifactResult result;
ArtifactRequest request = new ArtifactRequest();
request.setArtifact( new DefaultArtifact( artifact ) );
request.setRepositories( remoteRepos );
getLog().info( "Resolving artifact " + artifact + " from " + remoteRepos );
try {
result = repoSystem.resolveArtifact( repoSession, request );
return result;
} catch ( ArtifactResolutionException e ) {
throw new MojoExecutionException( e.getMessage(), e );
}
}
示例11: resolveArtifact
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
private Artifact resolveArtifact(Artifact artifact) throws Exception {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(repositories());
ArtifactResult result = system.resolveArtifact(session, request);
return result.getArtifact();
}
示例12: getArtifactRequests
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
private List<ArtifactRequest> getArtifactRequests(List<Dependency> dependencies) {
List<ArtifactRequest> list = new ArrayList<>();
for (Dependency dependency : dependencies) {
ArtifactRequest request = new ArtifactRequest(dependency.getArtifact(), null,
null);
request.setRepositories(aetherRepositories(new Properties()));
list.add(request);
}
return list;
}
示例13: makeRequest
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
private static ArtifactRequest makeRequest ( final List<RemoteRepository> repositories, final Artifact artifact )
{
final ArtifactRequest artifactRequest = new ArtifactRequest ();
artifactRequest.setArtifact ( artifact );
artifactRequest.setRepositories ( repositories );
return artifactRequest;
}
示例14: resolveArtifact
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
protected File resolveArtifact(Artifact artifact) throws MojoExecutionException, DependencyCollectionException {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(remoteRepos);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repoSession, request);
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
return result.getArtifact().getFile();
}
示例15: resolveArtifact
import org.eclipse.aether.resolution.ArtifactRequest; //導入方法依賴的package包/類
public ArtifactResult resolveArtifact(String groupId, String artifactId, String extension, String version) throws Exception {
Artifact artifact = new DefaultArtifact(groupId, artifactId, extension, version);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(Collections.emptyList());
return system.resolveArtifact(session, request);
}