Java Code Examples for org.eclipse.aether.RepositorySystem#resolveArtifact()
The following examples show how to use
org.eclipse.aether.RepositorySystem#resolveArtifact() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtifactTransporter.java From jenkins-build-monitor-plugin with MIT License | 6 votes |
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); } }
Example 2
Source File: ClassPathEntryTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
private static Artifact resolveArtifact(String coordinates) throws ArtifactResolutionException { RepositorySystem system = RepositoryUtility.newRepositorySystem(); RepositorySystemSession session = RepositoryUtility.newSession(system); Artifact artifact = new DefaultArtifact(coordinates); ArtifactRequest artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact(artifact); ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest); return artifactResult.getArtifact(); }
Example 3
Source File: ArtifactDownload.java From CogniCrypt with Eclipse Public License 2.0 | 5 votes |
/** * This method fetches the artifact from the remote server using aether library * * @param groupId group ID of the artifact * @param artifactId artifact ID of the artifact * @param version artifact version to be downloaded * @param classifier classifier of the artifact * @param packaging packaging of the artifact * @param localRepository destination path * @return location of the downloaded artifact in the local system * @throws IOException */ public static File getArtifactByAether(String groupId, String artifactId, String version, String classifier, String packaging, File localRepository) throws IOException { RepositorySystem repositorySystem = newRepositorySystem(); RepositorySystemSession session = newSession(repositorySystem, localRepository); Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, packaging, version); ArtifactRequest artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact(artifact); List<RemoteRepository> repositories = new ArrayList<>(); Section ini = Utils.getConfig().get(Constants.INI_URL_HEADER); RemoteRepository remoteRepository = new RemoteRepository.Builder("public", "default", ini.get(Constants.INI_NEXUS_SOOT_RELEASE)).build(); repositories.add(remoteRepository); artifactRequest.setRepositories(repositories); File result = null; try { ArtifactResult artifactResult = repositorySystem.resolveArtifact(session, artifactRequest); artifact = artifactResult.getArtifact(); if (artifact != null) { result = artifact.getFile(); } } catch (ArtifactResolutionException e) { throw new IOException("Artifact " + groupId + ":" + artifactId + ":" + version + " could not be downloaded due to " + e.getMessage()); } return result; }
Example 4
Source File: RemotePluginRepository.java From BIMserver with GNU Affero General Public License v3.0 | 4 votes |
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()); }