Java Code Examples for org.apache.maven.artifact.resolver.ArtifactResolutionRequest#setRemoteRepositories()
The following examples show how to use
org.apache.maven.artifact.resolver.ArtifactResolutionRequest#setRemoteRepositories() .
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: MavenHelper.java From sarl with Apache License 2.0 | 6 votes |
/** Resolve the artifacts with the given key. * * @param groupId the group identifier. * @param artifactId the artifact identifier. * @return the discovered artifacts. * @throws MojoExecutionException if resolution cannot be done. * @since 0.8 */ public Set<Artifact> resolve(String groupId, String artifactId) throws MojoExecutionException { final ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setResolveRoot(true); request.setResolveTransitively(true); request.setLocalRepository(getSession().getLocalRepository()); request.setRemoteRepositories(getSession().getCurrentProject().getRemoteArtifactRepositories()); request.setOffline(getSession().isOffline()); request.setForceUpdate(getSession().getRequest().isUpdateSnapshots()); request.setServers(getSession().getRequest().getServers()); request.setMirrors(getSession().getRequest().getMirrors()); request.setProxies(getSession().getRequest().getProxies()); request.setArtifact(createArtifact(groupId, artifactId)); final ArtifactResolutionResult result = resolve(request); return result.getArtifacts(); }
Example 2
Source File: Util.java From yangtools with Eclipse Public License 1.0 | 6 votes |
/** * Read transitive dependencies of given plugin and store them in map. * * @param plugin * plugin to read * @param map * map, where founded transitive dependencies will be stored * @param repoSystem * repository system * @param localRepository * local repository * @param remoteRepos * list of remote repositories */ private static void getPluginTransitiveDependencies(final Plugin plugin, final Map<Artifact, Collection<Artifact>> map, final RepositorySystem repoSystem, final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepos) { List<Dependency> pluginDependencies = plugin.getDependencies(); for (Dependency dep : pluginDependencies) { Artifact artifact = repoSystem.createDependencyArtifact(dep); ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact); request.setResolveTransitively(true); request.setLocalRepository(localRepository); request.setRemoteRepositories(remoteRepos); ArtifactResolutionResult result = repoSystem.resolve(request); Set<Artifact> pluginDependencyDependencies = result.getArtifacts(); map.put(artifact, pluginDependencyDependencies); } }
Example 3
Source File: AbstractCodegenMojo.java From cxf with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: MavenEmbedder.java From netbeans with Apache License 2.0 | 5 votes |
/** * * @param sources * @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository() * or by using instances from MavenProject * @param localRepository * @throws ArtifactResolutionException * @throws ArtifactNotFoundException */ public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException { setUpLegacySupport(); ArtifactResolutionRequest req = new ArtifactResolutionRequest(); req.setLocalRepository(localRepository); req.setRemoteRepositories(remoteRepositories); req.setArtifact(sources); req.setOffline(isOffline()); ArtifactResolutionResult result = repositorySystem.resolve(req); normalizePath(sources); // XXX check result for exceptions and throw them now? for (Exception ex : result.getExceptions()) { LOG.log(Level.FINE, null, ex); } }
Example 5
Source File: GenerateBomMojo.java From sundrio with Apache License 2.0 | 5 votes |
private Set<Artifact> resolve(final Set<Artifact> dependencies) { ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(getProject().getArtifact()); request.setArtifactDependencies(dependencies); request.setLocalRepository(localRepository); request.setRemoteRepositories(remoteRepositories); request.setManagedVersionMap(getProject().getManagedVersionMap()); request.setResolveTransitively(true); ArtifactResolutionResult result = artifactResolver.resolve(request); return result.getArtifacts(); }
Example 6
Source File: AbstractCodeGeneratorMojo.java From cxf with Apache License 2.0 | 5 votes |
private Artifact resolveRemoteWadlArtifact(Artifact artifact) throws MojoExecutionException { /** * First try to find the artifact in the reactor projects of the maven session. * So an artifact that is not yet built can be resolved */ List<MavenProject> rProjects = mavenSession.getProjects(); for (MavenProject rProject : rProjects) { if (artifact.getGroupId().equals(rProject.getGroupId()) && artifact.getArtifactId().equals(rProject.getArtifactId()) && artifact.getVersion().equals(rProject.getVersion())) { Set<Artifact> artifacts = rProject.getArtifacts(); for (Artifact pArtifact : artifacts) { if ("wadl".equals(pArtifact.getType())) { return pArtifact; } } } } 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; }