Search in sources :

Example 1 with Publisher

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;
}
Also used : Publisher(com.facebook.buck.maven.Publisher) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) MavenPublishable(com.facebook.buck.jvm.java.MavenPublishable) ImmutableSet(com.google.common.collect.ImmutableSet) DeployResult(org.eclipse.aether.deployment.DeployResult) BuildTarget(com.facebook.buck.model.BuildTarget) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) BuildRule(com.facebook.buck.rules.BuildRule) DeploymentException(org.eclipse.aether.deployment.DeploymentException)

Aggregations

MavenPublishable (com.facebook.buck.jvm.java.MavenPublishable)1 Publisher (com.facebook.buck.maven.Publisher)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)1 BuildRule (com.facebook.buck.rules.BuildRule)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 DeployResult (org.eclipse.aether.deployment.DeployResult)1 DeploymentException (org.eclipse.aether.deployment.DeploymentException)1