use of org.apache.maven.artifact.resolver.ArtifactResolutionResult in project intellij-plugins by JetBrains.
the class RepositoryReplicatorMojo method resolveAndCopyArtifact.
private boolean resolveAndCopyArtifact(Artifact artifact) throws MojoExecutionException, IOException {
if (copiedArtifacts.contains(artifact)) {
return true;
}
copiedArtifacts.add(artifact);
File artifactFile = artifact.getFile();
if (artifactFile == null && !artifact.isResolved()) {
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(session.getLocalRepository());
request.setRemoteRepositories(remoteRepositories);
ArtifactResolutionResult result = repositorySystem.resolve(request);
artifactFile = artifact.getFile();
if (!result.isSuccess() && artifactFile == null) {
if (getLog().isDebugEnabled()) {
for (Exception e : result.getExceptions()) {
getLog().error(e);
}
}
throw new MojoExecutionException("Failed to resolve artifact " + artifact);
}
}
return copyArtifact(artifactFile, artifactFile.getPath().substring(localRepositoryBasedirLength));
}
use of org.apache.maven.artifact.resolver.ArtifactResolutionResult in project kotlin by JetBrains.
the class KotlinCompileMojoBase method getCompilerPluginClassPaths.
private List<String> getCompilerPluginClassPaths() {
ArrayList<String> result = new ArrayList<String>();
List<File> files = new ArrayList<File>();
for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) {
Artifact artifact = system.createDependencyArtifact(dependency);
ArtifactResolutionResult resolved = system.resolve(new ArtifactResolutionRequest().setArtifact(artifact));
for (Artifact resolvedArtifact : resolved.getArtifacts()) {
File file = resolvedArtifact.getFile();
if (file != null && file.exists()) {
files.add(file);
}
}
}
for (File file : files) {
result.add(file.getAbsolutePath());
}
return result;
}
use of org.apache.maven.artifact.resolver.ArtifactResolutionResult in project cxf by apache.
the class AbstractCodegenMoho method resolveArbitraryWsdl.
private Artifact resolveArbitraryWsdl(Artifact artifact) {
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setResolveRoot(true).setResolveTransitively(false);
request.setServers(mavenSession.getRequest().getServers());
request.setMirrors(mavenSession.getRequest().getMirrors());
request.setProxies(mavenSession.getRequest().getProxies());
request.setLocalRepository(mavenSession.getLocalRepository());
request.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories());
ArtifactResolutionResult result = repositorySystem.resolve(request);
Artifact resolvedArtifact = result.getOriginatingArtifact();
if (resolvedArtifact == null && !CollectionUtils.isEmpty(result.getArtifacts())) {
resolvedArtifact = result.getArtifacts().iterator().next();
}
return resolvedArtifact;
}
use of org.apache.maven.artifact.resolver.ArtifactResolutionResult in project xwiki-platform by xwiki.
the class PackageMojo method resolveArtifact.
private void resolveArtifact(Artifact artifact) throws MojoExecutionException {
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact(artifact).setRemoteRepositories(this.remoteRepositories).setLocalRepository(this.localRepository);
ArtifactResolutionResult resolutionResult = this.repositorySystem.resolve(request);
if (resolutionResult.hasExceptions()) {
throw new MojoExecutionException(String.format("Failed to resolve artifact [%s]", artifact, resolutionResult.getExceptions().get(0)));
}
}
use of org.apache.maven.artifact.resolver.ArtifactResolutionResult in project xwiki-platform by xwiki.
the class PackageMojo method resolveTransitively.
private Set<Artifact> resolveTransitively(Set<Artifact> artifacts) throws MojoExecutionException {
AndArtifactFilter filter = new AndArtifactFilter(Arrays.asList(new ScopeArtifactFilter("runtime"), // for JSX. See https://jira.xwiki.org/browse/XWIKI-6151 for more details.
new ExcludesArtifactFilter(Arrays.asList("org.apache.xmlgraphic:batik-js", "commons-logging:commons-logging", "commons-logging:commons-logging-api", "log4j:log4j"))));
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact(this.project.getArtifact()).setArtifactDependencies(artifacts).setCollectionFilter(filter).setRemoteRepositories(this.remoteRepositories).setLocalRepository(this.localRepository).setManagedVersionMap(getManagedVersionMap()).setResolveRoot(false);
ArtifactResolutionResult resolutionResult = this.repositorySystem.resolve(request);
if (resolutionResult.hasExceptions()) {
throw new MojoExecutionException(String.format("Failed to resolve artifacts [%s]", artifacts, resolutionResult.getExceptions().get(0)));
}
return resolutionResult.getArtifacts();
}
Aggregations