List of usage examples for org.apache.maven.artifact.resolver ArtifactResolutionException ArtifactResolutionException
public ArtifactResolutionException(String message, Artifact artifact)
From source file:org.echocat.jomon.maven.boot.ArtifactFactory.java
License:Mozilla Public License
@Nonnull protected String getLatestVersionOf(@Nonnull MavenProject project, @Nonnull Artifact artifact) throws ArtifactResolutionException { String latestVersion = null;/*from w w w .ja v a 2 s.c om*/ try { final ArtifactRepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata(artifact); _repositoryMetadataManager.resolve(repositoryMetadata, project.getRemoteArtifactRepositories(), getLocalRepository()); latestVersion = selectLatestMatchingVersion(repositoryMetadata, artifact); } catch (final Exception ignored) { } if (latestVersion == null || latestVersion.isEmpty()) { throw new ArtifactResolutionException( "Could not find a version in the remote repositories but also no latestVersion in the local repository. Stop resolving now.", artifact); } return latestVersion; }
From source file:org.jvnet.maven.plugin.antrun.MavenComponentBag.java
License:Apache License
public ArtifactResolutionResult resolveTransitively(String groupId, String artifactId, String version, String type, String classifier) throws ArtifactResolutionException, ArtifactNotFoundException, IOException { Set artifacts = new HashSet(); Artifact artifact = createArtifactWithClassifier(groupId, artifactId, version, type, classifier); ResolutionGroup resolutionGroup;/*ww w. j a va 2 s .com*/ try { resolutionGroup = artifactMetadataSource.retrieve(artifact, localRepository, project.getPluginArtifactRepositories()); artifacts.addAll(resolutionGroup.getArtifacts()); } catch (ArtifactMetadataRetrievalException e) { throw new ArtifactResolutionException("Unable to download metadata from repository for artifact '" + artifact.getId() + " " + e.getMessage(), artifact); } ArtifactResolutionResult result = resolver.resolveTransitively(artifacts, artifact, localRepository, remoteRepositories, artifactMetadataSource, new ScopeArtifactFilter("runtime")); return result; }