@Test public void testPickFirst() throws IOException { setPickFirsts(ImmutableSet.of("foo/text.properties")); mFileFilter = new FileFilter( mPackagedJarExpansionSubStreams, mPackagingOptions); mFileFilter.handleChanged(mMergedFolder, createFile(mExpandedJar1, "foo/text.properties", "one")); mFileFilter.handleChanged(mMergedFolder, createFile(mExpandedJar2, "foo/text.properties", "two")); mFileFilter.handleChanged(mMergedFolder, createFile(mExpandedJar3, "foo/text.properties", "three")); File mergedFile = new File(mMergedFolder, "foo/text.properties"); assertTrue(mergedFile.exists()); String mergedContent = Files.asCharSource(mergedFile, Charset.defaultCharset()).read(); assertTrue(mergedContent.equals("one") || mergedContent.equals("two") || mergedContent.equals("three")); }
void handleChanged(@NonNull File outputDir, @NonNull File changedFile) throws IOException { String archivePath = getArchivePath(changedFile); PackagingFileAction action = getPackagingAction(archivePath); switch (action) { case EXCLUDE: return; case MERGE: mergeAll(outputDir, archivePath); return; case PICK_FIRST: copy(changedFile, outputDir, archivePath); return; case NONE: copy(changedFile, outputDir, archivePath); } }
FileFilter implements ZipEntryFilter { void handleChanged(@NonNull File outputDir, @NonNull File changedFile) throws IOException { String archivePath = getArchivePath(changedFile); PackagingFileAction action = getPackagingAction(archivePath); switch (action) { case EXCLUDE: return; case MERGE: mergeAll(outputDir, archivePath); return; case PICK_FIRST: copy(changedFile, outputDir, archivePath); return; case NONE: copy(changedFile, outputDir, archivePath); } } }
FileFilter implements ZipEntryFilter { void handleChanged(@NonNull File outputDir, @NonNull File changedFile) throws IOException { String archivePath = getArchivePath(changedFile); PackagingFileAction action = getPackagingAction(archivePath); switch (action) { case EXCLUDE: return; case MERGE: mergeAll(outputDir, archivePath); return; case PICK_FIRST: copy(changedFile, outputDir, archivePath); return; case NONE: copy(changedFile, outputDir, archivePath); } } FileFilter(
            @NonNull List<SubStream> expandedFolders,
            @Nullable PackagingOptions packagingOptions); }
FileFilter implements ZipEntryFilter { void handleChanged(@NonNull File outputDir, @NonNull File changedFile) throws IOException { String archivePath = getArchivePath(changedFile); PackagingFileAction action = getPackagingAction(archivePath); switch (action) { case EXCLUDE: return; case MERGE: mergeAll(outputDir, archivePath); return; case PICK_FIRST: copy(changedFile, outputDir, archivePath); return; case NONE: copy(changedFile, outputDir, archivePath); } } FileFilter(
            @NonNull List<SubStream> expandedFolders,
            @Nullable PackagingOptions packagingOptions); @Override boolean checkEntry(@NonNull String archivePath); void handleRemoved(@NonNull File outputDir, @NonNull String removedFilePath); }
FileFilter implements ZipEntryFilter { void handleChanged(@NonNull File outputDir, @NonNull File changedFile) throws IOException { String archivePath = getArchivePath(changedFile); PackagingFileAction action = getPackagingAction(archivePath); switch (action) { case EXCLUDE: return; case MERGE: mergeAll(outputDir, archivePath); return; case PICK_FIRST: copy(changedFile, outputDir, archivePath); return; case NONE: copy(changedFile, outputDir, archivePath); } } FileFilter(
            @NonNull List<SubStream> expandedFolders,
            @Nullable PackagingOptions packagingOptions); @Override boolean checkEntry(@NonNull String archivePath); void handleRemoved(@NonNull File outputDir, @NonNull String removedFilePath);  }