Java Code Examples for org.apache.maven.artifact.resolver.ArtifactResolutionRequest#setMirrors()
The following examples show how to use
org.apache.maven.artifact.resolver.ArtifactResolutionRequest#setMirrors() .
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: 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 3
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; }