本文整理匯總了Java中com.facebook.buck.model.BuildTarget類的典型用法代碼示例。如果您正苦於以下問題:Java BuildTarget類的具體用法?Java BuildTarget怎麽用?Java BuildTarget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BuildTarget類屬於com.facebook.buck.model包,在下文中一共展示了BuildTarget類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testObserverMethods
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void testObserverMethods() {
JavaLibrary accumulateClassNames = createMock(JavaLibrary.class);
expect(accumulateClassNames.getClassNamesToHashes())
.andReturn(ImmutableSortedMap.of("com/example/Foo", HashCode.fromString("cafebabe")))
.anyTimes();
replayAll();
BuildTarget buildTarget = BuildTarget.builder("//foo", "bar").build();
BuildRuleParams params = new FakeBuildRuleParamsBuilder(buildTarget).build();
DexProducedFromJavaLibrary preDexWithClasses =
new DexProducedFromJavaLibrary(params, accumulateClassNames);
assertNull(preDexWithClasses.getPathToOutputFile());
assertTrue(Iterables.isEmpty(preDexWithClasses.getInputsToCompareToOutput()));
assertEquals(Paths.get("buck-out/gen/foo/bar.dex.jar"), preDexWithClasses.getPathToDex());
assertTrue(preDexWithClasses.hasOutput());
verifyAll();
}
開發者ID:saleehk,項目名稱:buck-cutom,代碼行數:21,代碼來源:DexProducedFromJavaLibraryThatContainsClassFilesTest.java
示例2: getAnnotationProcessingTargets
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
ImmutableList<String> getAnnotationProcessingTargets(ProjectCommandOptions options)
throws BuildTargetException, BuildFileParseException, IOException, InterruptedException {
return ImmutableList.copyOf(
Iterables.transform(
Iterables.getOnlyElement(
createPartialGraphs(
Optional.of(ANNOTATION_PREDICATE),
Optional.<RuleJsonPredicate>absent(),
Optional.<AssociatedRulePredicate>absent(),
options))
.getTargets(),
new Function<BuildTarget, String>() {
@Override
public String apply(BuildTarget target) {
return target.getFullyQualifiedName();
}
}));
}
示例3: testGeneratedSourceFile
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
/**
* If the source paths specified are all generated files, then our path to source tmp
* should be absent.
*/
@Test
public void testGeneratedSourceFile() {
Path pathToGenFile = GEN_PATH.resolve("GeneratedFile.java");
assertTrue(MorePaths.isGeneratedFile(pathToGenFile));
ImmutableSortedSet<Path> javaSrcs = ImmutableSortedSet.of(pathToGenFile);
JavaLibrary javaLibrary = new FakeJavaLibrary(BuildTarget.builder("//foo", "bar").build())
.setJavaSrcs(javaSrcs);
DefaultJavaPackageFinder defaultJavaPackageFinder =
createMock(DefaultJavaPackageFinder.class);
Object[] mocks = new Object[] {defaultJavaPackageFinder};
replay(mocks);
ImmutableSet<String> result = TestCommand.getPathToSourceFolders(
javaLibrary, Optional.of(defaultJavaPackageFinder), new FakeProjectFilesystem());
assertTrue("No path should be returned if the library contains only generated files.",
result.isEmpty());
verify(mocks);
}
示例4: shouldRejectUnknownBuildSettingsInFrameworkEntries
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test(expected = HumanReadableException.class)
public void shouldRejectUnknownBuildSettingsInFrameworkEntries() throws IOException {
BuildRule rule = createBuildRuleWithDefaults(
BuildTarget.builder("//foo", "rule")
.setFlavor(AppleLibraryDescription.DYNAMIC_LIBRARY)
.build(),
ImmutableSortedSet.<BuildRule>of(),
appleLibraryDescription,
new Function<AppleNativeTargetDescriptionArg, AppleNativeTargetDescriptionArg>() {
@Override
public AppleNativeTargetDescriptionArg apply(AppleNativeTargetDescriptionArg input) {
input.frameworks = ImmutableSortedSet.of("$FOOBAR/libfoo.a");
return input;
}
}
);
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(
ImmutableSet.of(rule),
ImmutableSet.of(rule.getBuildTarget()));
projectGenerator.createXcodeProjects();
}
示例5: ensureSetsAreHandledProperly
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void ensureSetsAreHandledProperly() {
BuildTarget target = BuildTargetFactory.newInstance("//foo/bar:baz");
FakeBuildRule rule = new FakeBuildRule(new BuildRuleType("example"), target);
rule.setRuleKey(RuleKey.TO_RULE_KEY.apply("cafebabe"));
rule.setOutputFile("cheese.txt");
ImmutableSortedSet<SourcePath> sourcePaths = ImmutableSortedSet.<SourcePath>of(
new BuildRuleSourcePath(rule),
new TestSourcePath("alpha/beta"));
ImmutableSet<String> strings = ImmutableSet.of("one", "two");
RuleKey.Builder.RuleKeyPair reflective = createEmptyRuleKey()
.setReflectively("sourcePaths", sourcePaths)
.setReflectively("strings", strings)
.build();
RuleKey.Builder.RuleKeyPair manual = createEmptyRuleKey()
.setSourcePaths("sourcePaths", sourcePaths)
.set("strings", strings)
.build();
assertEquals(manual.getTotalRuleKey(), reflective.getTotalRuleKey());
}
示例6: whenAllRulesThenSingleTargetRequestedThenRulesAreParsedOnce
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void whenAllRulesThenSingleTargetRequestedThenRulesAreParsedOnce()
throws BuildFileParseException, BuildTargetException, IOException, InterruptedException {
TestProjectBuildFileParserFactory buildFileParserFactory =
new TestProjectBuildFileParserFactory(filesystem, buildRuleTypes);
Parser parser = createParser(emptyBuildTargets(), buildFileParserFactory);
parser.filterAllTargetsInProject(
filesystem,
Lists.<String>newArrayList(),
alwaysTrue(),
new TestConsole(),
ImmutableMap.<String, String>of());
BuildTarget foo = BuildTarget.builder("//java/com/facebook", "foo").build();
parser.parseBuildFilesForTargets(
ImmutableList.of(foo),
Lists.<String>newArrayList(),
BuckEventBusFactory.newInstance(),
new TestConsole(),
ImmutableMap.<String, String>of());
assertEquals("Should have cached build rules.", 1, buildFileParserFactory.calls);
}
示例7: testGetOptionalIntegerAttributeWithValue
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void testGetOptionalIntegerAttributeWithValue() {
BuildTarget target = BuildTargetFactory.newInstance("//src/com/facebook:Main");
Map<String, Object> instance = ImmutableMap.<String, Object>of(
"some_value", 42);
BuildRuleFactoryParams params = new BuildRuleFactoryParams(
instance /* instance */,
filesystem,
parser,
target,
new FakeRuleKeyBuilderFactory());
assertEquals(Optional.of(42), params.getOptionalIntegerAttribute("some_value"));
}
示例8: whenMetadataEmptyStringThenGetRuleKeyWithoutDepsReturnsAbsent
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void whenMetadataEmptyStringThenGetRuleKeyWithoutDepsReturnsAbsent() {
ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
EasyMock.expect(
projectFilesystem.readFileIfItExists(
Paths.get("buck-out/bin/foo/bar/.baz/metadata/" +
BuildInfo.METADATA_KEY_FOR_RULE_KEY_WITHOUT_DEPS)))
.andReturn(Optional.of(""));
EasyMock.replay(projectFilesystem);
BuildTarget buildTarget = BuildTarget.builder("//foo/bar", "baz").build();
DefaultOnDiskBuildInfo onDiskBuildInfo = new DefaultOnDiskBuildInfo(
buildTarget,
projectFilesystem);
assertEquals(Optional.absent(), onDiskBuildInfo.getRuleKeyWithoutDeps());
EasyMock.verify(projectFilesystem);
}
示例9: verifyMissingFilesAreCorrectlyReported
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void verifyMissingFilesAreCorrectlyReported() throws CmdLineException {
// All files will be directories now
FakeProjectFilesystem filesystem = new FakeProjectFilesystem() {
@Override
public File getFileForRelativePath(String pathRelativeToProjectRoot) {
return new MissingFile(getRootPath(), pathRelativeToProjectRoot);
}
};
// Inputs that should be treated as missing files
ImmutableSet<String> inputs = ImmutableSet.of(
"java/somefolder/badfolder/somefile.java",
"java/somefolder/perfect.java",
"com/test/subtest/random.java");
BuildTarget target = BuildTarget.builder("//base", "name").build();
TargetNode<?> targetNode = createTargetNode(target, ImmutableSet.<Path>of());
AuditOwnerCommand command = createAuditOwnerCommand(filesystem);
AuditOwnerCommand.OwnersReport report = command.generateOwnersReport(targetNode, inputs, false);
assertTrue(report.owners.isEmpty());
assertTrue(report.nonFileInputs.isEmpty());
assertTrue(report.inputsWithNoOwners.isEmpty());
assertEquals(inputs, report.nonExistentInputs);
}
示例10: testUnifiedSourceFile
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
/**
* If the source paths specified are from the new unified source tmp then we should return
* the correct source tmp corresponding to the unified source path.
*/
@Test
public void testUnifiedSourceFile() {
Path pathToNonGenFile = Paths.get("java/package/SourceFile1.java");
assertFalse(MorePaths.isGeneratedFile(pathToNonGenFile));
ImmutableSortedSet<Path> javaSrcs = ImmutableSortedSet.of(pathToNonGenFile);
JavaLibrary javaLibrary = new FakeJavaLibrary(BuildTarget.builder("//foo", "bar").build())
.setJavaSrcs(javaSrcs);
DefaultJavaPackageFinder defaultJavaPackageFinder =
createMock(DefaultJavaPackageFinder.class);
expect(defaultJavaPackageFinder.getPathsFromRoot()).andReturn(pathsFromRoot);
Object[] mocks = new Object[] {defaultJavaPackageFinder};
replay(mocks);
ImmutableSet<String> result = TestCommand.getPathToSourceFolders(
javaLibrary, Optional.of(defaultJavaPackageFinder), new FakeProjectFilesystem());
assertEquals("All non-generated source files are under one source tmp.",
ImmutableSet.of("java/"), result);
verify(mocks);
}
示例11: testThatOriginalBuildParamsDepsDoNotPropagateToArchive
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void testThatOriginalBuildParamsDepsDoNotPropagateToArchive() {
// Create an `Archive` rule using build params with an existing dependency,
// as if coming from a `TargetNode` which had declared deps. These should *not*
// propagate to the `Archive` rule, since it only cares about dependencies generating
// it's immediate inputs.
BuildRule dep = new FakeBuildRule(
BuildRuleParamsFactory.createTrivialBuildRuleParams(
BuildTargetFactory.newInstance("//:fake")));
BuildTarget target = BuildTargetFactory.newInstance("//:archive");
BuildRuleParams params =
new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:dummy"))
.setDeps(ImmutableSortedSet.of(dep))
.build();
Archive archive = Archives.createArchiveRule(
target,
params,
DEFAULT_ARCHIVER,
DEFAULT_OUTPUT,
DEFAULT_INPUTS);
// Verify that the archive rules dependencies are empty.
assertEquals(archive.getDeps(), ImmutableSortedSet.<BuildRule>of());
}
示例12: whenMetadataValidRuleKeyThenGetRuleKeyReturnsKey
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void whenMetadataValidRuleKeyThenGetRuleKeyReturnsKey() {
ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
String key = "fa";
EasyMock.expect(
projectFilesystem.readFileIfItExists(
Paths.get("buck-out/bin/foo/bar/.baz/metadata/" + BuildInfo.METADATA_KEY_FOR_RULE_KEY)))
.andReturn(Optional.of(key));
EasyMock.replay(projectFilesystem);
BuildTarget buildTarget = BuildTarget.builder("//foo/bar", "baz").build();
DefaultOnDiskBuildInfo onDiskBuildInfo = new DefaultOnDiskBuildInfo(
buildTarget,
projectFilesystem);
assertEquals(Optional.of(new RuleKey(key)), onDiskBuildInfo.getRuleKey());
EasyMock.verify(projectFilesystem);
}
示例13: upperBoundGenericTypesCauseValuesToBeSetToTheUpperBound
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void upperBoundGenericTypesCauseValuesToBeSetToTheUpperBound()
throws ConstructorArgMarshalException {
class Dto implements ConstructorArg {
public List<? extends SourcePath> yup;
}
BuildTarget target = BuildTargetFactory.newInstance("//will:happen");
ruleResolver.addToIndex(target, new FakeBuildRule(new BuildRuleType("example"), target));
Dto dto = new Dto();
marshaller.populate(
ruleResolver,
filesystem,
buildRuleFactoryParams(ImmutableMap.<String, Object>of(
"yup", ImmutableList.of(target.getFullyQualifiedName()))),
dto);
BuildRuleSourcePath path = new BuildRuleSourcePath(new FakeBuildRule(ruleType, target));
assertEquals(ImmutableList.of(path), dto.yup);
}
示例14: parseAndCreateGraphFromTargets
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
private static PartialGraph parseAndCreateGraphFromTargets(
ImmutableSet<BuildTarget> targets,
Iterable<String> includes,
Parser parser,
BuckEventBus eventBus,
Console console, ImmutableMap<String, String> environment)
throws BuildTargetException, BuildFileParseException, IOException, InterruptedException {
Preconditions.checkNotNull(parser);
// Now that the Parser is loaded up with the set of all build rules, use it to create a
// DependencyGraph of only the targets we want to build.
ActionGraph graph = parser.parseBuildFilesForTargets(
targets,
includes,
eventBus,
console,
environment);
return new PartialGraph(graph, targets);
}
示例15: testGetOutputNameMethod
import com.facebook.buck.model.BuildTarget; //導入依賴的package包/類
@Test
public void testGetOutputNameMethod() {
BuildTarget target = BuildTargetFactory.newInstance("//:test");
// Sample data of output names to test with Genrule
ImmutableList<String> names = ImmutableList.of(
"out.txt",
"out/file.txt");
// Create genrules using the names above and verify the output name method returns
// them.
for (String name : names) {
Genrule genrule = GenruleBuilder
.createGenrule(target)
.setOut(name)
.build();
assertEquals(name, genrule.getOutputName());
}
}