Search in sources :

Example 91 with BuckConfig

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());
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

Example 92 with BuckConfig

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));
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

Example 93 with BuckConfig

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());
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

Example 94 with BuckConfig

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);
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) TargetNode(com.facebook.buck.rules.TargetNode) Optional(java.util.Optional) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) JvmLibraryArg(com.facebook.buck.jvm.java.JvmLibraryArg) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)

Example 95 with BuckConfig

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());
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Aggregations

BuckConfig (com.facebook.buck.cli.BuckConfig)98 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)89 Test (org.junit.Test)74 Path (java.nio.file.Path)46 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)37 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)29 PathSourcePath (com.facebook.buck.rules.PathSourcePath)27 Cell (com.facebook.buck.rules.Cell)22 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 Config (com.facebook.buck.config.Config)15 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)14 BuildTarget (com.facebook.buck.model.BuildTarget)12 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)9 ParserConfig (com.facebook.buck.parser.ParserConfig)8 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)7 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)7 TestConsole (com.facebook.buck.testutil.TestConsole)7 Optional (java.util.Optional)7 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)6