@Override public boolean checkEntry(String archivePath) throws ZipAbortException { mLogger.verbose("=> %s", archivePath); File duplicate = checkFileForDuplicate(archivePath); if (duplicate != null) { throw new DuplicateFileException(archivePath, duplicate, mInputFile); } else { mAddedFiles.put(archivePath, mInputFile); } return true; } }
@Override protected void doFullTaskAction() { try { final File dir = getJavaResourceDir(); getBuilder().packageApk(getResourceFile().getAbsolutePath(), getDexFolder(), getDexedLibraries(), getPackagedJars(), (dir == null ? null : dir.getAbsolutePath()), getJniFolders(), getMergingFolder(), getAbiFilters(), getJniDebugBuild(), getSigningConfig(), getPackagingOptions(), getOutputFile().getAbsolutePath()); } catch (DuplicateFileException e) { Logger logger = getLogger(); logger.error("Error: duplicate files during packaging of APK " + getOutputFile() .getAbsolutePath()); logger.error("\tPath in archive: " + e.getArchivePath()); logger.error("\tOrigin 1: " + e.getFile1()); logger.error("\tOrigin 2: " + e.getFile2()); logger.error("You can ignore those files in your build.gradle:"); logger.error("\tandroid {"); logger.error("\t packagingOptions {"); logger.error("\t exclude \'" + e.getArchivePath() + "\'"); logger.error("\t }"); logger.error("\t}"); throw new BuildException(e.getMessage(), e); } catch (Exception e) { throw new BuildException(e.getMessage(), e); } }
@Override public boolean checkEntry(String archivePath) throws ZipAbortException { mLogger.verbose("=> %s", archivePath); File duplicate = checkFileForDuplicate(archivePath); if (duplicate != null) { // we have a duplicate but it might be the same source file, in this case, // we just ignore the duplicate, and of course, we don't add it again. File potentialDuplicate = new File(mInputFile, archivePath); if (!duplicate.getAbsolutePath().equals(potentialDuplicate.getAbsolutePath())) { throw new DuplicateFileException(archivePath, duplicate, mInputFile); } return false; } else { mAddedFiles.put(archivePath, mInputFile); } return true; } }
private void doAddFile(File file, String archivePath) throws DuplicateFileException, IOException { if (!mFileFilter.apply(archivePath)) { return; } mLogger.verbose("%1$s => %2$s", file, archivePath); // If a file has to be merged, write it to a file in the merging folder and add it later. if (!mMergeFiles.keySet().contains(archivePath)) { File duplicate = checkFileForDuplicate(archivePath); if (duplicate != null) { throw new DuplicateFileException(archivePath, duplicate, file); } } else { File mergingFile = mMergeFiles.get(archivePath); if (!mergingFile.getParentFile().exists()) { mergingFile.getParentFile().mkdirs(); } FileOutputStream fos = new FileOutputStream(mMergeFiles.get(archivePath), true); try { fos.write(Files.toByteArray(file)); } finally { fos.close(); } return; } mAddedFiles.put(archivePath, file); mBuilder.writeFile(file, archivePath); }
File duplicate = checkFileForDuplicate(archivePath); if (duplicate != null) { throw new DuplicateFileException(archivePath, duplicate, mInputFile);
.map(QualifiedContent::getFile) .collect(Collectors.toList()); throw new TransformException(new DuplicateFileException(key, sources));