Search in sources :

Example 1 with SubArtifact

use of org.eclipse.aether.util.artifact.SubArtifact 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);
}
Also used : SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) ArrayList(java.util.ArrayList) File(java.io.File) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact)

Example 2 with SubArtifact

use of org.eclipse.aether.util.artifact.SubArtifact 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);
    }
}
Also used : Path(java.nio.file.Path) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

Artifact (org.eclipse.aether.artifact.Artifact)2 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)2 SubArtifact (org.eclipse.aether.util.artifact.SubArtifact)2 File (java.io.File)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1