use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Publisher method createDeployRequest.
private DeployRequest createDeployRequest(List<Artifact> toPublish) {
DeployRequest deployRequest = new DeployRequest().setRepository(remoteRepo);
for (Artifact artifact : toPublish) {
File file = artifact.getFile();
Preconditions.checkNotNull(file);
Preconditions.checkArgument(file.exists(), "No such file: %s", file.getAbsolutePath());
deployRequest.addArtifact(artifact);
}
return deployRequest;
}
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);
}
}
Aggregations