use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class StackedDownloaderTest method shouldThrowReadableExceptionWhenUrlPathDoesntExist.
@Test
public void shouldThrowReadableExceptionWhenUrlPathDoesntExist() {
String pathNotExist = "file://not/a/valid/path";
BuckConfig config = FakeBuckConfig.builder().setSections("[download]", String.format("maven_repo = %s", pathNotExist)).build();
thrown.expect(HumanReadableException.class);
thrown.expectMessage(String.format("Error occurred when attempting to use %s " + "as a local Maven repository as configured", pathNotExist));
StackedDownloader.createFromConfig(config, Optional.empty());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class StackedDownloaderTest method shouldFallBackToTheDeprecatedMechanismForCreatingMavenRepos.
@Test
public void shouldFallBackToTheDeprecatedMechanismForCreatingMavenRepos() throws IOException {
// Set up a config so we expect to see both a local and a remote maven repo.
BuckConfig config = FakeBuckConfig.builder().setSections("[download]", "maven_repo = https://repo1.maven.org/maven2").build();
Downloader downloader = StackedDownloader.createFromConfig(config, Optional.empty());
assertThat(downloader, includes(RemoteMavenDownloader.class));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class StackedDownloaderTest method shouldThrowReadableExceptionWhenPathDoesntExist.
@Test
public void shouldThrowReadableExceptionWhenPathDoesntExist() {
String pathNotExist = "//not/a/valid/path";
BuckConfig config = FakeBuckConfig.builder().setSections("[download]", String.format("maven_repo = %s", pathNotExist)).build();
thrown.expect(HumanReadableException.class);
thrown.expectMessage(String.format("Error occurred when attempting to use %s " + "as a local Maven repository as configured", pathNotExist));
StackedDownloader.createFromConfig(config, Optional.empty());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class IjModuleGraphTest method createModuleGraph.
public static IjModuleGraph createModuleGraph(ImmutableSet<TargetNode<?, ?>> targets, final ImmutableMap<TargetNode<?, ?>, SourcePath> javaLibraryPaths, final Function<? super TargetNode<?, ?>, Optional<Path>> rDotJavaClassPathResolver, AggregationMode aggregationMode) {
final SourcePathResolver sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
IjLibraryFactoryResolver sourceOnlyResolver = new IjLibraryFactoryResolver() {
@Override
public Path getPath(SourcePath path) {
return sourcePathResolver.getAbsolutePath(path);
}
@Override
public Optional<SourcePath> getPathIfJavaLibrary(TargetNode<?, ?> targetNode) {
return Optional.ofNullable(javaLibraryPaths.get(targetNode));
}
};
BuckConfig buckConfig = FakeBuckConfig.builder().build();
IjProjectConfig projectConfig = IjProjectBuckConfig.create(buckConfig);
IjModuleFactory moduleFactory = new IjModuleFactory(new FakeProjectFilesystem(), new IjModuleFactoryResolver() {
@Override
public Optional<Path> getDummyRDotJavaPath(TargetNode<?, ?> targetNode) {
return rDotJavaClassPathResolver.apply(targetNode);
}
@Override
public Path getAndroidManifestPath(TargetNode<AndroidBinaryDescription.Arg, ?> targetNode) {
return Paths.get("TestAndroidManifest.xml");
}
@Override
public Optional<Path> getLibraryAndroidManifestPath(TargetNode<AndroidLibraryDescription.Arg, ?> targetNode) {
return Optional.empty();
}
@Override
public Optional<Path> getProguardConfigPath(TargetNode<AndroidBinaryDescription.Arg, ?> targetNode) {
return Optional.empty();
}
@Override
public Optional<Path> getAndroidResourcePath(TargetNode<AndroidResourceDescription.Arg, ?> targetNode) {
return Optional.empty();
}
@Override
public Optional<Path> getAssetsPath(TargetNode<AndroidResourceDescription.Arg, ?> targetNode) {
return Optional.empty();
}
@Override
public Optional<Path> getAnnotationOutputPath(TargetNode<? extends JvmLibraryArg, ?> targetNode) {
return Optional.empty();
}
}, projectConfig, false);
IjLibraryFactory libraryFactory = new DefaultIjLibraryFactory(sourceOnlyResolver);
return IjModuleGraph.from(projectConfig, TargetGraphFactory.newInstance(targets), libraryFactory, moduleFactory, aggregationMode);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KotlinBuckConfigTest method testFindsKotlinCompilerInPath.
@Test
public void testFindsKotlinCompilerInPath() throws HumanReadableException, IOException {
// Get faux kotlinc binary location in project
Path kotlinPath = workspace.resolve("bin");
Path kotlinCompiler = kotlinPath.resolve("kotlinc");
MoreFiles.makeExecutable(kotlinCompiler);
BuckConfig buckConfig = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", kotlinPath.toString() + pathSeparator + System.getenv("PATH"))).build();
KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
String command = kotlinBuckConfig.getKotlinCompiler().get().getCommandPrefix(null).get(0);
assertEquals(command, kotlinCompiler.toString());
}
Aggregations