Search in sources :

Example 56 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class CsharpLibrary method resolveReferences.

private ImmutableList<Either<Path, String>> resolveReferences(SourcePathResolver pathResolver, ImmutableList<Either<BuildRule, String>> refs) {
    ImmutableList.Builder<Either<Path, String>> resolved = ImmutableList.builder();
    for (Either<BuildRule, String> ref : refs) {
        if (ref.isLeft()) {
            // TODO(shs96c): Do this in the constructor? Or the Description?
            BuildRule rule = ref.getLeft();
            Preconditions.checkArgument(rule instanceof CsharpLibrary || rule instanceof PrebuiltDotnetLibrary);
            SourcePath outputPath = Preconditions.checkNotNull(rule.getSourcePathToOutput());
            resolved.add(Either.ofLeft(pathResolver.getAbsolutePath(outputPath)));
        } else {
            resolved.add(Either.ofRight(ref.getRight()));
        }
    }
    return resolved.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableList(com.google.common.collect.ImmutableList) Either(com.facebook.buck.model.Either) AbstractBuildRule(com.facebook.buck.rules.AbstractBuildRule) BuildRule(com.facebook.buck.rules.BuildRule)

Example 57 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class CsharpLibrary method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ProjectFilesystem filesystem = getProjectFilesystem();
    ImmutableSortedSet<Path> sourceFiles = context.getSourcePathResolver().getAllAbsolutePaths(srcs);
    ImmutableListMultimap.Builder<Path, String> resolvedResources = ImmutableListMultimap.builder();
    for (Map.Entry<String, SourcePath> resource : resources.entrySet()) {
        resolvedResources.put(context.getSourcePathResolver().getAbsolutePath(resource.getValue()), resource.getKey());
    }
    ImmutableList<Either<Path, String>> references = resolveReferences(context.getSourcePathResolver(), refs);
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MakeCleanDirectoryStep(filesystem, output.getParent()));
    steps.add(new CsharpLibraryCompile(filesystem.resolve(output), sourceFiles, references, resolvedResources.build(), version));
    return steps.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Either(com.facebook.buck.model.Either) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 58 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class PrebuiltDotnetLibrary method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new RmStep(getProjectFilesystem(), output));
    steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
    steps.add(CopyStep.forFile(getProjectFilesystem(), getResolver().getAbsolutePath(assembly), output));
    return steps.build();
}
Also used : RmStep(com.facebook.buck.step.fs.RmStep) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) RmStep(com.facebook.buck.step.fs.RmStep) Step(com.facebook.buck.step.Step) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

Example 59 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class PublicAnnouncementManager method getAndPostAnnouncements.

public void getAndPostAnnouncements() {
    final ListenableFuture<ImmutableList<Announcement>> message = service.submit(() -> {
        Optional<ClientSideSlb> slb = logConfig.getFrontendConfig().tryCreatingClientSideSlb(clock, eventBus, new CommandThreadFactory("PublicAnnouncement"));
        if (slb.isPresent()) {
            try (FrontendService frontendService = new FrontendService(ThriftOverHttpServiceConfig.of(new LoadBalancedService(slb.get(), logConfig.createOkHttpClient(), eventBus)))) {
                AnnouncementRequest announcementRequest = new AnnouncementRequest();
                announcementRequest.setBuckVersion(getBuckVersion());
                announcementRequest.setRepository(repository);
                FrontendRequest request = new FrontendRequest();
                request.setType(FrontendRequestType.ANNOUNCEMENT);
                request.setAnnouncementRequest(announcementRequest);
                FrontendResponse response = frontendService.makeRequest(request);
                return ImmutableList.copyOf(response.announcementResponse.announcements);
            } catch (IOException e) {
                throw new HumanReadableException("Failed to perform request", e);
            }
        } else {
            throw new HumanReadableException("Failed to establish connection to server.");
        }
    });
    Futures.addCallback(message, new FutureCallback<ImmutableList<Announcement>>() {

        @Override
        public void onSuccess(ImmutableList<Announcement> announcements) {
            LOG.info("Public announcements fetched successfully.");
            if (!announcements.isEmpty()) {
                String announcement = HEADER_MSG;
                for (Announcement entry : announcements) {
                    announcement = announcement.concat(String.format(ANNOUNCEMENT_TEMPLATE, entry.getErrorMessage(), entry.getSolutionMessage()));
                }
                consoleEventBusListener.setPublicAnnouncements(eventBus, Optional.of(announcement));
            }
        }

        @Override
        public void onFailure(Throwable t) {
            LOG.warn("Failed to get public announcements. Reason: %s", t.getMessage());
        }
    });
}
Also used : Announcement(com.facebook.buck.distributed.thrift.Announcement) ImmutableList(com.google.common.collect.ImmutableList) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) IOException(java.io.IOException) ClientSideSlb(com.facebook.buck.slb.ClientSideSlb) HumanReadableException(com.facebook.buck.util.HumanReadableException) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendService(com.facebook.buck.distributed.FrontendService) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) LoadBalancedService(com.facebook.buck.slb.LoadBalancedService) AnnouncementRequest(com.facebook.buck.distributed.thrift.AnnouncementRequest)

Example 60 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class GoAssembleStep method getShellCommandInternal.

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    ImmutableList.Builder<String> commandBuilder = ImmutableList.<String>builder().addAll(asmCommandPrefix).add("-trimpath", workingDirectory.toString()).addAll(flags).add("-D", "GOOS_" + platform.getGoOs()).add("-D", "GOARCH_" + platform.getGoArch()).add("-o", output.toString());
    for (Path dir : includeDirectories) {
        commandBuilder.add("-I", dir.toString());
    }
    commandBuilder.add(src.toString());
    return commandBuilder.build();
}
Also used : Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1042 List (java.util.List)287 ArrayList (java.util.ArrayList)160 Test (org.junit.Test)155 Path (java.nio.file.Path)149 Map (java.util.Map)142 ImmutableMap (com.google.common.collect.ImmutableMap)122 IOException (java.io.IOException)110 Set (java.util.Set)97 ImmutableSet (com.google.common.collect.ImmutableSet)96 SourcePath (com.facebook.buck.rules.SourcePath)91 Optional (java.util.Optional)87 HashMap (java.util.HashMap)80 Step (com.facebook.buck.step.Step)76 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)66 Collectors (java.util.stream.Collectors)60 File (java.io.File)57 HashSet (java.util.HashSet)55 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)52 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)52