本文整理汇总了Java中org.eclipse.aether.RepositorySystem.resolveArtifact方法的典型用法代码示例。如果您正苦于以下问题:Java RepositorySystem.resolveArtifact方法的具体用法?Java RepositorySystem.resolveArtifact怎么用?Java RepositorySystem.resolveArtifact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.RepositorySystem
的用法示例。
在下文中一共展示了RepositorySystem.resolveArtifact方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.eclipse.aether.RepositorySystem; //导入方法依赖的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);
}
}
示例2: resolveArtifact
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
public URL resolveArtifact(String gav) throws PlexusContainerException, ComponentLookupException,
ArtifactResolutionException, MalformedURLException {
RepositorySystem repositorySystem = newRepositorySystem();
RepositorySystemSession session = newSession(repositorySystem);
ArtifactRequest artifactRequest = new ArtifactRequest();
for (RemoteRepository repository : repositories) {
artifactRequest.addRepository(RepositoryUtils.applySessionSettingsToRepository(session, repository));
}
artifactRequest.setArtifact(new DefaultArtifact(gav));
ArtifactResult artifactResult = repositorySystem.resolveArtifact(session, artifactRequest);
return artifactResult.getArtifact().getFile().toURI().toURL();
}
示例3: resolveArtifact
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
/**
* resolve an artifact by searching it into repositories using Aether API
*
* @param artifactToFind
* @return
* @throws ArtifactResolutionException
*/
protected ArtifactResult resolveArtifact(Artifact artifactToFind) throws ArtifactResolutionException {
RepositorySystem aetherRepoSystem = aetherConfigurer.newRepositorySystem();
RepositorySystemSession aetherRepoSession = aetherConfigurer.newSession(aetherRepoSystem, this.mvnConsumerConfigurer.getLocalM2Repo());
ArtifactRequest resolveArtifactRequest = new ArtifactRequest(artifactToFind, initRemoteRepositories(), null);
ArtifactResult artifactResultFound = aetherRepoSystem.resolveArtifact(aetherRepoSession, resolveArtifactRequest);
return artifactResultFound;
}
示例4: resolveArtifact
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
static ArtifactResult resolveArtifact(RepositorySystem rs, MavenSession ms, String coords) throws ArtifactResolutionException {
return rs.resolveArtifact(
ms.getRepositorySession(),
new ArtifactRequest(new DefaultArtifact(coords),
RepositoryUtils.toRepos(ms.getRequest().getRemoteRepositories()),
null));
}
示例5: downloadArtifact
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
private Artifact downloadArtifact(
Artifact artifact,
RemoteRepository repository,
RepositorySystemSession session,
RepositorySystem system)
throws ArtifactResolutionException {
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(ImmutableList.of(repository));
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
return artifactResult.getArtifact();
}
示例6: resolveArtifact
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
private ArtifactResult resolveArtifact(Artifact artifact) {
Moment before = X_Time.now();
RepositorySystem repoSystem = this.repoSystem.get();
RepositorySystemSession session = this.session.get();
try {
final LocalArtifactRequest localRequest = new LocalArtifactRequest(artifact, remoteRepos(), null);
final LocalArtifactResult result = session.getLocalRepositoryManager().find(session, localRequest);
ArtifactRequest request = new ArtifactRequest(artifact, remoteRepos(), null);
if (result.isAvailable()) {
final ArtifactResult artifactResult = new ArtifactResult(request);
final Artifact withFile = artifact.setFile(result.getFile());
artifactResult.setArtifact(withFile);
artifactResult.setRepository(result.getRepository());
return artifactResult;
}
return repoSystem.resolveArtifact(session, request);
} catch (ArtifactResolutionException e) {
X_Log.log(getClass(), getLogLevel(), "Resolved? ", e.getResult().isResolved(), e.getResult().getExceptions());
X_Log.log(getClass(), getLogLevel(), "Could not download " + artifact, e);
throw X_Debug.rethrow(e);
} finally {
if (X_Log.loggable(LogLevel.DEBUG)) {
X_Log.debug("Resolved: " + artifact.toString() + " in "
+ X_Time.difference(before));
}
}
}
示例7: main
import org.eclipse.aether.RepositorySystem; //导入方法依赖的package包/类
public static void main(String[] args) throws ArtifactResolutionException {
System.out.println("------------------------------------------------------------");
System.out.println(RemotePluginRepository.class.getSimpleName());
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-util:1.0.0.v20140518");
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(newRepositories(system, session));
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
System.out.println(artifact + " resolved to " + artifact.getFile());
}