use of com.facebook.buck.rules.ArchiveMemberSourcePath in project buck by facebook.
the class DefaultClassUsageFileReader method loadFromFile.
public static ImmutableList<SourcePath> loadFromFile(SourcePathResolver pathResolver, ProjectFilesystem projectFilesystem, Path classUsageFilePath, ImmutableSortedSet<BuildRule> deps) {
final ImmutableMap<Path, SourcePath> jarAbsolutePathToAbiJarSourcePath = buildJarToAbiJarMap(pathResolver, deps);
final ImmutableList.Builder<SourcePath> builder = ImmutableList.builder();
try {
final ImmutableSet<Map.Entry<String, ImmutableList<String>>> classUsageEntries = loadClassUsageMap(classUsageFilePath).entrySet();
for (Map.Entry<String, ImmutableList<String>> jarUsedClassesEntry : classUsageEntries) {
Path jarAbsolutePath = projectFilesystem.resolve(Paths.get(jarUsedClassesEntry.getKey()));
SourcePath abiJarSourcePath = jarAbsolutePathToAbiJarSourcePath.get(jarAbsolutePath);
if (abiJarSourcePath == null) {
// it came from the build environment (JDK, Android SDK, etc.)
continue;
}
ImmutableList<String> classAbsolutePaths = jarUsedClassesEntry.getValue();
for (String classAbsolutePath : classAbsolutePaths) {
builder.add(new ArchiveMemberSourcePath(abiJarSourcePath, Paths.get(classAbsolutePath)));
}
}
} catch (IOException e) {
throw new HumanReadableException(e, "Failed to load class usage files from %s:\n%s", classUsageFilePath, e.getLocalizedMessage());
}
return builder.build();
}
use of com.facebook.buck.rules.ArchiveMemberSourcePath in project buck by facebook.
the class DependencyFileRuleKeyFactoryTest method testKeysWhenInputArchiveMemberChanges.
@Test
public void testKeysWhenInputArchiveMemberChanges() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver ruleResolver = newRuleResolver();
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
SourcePath archivePath = new PathSourcePath(filesystem, Paths.get("archive"));
SourcePath usedSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("used"));
SourcePath unusedSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("unused"));
SourcePath noncoveredSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("nc"));
SourcePath interestingSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("META-INF"));
testKeysWhenInputContentsChanges(ruleFinder, pathResolver, usedSourcePath, unusedSourcePath, noncoveredSourcePath, interestingSourcePath, Paths.get(pathResolver.getAbsoluteArchiveMemberPath(usedSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(unusedSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(noncoveredSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(interestingSourcePath).toString()), DependencyFileEntry.fromSourcePath(usedSourcePath, pathResolver));
}
use of com.facebook.buck.rules.ArchiveMemberSourcePath in project buck by facebook.
the class AbstractDependencyFileEntry method fromSourcePath.
public static DependencyFileEntry fromSourcePath(SourcePath sourcePath, SourcePathResolver resolver) {
final DependencyFileEntry.Builder builder = DependencyFileEntry.builder();
if (sourcePath instanceof ArchiveMemberSourcePath) {
ArchiveMemberSourcePath archiveMemberSourcePath = (ArchiveMemberSourcePath) sourcePath;
ArchiveMemberPath relativeArchiveMemberPath = resolver.getRelativeArchiveMemberPath(archiveMemberSourcePath);
builder.setPathToFile(relativeArchiveMemberPath.getArchivePath());
builder.setPathWithinArchive(relativeArchiveMemberPath.getMemberPath());
} else {
builder.setPathToFile(resolver.getRelativePath(sourcePath));
}
return builder.build();
}
Aggregations