Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Change ArtifactCacheFactory to not depend on AbstractCommandOptions.
Browse files Browse the repository at this point in the history
Summary:
ArtifactCacheFactory needs AbstractCommandOptions to know whether the
artifact cache it creates should be no-op or not. This changes it to
require a boolean for that information instead.

Test Plan: CI
  • Loading branch information
Uri Baghin authored and sdwilsh committed May 13, 2015
1 parent c79b4ee commit 923718e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/com/facebook/buck/cli/AbstractCommandRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ protected ImmutableSet<BuildTarget> getBuildTargets(

public ArtifactCache getArtifactCache(CommandRunnerParams params, T options)
throws InterruptedException {
return params.getArtifactCacheFactory().newInstance(params.getBuckConfig(), options);
return params
.getArtifactCacheFactory()
.newInstance(params.getBuckConfig(), options.isNoCache());
}

private static class ParserAndOptions<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/com/facebook/buck/cli/ArtifactCacheFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public interface ArtifactCacheFactory {

public ArtifactCache newInstance(BuckConfig buckConfig, AbstractCommandOptions options)
public ArtifactCache newInstance(BuckConfig buckConfig, boolean noop)
throws InterruptedException;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/com/facebook/buck/cli/LoggingArtifactCacheFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public LoggingArtifactCacheFactory(
}

@Override
public ArtifactCache newInstance(BuckConfig buckConfig, AbstractCommandOptions options)
public ArtifactCache newInstance(BuckConfig buckConfig, boolean noop)
throws InterruptedException {
if (options.isNoCache()) {
if (noop) {
return new NoopArtifactCache();
} else {
buckEventBus.post(ArtifactCacheConnectEvent.started());
Expand Down
4 changes: 2 additions & 2 deletions test/com/facebook/buck/cli/InstanceArtifactCacheFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* An implementation of {@link ArtifactCacheFactory} used for testing that always returns the
* instance of {@link ArtifactCache} passed to its constructor when its
* {@link #newInstance(BuckConfig, AbstractCommandOptions)} method is invoked.
* {@link #newInstance(BuckConfig, boolean)} method is invoked.
*/
public class InstanceArtifactCacheFactory implements ArtifactCacheFactory {

Expand All @@ -35,7 +35,7 @@ public InstanceArtifactCacheFactory(ArtifactCache artifactCache) {
}

@Override
public ArtifactCache newInstance(BuckConfig buckConfig, AbstractCommandOptions options) {
public ArtifactCache newInstance(BuckConfig buckConfig, boolean noop) {
return artifactCache;
}

Expand Down

0 comments on commit 923718e

Please sign in to comment.