@Override public void deleteAll() throws IOException { FileUtils.cleanOutputDir(rootLocation); }
private void writeTo(@NonNull TransformOutputProvider outputProvider) throws IOException { File sliceOutputLocation = outputProvider.getContentLocation(name, TransformManager.CONTENT_CLASS, Sets.immutableEnumSet(Scope.PROJECT, Scope.SUB_PROJECTS), Format.DIRECTORY); FileUtils.cleanOutputDir(sliceOutputLocation); // always write our dummy guard class, nobody will ever delete this file which mean // the slice will continue existing even it there is no other .class file in it. createGuardClass(name, sliceOutputLocation); // now copy all the files into its new location. for (Slice.SlicedElement slicedElement : slicedElements) { File outputFile = new File(sliceOutputLocation, new File(slicedElement.packagePath, slicedElement.slicedFile.getName()).getPath()); Files.createParentDirs(outputFile); Files.copy(slicedElement.slicedFile, outputFile); } } }
@TaskAction void generate() throws IOException, ParserConfigurationException { File folder = getResOutputDir(); List<Object> resolvedItems = getItems(); if (resolvedItems.isEmpty()) { FileUtils.cleanOutputDir(folder); } else { ResValueGenerator generator = new ResValueGenerator(folder); generator.addItems(getItems()); generator.generate(); } }
private static void instrumentFilesFullRun( @NonNull Instrumenter instrumenter, @NonNull File inputDir, @NonNull File outputDir) throws IOException { FileUtils.cleanOutputDir(outputDir); Iterable<File> files = FileUtils.getAllFiles(inputDir); for (File inputFile : files) { if (!inputFile.getName().endsWith(SdkConstants.DOT_CLASS)) { continue; } File outputFile = new File(outputDir, FileUtils.relativePath(inputFile, inputDir)); instrumentFile(instrumenter, inputFile, outputFile); } }
protected void wrapUpOutputs(File classes2Folder, File classes3Folder) throws IOException { // the transform can set the verifier status to failure in some corner cases, in that // case, make sure we delete our classes.3 if (!transformScope.getInstantRunBuildContext().hasPassedVerification()) { FileUtils.cleanOutputDir(classes3Folder); return; } // otherwise, generate the patch file and add it to the list of files to process next. ImmutableList<String> generatedClassNames = generatedClasses3Names.build(); if (!generatedClassNames.isEmpty()) { writePatchFileContents(generatedClassNames, classes3Folder, transformScope.getInstantRunBuildContext().getBuildId()); } }
@Override protected void doFullTaskAction() throws IOException { // this is full run, clean the previous output File destinationDir = getSourceOutputDir(); File parcelableDir = getPackagedDir(); FileUtils.cleanOutputDir(destinationDir); if (parcelableDir != null) { FileUtils.cleanOutputDir(parcelableDir); } DepFileProcessor processor = new DepFileProcessor(); try { compileAllFiles(processor); } catch (Exception e) { throw new RuntimeException(e); } List<DependencyData> dataList = processor.getDependencyDataList(); DependencyDataStore store = new DependencyDataStore(); store.addData(dataList); try { store.saveTo(new File(getIncrementalFolder(), DEPENDENCY_STORE)); } catch (IOException e) { throw new RuntimeException(e); } }
@TaskAction protected void compileShaders() throws IOException { // this is full run, clean the previous output File destinationDir = getOutputDir(); FileUtils.cleanOutputDir(destinationDir); try { getBuilder().compileAllShaderFiles( getSourceDir(), getOutputDir(), defaultArgs, scopedArgs, ndkLocation, new LoggedProcessOutputHandler(getILogger())); } catch (Exception e) { throw new RuntimeException(e); } }
KeytoolException, PackagerException, IOException { FileUtils.cleanOutputDir(incrementalDir);
@NonNull protected File generateSplitApk(@NonNull DexFiles dexFiles) throws IOException, KeytoolException, PackagerException, InterruptedException, ProcessException, TransformException { String uniqueName = dexFiles.encodeName(); final File alignedOutput = new File(outputDirectory, uniqueName + ".apk"); Files.createParentDirs(alignedOutput); File resPackageFile = generateSplitApkManifest(uniqueName); // packageCodeSplitApk uses a temporary directory for incremental runs. Since we don't // do incremental builds here, make sure it gets an empty directory. File tempDir = new File(supportDirectory, "package_" + uniqueName); if (!tempDir.exists() && !tempDir.mkdirs()) { throw new TransformException("Cannot create temporary folder " + tempDir.getAbsolutePath()); } FileUtils.cleanOutputDir(tempDir); androidBuilder.packageCodeSplitApk( resPackageFile, dexFiles.dexFiles, signingConf, alignedOutput, tempDir, ApkCreatorFactories.fromProjectProperties(project, true)); instantRunBuildContext.addChangedFile(FileType.SPLIT, alignedOutput); //noinspection ResultOfMethodCallIgnored resPackageFile.delete(); return alignedOutput; }
@TaskAction public void createReport() throws IOException { File resultsOutDir = getResultsDir(); File reportOutDir = getReportsDir(); // empty the folders FileUtils.cleanOutputDir(resultsOutDir); FileUtils.cleanOutputDir(reportOutDir); // do the copy. copyResults(resultsOutDir); // create the report. TestReport report = new TestReport(reportType, resultsOutDir, reportOutDir); report.generateReport(); // fail if any of the tasks failed. for (AndroidTestTask task : subTasks) { if (task.getTestFailed()) { testFailed = true; String reportUrl = new ConsoleRenderer().asClickableFileUrl( new File(reportOutDir, "index.html")); String message = "There were failing tests. See the report at: " + reportUrl; if (getIgnoreFailures()) { getLogger().warn(message); } else { throw new GradleException(message); } break; } } }
@TaskAction void generate() throws IOException, ProcessException, LoggedErrorException, InterruptedException { AndroidBuilder builder = getBuilder(); // always empty output dir. File outDir = getResOutputDir(); FileUtils.cleanOutputDir(outDir); File apk = getApkFile(); if (apk != null) { // copy the file into the destination, by sanitizing the name first. File rawDir = new File(outDir, FD_RES_RAW); FileUtils.mkdirs(rawDir); File to = new File(rawDir, ANDROID_WEAR_MICRO_APK + DOT_ANDROID_PACKAGE); Files.copy(apk, to); builder.generateApkData(apk, outDir, getMainPkgName(), ANDROID_WEAR_MICRO_APK); } else { builder.generateUnbundledWearApkData(outDir, getMainPkgName()); } AndroidBuilder.generateApkDataEntryInManifest(getMinSdkVersion(), getTargetSdkVersion(), getManifestFile()); }
FileUtils.cleanOutputDir(sourceDestDir); FileUtils.cleanOutputDir(resDestDir); FileUtils.cleanOutputDir(objDestDir); FileUtils.cleanOutputDir(libDestDir);
private void doTransform(@NonNull Collection<TransformInput> inputs, boolean isIncremental) throws IOException, TransformException, InterruptedException { if (!isIncremental && outputDir.exists()) { FileUtils.cleanOutputDir(outputDir); } else { FileUtils.mkdirs(outputDir); } InstantRunVerifierStatus resultSoFar = InstantRunVerifierStatus.COMPATIBLE; for (TransformInput transformInput : inputs) { resultSoFar = processFolderInputs(resultSoFar, isIncremental, transformInput); resultSoFar = processJarInputs(resultSoFar, transformInput); } // if we are being asked to produce the RESTART artifacts, there is no need to set the // verifier result, however the transform needed to run to backup the .class files. if (!variantScope.getGlobalScope().isActive(OptionalCompilationStep.RESTART_ONLY)) { variantScope.getInstantRunBuildContext().setVerifierStatus(resultSoFar); } }
@Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { FileUtils.cleanOutputDir(jniLibsFolder); for (TransformInput input : invocation.getReferencedInputs()) { for (JarInput jarInput : input.getJarInputs()) { copyFromJar(jarInput.getFile()); } for (DirectoryInput directoryInput : input.getDirectoryInputs()) { copyFromFolder(directoryInput.getFile()); } } }
FileUtils.cleanOutputDir(outputFolder); return; FileUtils.cleanOutputDir(outputFolder); return;
FileUtils.cleanOutputDir(resultsOutDir); FileUtils.cleanOutputDir(coverageOutDir); FileUtils.cleanOutputDir(reportOutDir);
FileUtils.cleanOutputDir(destinationDir);
@Override protected void doFullTaskAction() throws IOException { // this is full run, clean the previous output File destinationDir = getOutputDir(); FileUtils.cleanOutputDir(destinationDir); List<AssetSet> assetSets = getInputDirectorySets(); // create a new merger and populate it with the sets. AssetMerger merger = new AssetMerger(); try { for (AssetSet assetSet : assetSets) { // set needs to be loaded. assetSet.loadFromFiles(getILogger()); merger.addDataSet(assetSet); } // get the merged set and write it down. MergedAssetWriter writer = new MergedAssetWriter(destinationDir); merger.mergeData(writer, false /*doCleanUp*/); // No exception? Write the known state. merger.writeBlobTo(getIncrementalFolder(), writer, false); } catch (MergingException e) { getLogger().error("Could not merge source set folders: ", e); merger.cleanBlob(getIncrementalFolder()); throw new ResourceException(e.getMessage(), e); } }
FileUtils.cleanOutputDir(destinationDir);
FileUtils.cleanOutputDir(destinationDir);