use of org.eclipse.aether.deployment.DeployResult in project buck by facebook.
the class PublishCommand method publishTargets.
private boolean publishTargets(ImmutableList<BuildTarget> buildTargets, CommandRunnerParams params) {
ImmutableSet.Builder<MavenPublishable> publishables = ImmutableSet.builder();
boolean success = true;
for (BuildTarget buildTarget : buildTargets) {
BuildRule buildRule = null;
try {
buildRule = getBuild().getRuleResolver().requireRule(buildTarget);
} catch (NoSuchBuildTargetException e) {
// This doesn't seem physically possible!
throw new RuntimeException(e);
}
Preconditions.checkNotNull(buildRule);
if (!(buildRule instanceof MavenPublishable)) {
params.getBuckEventBus().post(ConsoleEvent.severe("Cannot publish rule of type %s", buildRule.getClass().getName()));
success &= false;
continue;
}
MavenPublishable publishable = (MavenPublishable) buildRule;
if (!publishable.getMavenCoords().isPresent()) {
params.getBuckEventBus().post(ConsoleEvent.severe("No maven coordinates specified for %s", buildTarget.getUnflavoredBuildTarget().getFullyQualifiedName()));
success &= false;
continue;
}
publishables.add(publishable);
}
Publisher publisher = new Publisher(params.getCell().getFilesystem(), Optional.ofNullable(remoteRepo), Optional.ofNullable(username), Optional.ofNullable(password), dryRun);
try {
ImmutableSet<DeployResult> deployResults = publisher.publish(new SourcePathResolver(new SourcePathRuleFinder(getBuild().getRuleResolver())), publishables.build());
for (DeployResult deployResult : deployResults) {
printArtifactsInformation(params, deployResult);
}
} catch (DeploymentException e) {
params.getConsole().printBuildFailureWithoutStacktraceDontUnwrap(e);
return false;
}
return success;
}
use of org.eclipse.aether.deployment.DeployResult in project buck by facebook.
the class Publisher method publish.
public ImmutableSet<DeployResult> publish(SourcePathResolver pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException {
ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables);
if (duplicateBuiltinBuileRules.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Duplicate transitive dependencies for publishable libraries found! This means");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("that the following libraries would have multiple copies if these libraries were");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("used together. The can be resolved by adding a maven URL to each target listed");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("below:");
for (UnflavoredBuildTarget unflavoredBuildTarget : duplicateBuiltinBuileRules.keySet()) {
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append(unflavoredBuildTarget.getFullyQualifiedName());
sb.append(" (referenced by these build targets: ");
Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTarget));
sb.append(")");
}
throw new DeploymentException(sb.toString());
}
ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder();
for (MavenPublishable publishable : publishables) {
DefaultArtifact coords = new DefaultArtifact(Preconditions.checkNotNull(publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable));
Path relativePathToOutput = pathResolver.getRelativePath(Preconditions.checkNotNull(publishable.getSourcePathToOutput(), "No path to output present in ", publishable));
File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile();
if (!coords.getClassifier().isEmpty()) {
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem)));
}
try {
// If this is the "main" artifact (denoted by lack of classifier) generate and publish
// pom alongside
File pom = Pom.generatePomFile(pathResolver, publishable).toFile();
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return deployResultBuilder.build();
}
use of org.eclipse.aether.deployment.DeployResult in project buck by facebook.
the class Publisher method publish.
/**
* @param toPublish each {@link Artifact} must contain a file, that will be published under maven
* coordinates in the corresponding {@link Artifact}.
* @see Artifact#setFile
*/
public DeployResult publish(List<Artifact> toPublish) throws DeploymentException {
RepositorySystem repoSys = Preconditions.checkNotNull(locator.getService(RepositorySystem.class));
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(repoSys.newLocalRepositoryManager(session, localRepo));
session.setReadOnly();
DeployRequest deployRequest = createDeployRequest(toPublish);
if (dryRun) {
return new DeployResult(deployRequest).setArtifacts(toPublish).setMetadata(deployRequest.getMetadata());
} else {
return repoSys.deploy(session, deployRequest);
}
}
use of org.eclipse.aether.deployment.DeployResult in project unleash-maven-plugin by shillner.
the class ArtifactDeployer method deployArtifacts.
/**
* Deploys the given artifacts to the configured remote Maven repositories.
*
* @param artifacts the artifacts to deploy.
* @return the artifacts that have been deployed successfully.
* @throws DeploymentException if anything goes wrong during the deployment process.
*/
public Collection<Artifact> deployArtifacts(Collection<Artifact> artifacts) throws DeploymentException {
DeployRequest request = new DeployRequest();
request.setArtifacts(artifacts);
request.setRepository(this.metadata.getDeploymentRepository());
DeployResult result = this.deployer.deploy(this.repoSession, request);
return result.getArtifacts();
}
Aggregations