private List<File> loadFromMvn(String artifact, Collection<String> excludes) throws RepositoryException { Collection<String> allExclusions = new LinkedList<>(); allExclusions.addAll(excludes); allExclusions.addAll(Arrays.asList(exclusions)); List<ArtifactResult> listOfArtifact; listOfArtifact = getArtifactsWithDep(artifact, allExclusions); Iterator<ArtifactResult> it = listOfArtifact.iterator(); while (it.hasNext()) { Artifact a = it.next().getArtifact(); String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion(); for (String exclude : allExclusions) { if (gav.startsWith(exclude)) { it.remove(); break; } } } List<File> files = new LinkedList<>(); for (ArtifactResult artifactResult : listOfArtifact) { files.add(artifactResult.getArtifact().getFile()); logger.debug("load {}", artifactResult.getArtifact().getFile().getAbsolutePath()); } return files; }
/** * fetch all artifacts * @return * @throws MalformedURLException * @throws ArtifactResolutionException * @throws DependencyResolutionException */ public List<File> fetch() throws MalformedURLException, DependencyResolutionException, ArtifactResolutionException { for (Dependency dep : dependencies) { if (!dep.isLocalFsArtifact()) { List<ArtifactResult> artifacts = fetchArtifactWithDep(dep); for (ArtifactResult artifact : artifacts) { if (dep.isDist()) { filesDist.add(artifact.getArtifact().getFile()); } files.add(artifact.getArtifact().getFile()); } } else { if (dep.isDist()) { filesDist.add(new File(dep.getGroupArtifactVersion())); } files.add(new File(dep.getGroupArtifactVersion())); } } return files; }
/** * Indicates whether the requested artifact was resolved. Note that the artifact might have been successfully * resolved despite {@link #getExceptions()} indicating transfer errors while trying to fetch the artifact from some * of the specified remote repositories. * * @return {@code true} if the artifact was resolved, {@code false} otherwise. * @see Artifact#getFile() */ public boolean isResolved() { return getArtifact() != null && getArtifact().getFile() != null; }
/** * Indicates whether the requested artifact was resolved. Note that the artifact might have been successfully * resolved despite {@link #getExceptions()} indicating transfer errors while trying to fetch the artifact from some * of the specified remote repositories. * * @return {@code true} if the artifact was resolved, {@code false} otherwise. * @see Artifact#getFile() */ public boolean isResolved() { return getArtifact() != null && getArtifact().getFile() != null; }
/** * Indicates whether the requested artifact was resolved. Note that the artifact might have been successfully * resolved despite {@link #getExceptions()} indicating transfer errors while trying to fetch the artifact from some * of the specified remote repositories. * * @return {@code true} if the artifact was resolved, {@code false} otherwise. * @see Artifact#getFile() */ public boolean isResolved() { return getArtifact() != null && getArtifact().getFile() != null; }
@Override public String toString() { return getArtifact() + " < " + getRepository(); }
protected static String artifactResultToFilePath(ArtifactResult result) { if (result != null) { Artifact artifact = result.getArtifact(); if (artifact != null) { File file = artifact.getFile(); if (file != null) { return file.getAbsolutePath(); } } } return null; }
@Override public String toString() { return getArtifact() + " < " + getRepository(); }
@Override public String toString() { return getArtifact() + " < " + getRepository(); }
public List<URL> resolve(File rootPom, boolean offline) throws RepositoryException { List<ArtifactResult> results = resolveResult(rootPom, offline); List<URL> urls = new ArrayList<URL>(); for (ArtifactResult r : results) { try { urls.add(r.getArtifact().getFile().toURI().toURL()); } catch (MalformedURLException e) { // Should never happen throw new RuntimeException(e); } } return urls; }
public List<URL> resolve(File rootPom, boolean offline) throws RepositoryException { List<ArtifactResult> results = resolveResult(rootPom, offline); List<URL> urls = new ArrayList<URL>(); for (ArtifactResult r : results) { try { urls.add(r.getArtifact().getFile().toURI().toURL()); } catch (MalformedURLException e) { // Should never happen throw new RuntimeException(e); } } return urls; }
private org.sonatype.aether.artifact.Artifact getResolvedSideArtifact( final org.sonatype.aether.artifact.Artifact sideArtifact, final ArtifactResult result) throws SideArtifactNotFoundException { org.sonatype.aether.artifact.Artifact resolvedArtifact = result.getArtifact(); final File artifactFile = resolvedArtifact.getFile(); if (artifactFile == null || !artifactFile.exists()) throw new SideArtifactNotFoundException("Problems with resolving artifact \"" + sideArtifact + "\". The file that corresponds to that artifact (" + artifactFile + ") should be present in local repo but could not be found.", sideArtifact); return resolvedArtifact; }
@Override protected File resolveArtifact(Artifact a) throws ArtifactResolutionException { return rs.resolveArtifact(a).getArtifact().getFile(); } }
private void updateNodesWithResolvedArtifacts( List<ArtifactResult> results ) { for ( ArtifactResult result : results ) { Artifact artifact = result.getArtifact(); if ( artifact != null ) { result.getRequest().getDependencyNode().setArtifact( artifact ); } } }
@Override protected File resolveArtifact(Artifact a) throws ArtifactResolutionException { return getRepositoryService().resolveArtifact(a).getArtifact().getFile(); } };
private void updateNodesWithResolvedArtifacts( List<ArtifactResult> results ) { for ( ArtifactResult result : results ) { Artifact artifact = result.getArtifact(); if ( artifact != null ) { result.getRequest().getDependencyNode().setArtifact( artifact ); } } }
public Artifact resolveArtifact(boolean offline, String groupId, String artifactId, String version, String classifier, String extension) throws ArtifactResolutionException { RepositorySystem repo = getRepositorySystem(); MavenRepositorySystemSession session = createSession(offline, repo); Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); List<RemoteRepository> repos = getRemoteRepositories(); ArtifactRequest request = new ArtifactRequest(artifact, repos, null); ArtifactResult result = repo.resolveArtifact(session, request); return result.getArtifact(); }
public Artifact resolveArtifact(boolean offline, String groupId, String artifactId, String version, String classifier, String extension) throws ArtifactResolutionException { RepositorySystem repo = getRepositorySystem(); MavenRepositorySystemSession session = createSession(offline, repo); Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); List<RemoteRepository> repos = getRemoteRepositories(); ArtifactRequest request = new ArtifactRequest(artifact, repos, null); ArtifactResult result = repo.resolveArtifact(session, request); return result.getArtifact(); }
public File resolveFile(Artifact root) throws ArtifactResolutionException { RepositorySystem repositorySystem = getRepositorySystem(); final MavenRepositorySystemSession session = createRepositorSystemSession(offline, repositorySystem); List<RemoteRepository> repos = getRemoteRepositories(); ArtifactRequest request = new ArtifactRequest(); request.setArtifact(root); request.setRepositories(repos); request.setRequestContext("runtime"); ArtifactResult result = repositorySystem.resolveArtifact(session, request); return result.getArtifact().getFile(); }
public File resolveFile(Artifact root) throws ArtifactResolutionException { RepositorySystem repositorySystem = getRepositorySystem(); final MavenRepositorySystemSession session = createRepositorSystemSession(offline, repositorySystem); List<RemoteRepository> repos = getRemoteRepositories(); ArtifactRequest request = new ArtifactRequest(); request.setArtifact(root); request.setRepositories(repos); request.setRequestContext("runtime"); ArtifactResult result = repositorySystem.resolveArtifact(session, request); return result.getArtifact().getFile(); }