localProject = pomResult.getRepository() instanceof WorkspaceRepository;
public String getRepository(String version) throws ArtifactResolutionException { Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version.toString()); ArtifactRequest request = new ArtifactRequest(); request.setArtifact(pomArtifact); request.setRepositories(mavenPluginRepository.getRepositories()); ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request); return resolveArtifact.getRepository().toString(); }
resolveResult = artifactResolver.resolveArtifact( session, resolveRequest ); pomArtifact = resolveResult.getArtifact(); result.setRepository( resolveResult.getRepository() ); versionRangeResolver, remoteRepositoryManager, request.getRepositories() ) ); if ( resolveResult.getRepository() instanceof WorkspaceRepository )
private boolean resolvedFromLocalRepo(ArtifactResult result) { return result.getRepository() instanceof LocalRepository; }
@Override public String toString() { return getArtifact() + " < " + getRepository(); }
@Override public String toString() { return getArtifact() + " < " + getRepository(); }
@Override public File resolve(Object artifact, Log log) { if (log.isDebugEnabled()) { log.debug("Resolving artifact " + artifact + " from " + projectRepositories); } ArtifactResult result; try { result = resolveArtifact((Artifact) artifact); } catch (ArtifactResolutionException e) { log.warn("Cound not resolve " + artifact, e); return null; } if (log.isDebugEnabled()) { log.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository()); } return result.getArtifact().getFile(); }
@Override public File resolveById(String id, Log log) throws MojoFailureException { if (id.startsWith("mvn:")) { if (id.contains("!")) { id = id.substring(0, "mvn:".length()) + id.substring(id.indexOf("!") + 1); } if (id.endsWith("/")) { id = id.substring(0, id.length() - 1); } } id = MavenUtil.mvnToAether(id); if (log.isDebugEnabled()) { log.debug("Resolving artifact " + id + " from " + projectRepositories); } ArtifactResult result; try { result = resolveArtifact(MavenUtil.aetherToArtifact(id)); } catch (ArtifactResolutionException e) { log.warn("Could not resolve " + id, e); throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e); } if (log.isDebugEnabled()) { log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository()); } return result.getArtifact().getFile(); }
@Override public File resolveById(String id, Log log) throws MojoFailureException { if (id.startsWith("mvn:")) { if (id.contains("!")) { id = id.substring(0, "mvn:".length()) + id.substring(id.indexOf("!") + 1); } if (id.endsWith("/")) { id = id.substring(0, id.length() - 1); } } id = MavenUtil.mvnToAether(id); if (log.isDebugEnabled()) { log.debug("Resolving artifact " + id + " from " + projectRepositories); } ArtifactResult result; try { result = resolveArtifact(MavenUtil.aetherToArtifact(id)); } catch (ArtifactResolutionException e) { log.warn("Could not resolve " + id, e); throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e); } if (log.isDebugEnabled()) { log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository()); } return result.getArtifact().getFile(); }
@Override public File resolve(Object artifact, Log log) { if (log.isDebugEnabled()) { log.debug("Resolving artifact " + artifact + " from " + projectRepositories); } ArtifactResult result; try { result = resolveArtifact((Artifact) artifact); } catch (ArtifactResolutionException e) { log.warn("Cound not resolve " + artifact, e); return null; } if (log.isDebugEnabled()) { log.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository()); } return result.getArtifact().getFile(); }
@Override public File download(Archive archive) throws DownloadException { ArtifactResult result = resolveArtifact(createRequest(archive)); File artifact = result.getArtifact().getFile(); LOGGER.info(RESOLVED_ARTIFACT, artifact, result.getRepository()); return artifact; }
protected Collection<File> resolveArtifactIds(Collection<String> artifactIds) throws MojoExecutionException { Collection<ArtifactRequest> requests = new ArrayList<ArtifactRequest>(); for (String artifactId : artifactIds) { ArtifactRequest request = new ArtifactRequest(); request.setArtifact( new DefaultArtifact(artifactId)); request.setRepositories( remoteRepos ); getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos); requests.add(request); } Collection<File> files = new ArrayList<File>(); try { List<ArtifactResult> result = repoSystem.resolveArtifacts(repoSession, requests); for (ArtifactResult artifactResult : result) { File file = artifactResult.getArtifact().getFile(); files.add(file); getLog().debug("Resolved artifact " + artifactResult.getArtifact().getArtifactId() + " to " + file + " from " + artifactResult.getRepository()); } } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException( e.getMessage(), e ); } return files; }
private ResolutionResult getResolutionResult(ArtifactResult artifactResult, boolean remoteOnly) { ResolutionResult result = null; Artifact artifact = artifactResult.getArtifact(); if (artifact != null) { String repositoryId = artifactResult.getRepository().getId(); if (remoteOnly) { if (!Objects.equal(repositoryId, this.repoSession.getLocalRepository().getId())) { result = new ResolutionResult(artifact.getFile(), repositoryId); } } else { result = new ResolutionResult(artifact.getFile(), repositoryId); } } return result; }
private ResolutionResult getResolutionResult(ArtifactResult artifactResult, boolean remoteOnly) { ResolutionResult result = null; Artifact artifact = artifactResult.getArtifact(); if (artifact != null) { String repositoryId = artifactResult.getRepository().getId(); if (remoteOnly) { if (!Objects.equal(repositoryId, this.repoSession.getLocalRepository().getId())) { result = new ResolutionResult(artifact.getFile(), repositoryId); } } else { result = new ResolutionResult(artifact.getFile(), repositoryId); } } return result; }
protected File resolveArtifact(String artifactId) throws MojoExecutionException { ArtifactRequest request = new ArtifactRequest(); request.setArtifact( new DefaultArtifact(artifactId)); request.setRepositories( remoteRepos ); getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos); ArtifactResult result; File file; try { result = repoSystem.resolveArtifact( repoSession, request ); file = result.getArtifact().getFile(); } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException( e.getMessage(), e ); } getLog().debug("Resolved artifact " + artifactId + " to " + file + " from " + result.getRepository()); return file; }
artifact, result.getArtifact().getFile(), result.getRepository()));
/** * Resolves the specified artifact (using the : separated syntax). * * @param mojo the mojo * @param coords the coordinates ot the artifact to resolve using the : separated syntax - * {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null} * @return the artifact's file if it can be revolved. The file is located in the local maven repository. * @throws MojoExecutionException if the artifact cannot be resolved */ public static File resolve(AbstractWisdomMojo mojo, String coords) throws MojoExecutionException { ArtifactRequest request = new ArtifactRequest(); request.setArtifact( new DefaultArtifact(coords)); request.setRepositories(mojo.remoteRepos); mojo.getLog().info("Resolving artifact " + coords + " from " + mojo.remoteRepos); ArtifactResult result; try { result = mojo.repoSystem.resolveArtifact(mojo.repoSession, request); } catch (ArtifactResolutionException e) { mojo.getLog().error("Cannot resolve " + coords); throw new MojoExecutionException(e.getMessage(), e); } mojo.getLog().info("Resolved artifact " + coords + " to " + result.getArtifact().getFile() + " from " + result.getRepository()); return result.getArtifact().getFile(); }
artifactRequest); if (result != null && result.isResolved()) { final MavenRepositoryMetadata artifactRepositoryMetaData = makeRepositoryMetaData(result.getRepository(), MavenRepositorySource.LOCAL); if (artifactRepositoryMetaData != null) { final MavenRepositoryMetadata artifactRepositoryMetaData = makeRepositoryMetaData(result.getRepository(), e.getKey()); if (artifactRepositoryMetaData != null) {
log.debug("Resolved artifact " + mavenArtifact.getDependency() + " to " + result.getArtifact().getFile() + " from " + result.getRepository());