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;
}
Aggregations