@Test public void testMergeUpdate() throws IOException { setMerges(ImmutableSet.of( FileUtils.join("foo", "text.properties"))); mFileFilter = new FileFilter( mPackagedJarExpansionSubStreams, mPackagingOptions); createFile(mExpandedJar1, "foo/text.properties", "one"); File secondFile = createFile(mExpandedJar2, "foo/text.properties", "two"); createFile(mExpandedJar3, "foo/text.properties", "three"); mFileFilter.handleChanged(mMergedFolder, secondFile); File mergedFile = new File(mMergedFolder, "foo/text.properties"); assertTrue(mergedFile.exists()); assertContentInAnyOrder( Files.asCharSource(mergedFile, Charset.defaultCharset()).read() , ImmutableList.of("one", "two", "three")); assertTrue(secondFile.delete()); secondFile = createFile(mExpandedJar2, "foo/text.properties", "deux"); mFileFilter.handleChanged(mMergedFolder, secondFile); assertTrue(mergedFile.exists()); assertContentInAnyOrder( Files.asCharSource(mergedFile, Charset.defaultCharset()).read() , ImmutableList.of("one", "deux", "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);  }