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; }
public String getVersion() { return delegate.getVersion(); }
public String getVersion() { return delegate.getVersion(); }
public String getVersion() { return mainArtifact.getVersion(); }
static String nameOf( final Artifact artifact ) { final StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.getClassifier().length() > 0 ) { path.append( '-' ).append( artifact.getClassifier() ); } path.append( '.' ).append( artifact.getExtension() ); return path.toString(); }
private static String artifactCoords(Artifact artifact) { String groupId = artifact.getGroupId(); String artifactId = artifact.getArtifactId(); String extension = artifact.getExtension(); String classifier = artifact.getClassifier(); String version = artifact.getVersion(); StringBuilder b = new StringBuilder() .append(groupId).append(":") .append(artifactId).append(":"); if (!extension.equals("jar") || !classifier.equals("")) { b.append(extension).append(":"); if (!classifier.equals("")) b.append(classifier).append(":"); } b.append(version); return b.toString(); }
public static String pathOf( final Artifact artifact ) { final StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); path.append( artifact.getArtifactId() ).append( '/' ); path.append( artifact.getBaseVersion() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.getClassifier().length() > 0 ) { path.append( '-' ).append( artifact.getClassifier() ); } path.append( '.' ).append( artifact.getExtension() ); return path.toString(); }
public File findArtifact( Artifact artifact ) { String projectKey = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getVersion(); MavenProject project = projectsByGAV.get( projectKey ); if ( project != null ) { return find( project, artifact ); } return null; }
public String getPathForLocalArtifact( Artifact artifact ) { String artifactId = artifact.getArtifactId(); String groupId = artifact.getGroupId(); String extension = artifact.getExtension(); String version = artifact.getVersion(); String classifier = artifact.getClassifier(); String path = String.format( "%s/%s/%s/%s-%s-%s%s.%s", groupId, artifactId, version, groupId, artifactId, version, classifier, extension ); return path; }
private DefaultArtifact getSideArtifact(final org.sonatype.aether.artifact.Artifact mainArtifact, final String classifier, String type) { return new DefaultArtifact(mainArtifact.getGroupId(), mainArtifact.getArtifactId(), classifier, type, mainArtifact.getVersion()); } }
public DependencyTree(DependencyId dependencyId, Dependency dependency, List<DependencyTree> children) { this(dependencyId, dependency.getArtifact().getVersion(), children); this.scope = dependency.getScope(); this.optional = dependency.isOptional(); }
public String getPathForLocalArtifact( Artifact artifact ) { String artifactId = artifact.getArtifactId(); String groupId = artifact.getGroupId(); String extension = artifact.getExtension(); String version = artifact.getVersion(); String classifier = artifact.getClassifier(); String path = String.format( "%s/%s/%s/%s-%s-%s%s.%s", groupId, artifactId, version, groupId, artifactId, version, classifier, extension ); return path; }
public VersionRangeResult resolveVersions(String groupId, String artifactId, String classifier, String extension, String version) { final RepositorySystemSession session = newSession(); Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version); if (artifact.getVersion().equals("LATEST")) { artifact = artifact.setVersion(LATEST_VERSION_RANGE); } final VersionRangeRequest request = new VersionRangeRequest(artifact, m_remoteRepos, null); try { return m_repoSystem.resolveVersionRange(session, request); } catch (VersionRangeResolutionException e) { final VersionRangeResult result = new VersionRangeResult(request); result.setVersions(Arrays.asList((Version) new VersionImpl(version))); return result; } }
public static String gavOf(Dependency d) { return d.getArtifact().getGroupId() + ":" + d.getArtifact().getArtifactId() + ":" + d.getArtifact().getVersion(); }
private boolean isNewer(Artifact a1, Artifact a2) { if (Objects.equal(a1.getGroupId(), a2.getGroupId()) && Objects.equal(a1.getArtifactId(), a2.getArtifactId()) && Objects.equal(a1.getExtension(), a2.getExtension()) && Objects.equal(a1.getClassifier(), a2.getClassifier())) { String v1 = a1.getVersion(); String v2 = a2.getVersion(); if (!Objects.equal(v1, v2)) { int c = v1.compareTo(v2); return c > 0; } } return false; } }
private boolean isNewer(Artifact a1, Artifact a2) { if (Objects.equal(a1.getGroupId(), a2.getGroupId()) && Objects.equal(a1.getArtifactId(), a2.getArtifactId()) && Objects.equal(a1.getExtension(), a2.getExtension()) && Objects.equal(a1.getClassifier(), a2.getClassifier())) { String v1 = a1.getVersion(); String v2 = a2.getVersion(); if (!Objects.equal(v1, v2)) { int c = v1.compareTo(v2); return c > 0; } } return false; } }
private MavenBundle(Artifact artifact, boolean forceVersionAsInProject) { groupId(artifact.getGroupId()); artifactId(artifact.getArtifactId()); type(artifact.getExtension()); classifier(artifact.getClassifier()); if (!forceVersionAsInProject) version(artifact.getVersion()); }
private Artifact getDependencyArtifact( Dependency dep ) { org.sonatype.aether.artifact.Artifact artifact = dep.getArtifact(); return factory.createDependencyArtifact( artifact.getGroupId(), artifact.getArtifactId(), VersionRange.createFromVersion( artifact.getVersion() ), artifact.getProperty( "type", artifact.getExtension() ), artifact.getClassifier(), dep.getScope(), dep.isOptional() ); }
public MavenDependencyAdapter(final org.sonatype.aether.graph.Dependency dep) { if (dep == null) { throw new IllegalArgumentException("Dependency must not be null."); } this.setArtifactId(dep.getArtifact().getArtifactId()); this.setGroupId(dep.getArtifact().getGroupId()); this.setClassifier("".equals(dep.getArtifact().getClassifier()) ? null : dep.getArtifact().getClassifier()); this.setExclusions(dep.getExclusions()); this.setOptional(dep.isOptional()); this.setScope(dep.getScope()); this.setType(dep.getArtifact().getExtension()); this.setVersion(dep.getArtifact().getVersion()); }
private static ArtifactRef createArtifact(final DependencyNode node) { final Artifact artifact = node.getDependency().getArtifact(); final ArtifactId.Builder builder = new ArtifactId.Builder(); final String classifier = normalize(artifact); builder.withGroupId(artifact.getGroupId()) .withName(artifact.getArtifactId()).withVersion(artifact.getVersion()) .withArchiveType(artifact.getExtension()).withClassifier(classifier); final ArtifactId id = builder.build(); final File file = artifact.getFile(); final URL url = toUrl(file); final ArtifactRef ref = new ArtifactRef(id, url); return ref; }