use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Publisher method publish.
/**
* @param descriptor an {@link Artifact}, holding the maven coordinates for the published files
* less the extension that is to be derived from the files.
* The {@code descriptor} itself will not be published as is, and the
* {@link File} attached to it (if any) will be ignored.
* @param toPublish {@link File}(s) to be published using the given coordinates. The filename
* extension of each given file will be used as a maven "extension" coordinate
*/
public DeployResult publish(Artifact descriptor, List<File> toPublish) throws DeploymentException {
String providedExtension = descriptor.getExtension();
if (!providedExtension.isEmpty()) {
LOG.warn("Provided extension %s of artifact %s to be published will be ignored. The extensions " + "of the provided file(s) will be used", providedExtension, descriptor);
}
List<Artifact> artifacts = new ArrayList<>(toPublish.size());
for (File file : toPublish) {
artifacts.add(new SubArtifact(descriptor, descriptor.getClassifier(), Files.getFileExtension(file.getAbsolutePath()), file));
}
return publish(artifacts);
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method getDependenciesFromPom.
private ImmutableList<Dependency> getDependenciesFromPom(Model model) {
return model.getDependencies().stream().map(dep -> {
ArtifactType stereotype = session.getArtifactTypeRegistry().get(dep.getType());
if (stereotype == null) {
stereotype = new DefaultArtifactType(dep.getType());
}
Map<String, String> props = null;
boolean system = dep.getSystemPath() != null && dep.getSystemPath().length() > 0;
if (system) {
props = ImmutableMap.of(ArtifactProperties.LOCAL_PATH, dep.getSystemPath());
}
@SuppressWarnings("PMD.PrematureDeclaration") DefaultArtifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), null, dep.getVersion(), props, stereotype);
ImmutableList<Exclusion> exclusions = FluentIterable.from(dep.getExclusions()).transform(input -> {
String group = input.getGroupId();
String artifact1 = input.getArtifactId();
group = (group == null || group.length() == 0) ? "*" : group;
artifact1 = (artifact1 == null || artifact1.length() == 0) ? "*" : artifact1;
return new Exclusion(group, artifact1, "*", "*");
}).toList();
return new Dependency(artifact, dep.getScope(), dep.isOptional(), exclusions);
}).collect(MoreCollectors.toImmutableList());
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method resolveLib.
private Prebuilt resolveLib(Artifact artifact, Path project) throws ArtifactResolutionException, IOException {
Artifact jar = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), "jar", artifact.getVersion());
Path relativePath = resolveArtifact(jar, project);
Prebuilt library = new Prebuilt(jar.getArtifactId(), jar.toString(), relativePath);
downloadSources(jar, project, library);
return library;
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method downloadSources.
private void downloadSources(Artifact artifact, Path project, Prebuilt library) throws IOException {
Artifact srcs = new SubArtifact(artifact, "sources", "jar");
try {
Path relativePath = resolveArtifact(srcs, project);
library.setSourceJar(relativePath);
} catch (ArtifactResolutionException e) {
System.err.println("Skipping sources for: " + srcs);
}
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method getRunTimeTransitiveDeps.
private ImmutableMap<String, Artifact> getRunTimeTransitiveDeps(Iterable<Dependency> mavenCoords) throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRequestContext(JavaScopes.RUNTIME);
collectRequest.setRepositories(repos);
for (Dependency dep : mavenCoords) {
collectRequest.addDependency(dep);
}
DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, filter);
DependencyResult dependencyResult = repoSys.resolveDependencies(session, dependencyRequest);
ImmutableSortedMap.Builder<String, Artifact> knownDeps = ImmutableSortedMap.naturalOrder();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
Artifact node = artifactResult.getArtifact();
knownDeps.put(buildKey(node), node);
}
return knownDeps.build();
}
Aggregations