Search in sources :

Example 1 with BuildTargetSpec

use of com.facebook.buck.parser.BuildTargetSpec in project buck by facebook.

the class PublishCommand method parseArgumentsAsTargetNodeSpecs.

@Override
public ImmutableList<TargetNodeSpec> parseArgumentsAsTargetNodeSpecs(BuckConfig config, Iterable<String> targetsAsArgs) {
    ImmutableList<TargetNodeSpec> specs = super.parseArgumentsAsTargetNodeSpecs(config, targetsAsArgs);
    if (includeSource) {
        specs = ImmutableList.<TargetNodeSpec>builder().addAll(specs).addAll(specs.stream().filter(input -> {
            if (!(input instanceof BuildTargetSpec)) {
                throw new IllegalArgumentException("Targets must be explicitly defined when using " + INCLUDE_SOURCE_LONG_ARG);
            }
            return !((BuildTargetSpec) input).getBuildTarget().getFlavors().contains(JavaLibrary.SRC_JAR);
        }).map(input -> BuildTargetSpec.of(((BuildTargetSpec) input).getBuildTarget().withFlavors(JavaLibrary.SRC_JAR), input.getBuildFileSpec())).iterator()).build();
    }
    // Append "maven" flavor
    specs = specs.stream().map(input -> {
        if (!(input instanceof BuildTargetSpec)) {
            throw new IllegalArgumentException("Need to specify build targets explicitly when publishing. " + "Cannot modify " + input);
        }
        BuildTargetSpec buildTargetSpec = (BuildTargetSpec) input;
        BuildTarget buildTarget = Preconditions.checkNotNull(buildTargetSpec.getBuildTarget());
        return buildTargetSpec.withBuildTarget(BuildTarget.builder(buildTarget).addFlavors(JavaLibrary.MAVEN_JAR).build());
    }).collect(MoreCollectors.toImmutableList());
    return specs;
}
Also used : DeployResult(org.eclipse.aether.deployment.DeployResult) URL(java.net.URL) TargetNodeSpec(com.facebook.buck.parser.TargetNodeSpec) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) JavaLibrary(com.facebook.buck.jvm.java.JavaLibrary) ConsoleEvent(com.facebook.buck.event.ConsoleEvent) BuildRule(com.facebook.buck.rules.BuildRule) ImmutableList(com.google.common.collect.ImmutableList) FluentIterable(com.google.common.collect.FluentIterable) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildTargetSpec(com.facebook.buck.parser.BuildTargetSpec) Nullable(javax.annotation.Nullable) MoreCollectors(com.facebook.buck.util.MoreCollectors) ImmutableSet(com.google.common.collect.ImmutableSet) MavenPublishable(com.facebook.buck.jvm.java.MavenPublishable) Artifact(org.eclipse.aether.artifact.Artifact) IOException(java.io.IOException) Option(org.kohsuke.args4j.Option) BuildTarget(com.facebook.buck.model.BuildTarget) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) Publisher(com.facebook.buck.maven.Publisher) DeploymentException(org.eclipse.aether.deployment.DeploymentException) Joiner(com.google.common.base.Joiner) BuildTarget(com.facebook.buck.model.BuildTarget) BuildTargetSpec(com.facebook.buck.parser.BuildTargetSpec) TargetNodeSpec(com.facebook.buck.parser.TargetNodeSpec)

Aggregations

ConsoleEvent (com.facebook.buck.event.ConsoleEvent)1 JavaLibrary (com.facebook.buck.jvm.java.JavaLibrary)1 MavenPublishable (com.facebook.buck.jvm.java.MavenPublishable)1 Publisher (com.facebook.buck.maven.Publisher)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildTargetSpec (com.facebook.buck.parser.BuildTargetSpec)1 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)1 TargetNodeSpec (com.facebook.buck.parser.TargetNodeSpec)1 BuildRule (com.facebook.buck.rules.BuildRule)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 MoreCollectors (com.facebook.buck.util.MoreCollectors)1 Joiner (com.google.common.base.Joiner)1 Preconditions (com.google.common.base.Preconditions)1 FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Optional (java.util.Optional)1