use of com.facebook.buck.maven.Publisher 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;
}
Aggregations