private void copyResults(File reportOutDir) throws IOException { List<File> inputs = getResultInputs(); for (File input : inputs) { File[] children = input.listFiles(); if (children != null) { for (File child : children) { copyFile(child, reportOutDir); } } } }
/** * Makes a copy of the given file in the specified directory, preserving the name and file * attributes. */ public static void copyFileToDirectory(@NonNull final File from, @NonNull final File to) throws IOException { copyFile(from, new File(to, from.getName())); }
/** * Copies a file or a directory's contents to another file or directory, which can have a * different name. The target file/directory is replaced if it already exists. * * <p>The source file/directory must exist and must not reside in, contain, or be identical to * the target file/directory. */ private static void copyFileOrDirectory(@NonNull File from, @NonNull File to) throws IOException { Preconditions.checkArgument( from.exists(), "Source path " + from.getAbsolutePath() + " does not exists."); Preconditions.checkArgument(!FileUtils.isFileInDirectory(from, to)); Preconditions.checkArgument(!FileUtils.isFileInDirectory(to, from)); Preconditions.checkArgument(!from.getCanonicalFile().equals(to.getCanonicalFile())); if (from.isFile()) { Files.createParentDirs(to); FileUtils.copyFile(from, to); } else if (from.isDirectory()) { FileUtils.deletePath(to); FileUtils.copyDirectory(from, to); } }
FileUtils.mkdirs(destLibFile.getParentFile()); FileUtils.copyFile(lib, destLibFile); for (File dexFile : FileUtils.find(dexFolder, Pattern.compile("\\.dex$"))) { File destDexFile = new File(dexBundleFolder, dexFile.getName()); FileUtils.copyFile(dexFile, destDexFile); FileUtils.mkdirs(destJavaResFile.getParentFile()); FileUtils.copyFile(javaResFile, destJavaResFile);
private void stripFile(@NonNull File input, @NonNull File output, @Nullable Abi abi) throws IOException { FileUtils.mkdirs(output.getParentFile()); if (abi == null) { FileUtils.copyFile(input, output); return; } ProcessInfoBuilder builder = new ProcessInfoBuilder(); builder.setExecutable(stripExecutables.get(abi)); builder.addArgs("--strip-unneeded"); builder.addArgs("-o"); builder.addArgs(output.toString()); builder.addArgs(input.toString()); ILogger logger = new LoggerWrapper(project.getLogger()); ProcessResult result = new GradleProcessExecutor(project).execute( builder.createProcess(), new LoggedProcessOutputHandler(logger)); if (result.getExitValue() != 0) { logger.warning("Unable to strip library '%s', packaging it as is.", input.getAbsolutePath()); FileUtils.copyFile(input, output); } }
if (excludeMatchers.stream().anyMatch(m -> m.matches(Paths.get(path)))) { FileUtils.mkdirs(strippedLib.getParentFile()); FileUtils.copyFile(input, strippedLib); } else { stripFile(input, strippedLib, abi); FileUtils.copyFile(input, strippedLib); } else { stripFile(input, strippedLib, abi); FileUtils.copyFile(jarInput.getFile(), outFile); } else if (jarInput.getStatus() == Status.REMOVED) { FileUtils.deleteIfExists(outFile);