Search in sources :

Example 1 with ZipFileTraversal

use of com.facebook.buck.util.ZipFileTraversal in project buck by facebook.

the class PrebuiltJarSymbolsFinder method extractSymbols.

@Override
public Symbols extractSymbols() throws IOException {
    if (!(binaryJar instanceof PathSourcePath)) {
        return Symbols.EMPTY;
    }
    PathSourcePath sourcePath = (PathSourcePath) binaryJar;
    ProjectFilesystem filesystem = sourcePath.getFilesystem();
    Path absolutePath = filesystem.resolve(sourcePath.getRelativePath());
    final Set<String> providedSymbols = new HashSet<>();
    new ZipFileTraversal(absolutePath) {

        @Override
        public void visit(ZipFile zipFile, ZipEntry zipEntry) throws IOException {
            String name = zipEntry.getName();
            if (!name.endsWith(CLASS_SUFFIX) || name.contains("$")) {
                return;
            }
            String fullyQualifiedName = name.substring(0, name.length() - CLASS_SUFFIX.length()).replace('/', '.');
            providedSymbols.add(fullyQualifiedName);
        }
    }.traverse();
    return new Symbols(providedSymbols, ImmutableList.of(), ImmutableList.of());
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ZipFileTraversal(com.facebook.buck.util.ZipFileTraversal) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) IOException(java.io.IOException) HashSet(java.util.HashSet)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 PathSourcePath (com.facebook.buck.rules.PathSourcePath)1 SourcePath (com.facebook.buck.rules.SourcePath)1 ZipFileTraversal (com.facebook.buck.util.ZipFileTraversal)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1