input.getJarInputs().parallelStream().forEach(jarInput -> { File src = jarInput.getFile(); File dst = invocation.getOutputProvider().getContentLocation( jarInput.getName(), jarInput.getContentTypes(), jarInput.getScopes(), Format.JAR); input.getDirectoryInputs().parallelStream().forEach(directoryInput -> { File src = directoryInput.getFile(); File dst = invocation.getOutputProvider().getContentLocation( directoryInput.getName(), directoryInput.getContentTypes(), directoryInput.getScopes(), Format.DIRECTORY); File dest = invocation.getOutputProvider().getContentLocation( "WMRouter", TransformManager.CONTENT_CLASS, ImmutableSet.of(QualifiedContent.Scope.PROJECT), Format.DIRECTORY);
Collection<TransformInput> inputs = transformInvocation.getInputs(); TransformOutputProvider outputProvider = transformInvocation.getOutputProvider(); if (outputProvider != null) outputProvider.deleteAll(); System.out.println("/////////////////////////begin inputs///////////////////////////////////"); File dest = outputProvider.getContentLocation(input.getName(), input.getContentTypes(), input.getScopes(), Format.DIRECTORY); FileUtils.copyDirectory(input.getFile(), dest); } else { File dest = outputProvider.getContentLocation(jarName + md5Name, jarInput.getContentTypes(), jarInput.getScopes(), Format.JAR); FileUtils.copyFile(jarInput.getFile(), dest);
public void clearForFullMode() throws IOException { invocation.getOutputProvider().deleteAll(); FileUtils.deleteDirectory(variantRoot); } }
try { if (!transformInvocation.isIncremental()) { transformInvocation.getOutputProvider().deleteAll(); Path outDir = transformInvocation.getOutputProvider().getContentLocation( directoryInput.getName(), directoryInput.getContentTypes(),
/** * Performs the full shrinking run. This clears previous incremental state, creates a new * {@link ShrinkerGraph} and fills it with data read from the platform JARs as well as input * classes. Then we find "entry points" that match {@code -keep} rules from the config file, * and walk the graph, setting the counters and finding reachable classes and members. In the * last step we rewrite all reachable class files to only contain kept class members and put * them in the matching output directories. */ public void run( @NonNull Collection<TransformInput> inputs, @NonNull Collection<TransformInput> referencedClasses, @NonNull TransformOutputProvider output, @NonNull ImmutableMap<CounterSet, KeepRules> keepRules, boolean saveState) throws IOException { output.deleteAll(); buildGraph(inputs, referencedClasses); Stopwatch stopwatch = Stopwatch.createStarted(); setCounters(keepRules); logTime("Set counters", stopwatch); writeOutput(inputs, output); logTime("Write output", stopwatch); if (saveState) { mGraph.saveState(); logTime("Saving state", stopwatch); } }
TransformOutputProvider outputProvider = transformInvocation.getOutputProvider(); File styleables = outputProvider.getContentLocation("styleables", this.getInputTypes(), this.getScopes(), Format.DIRECTORY); String buildType = styleables.getParentFile().getName(); outputProvider.deleteAll(); Collection<TransformInput> inputs = transformInvocation.getInputs(); if (config.inlineR && !Objects.equals(buildType, "debug")) { throw new UnsupportedOperationException("Unknown format readAll input " + input); File f = outputProvider.getContentLocation(input.getName(), input.getContentTypes(), input.getScopes(), format); if (!f.getParentFile().exists()) f.getParentFile().mkdirs(); File destFolder = outputProvider.getContentLocation(dir.getName(), dir.getContentTypes(), dir.getScopes(), Format.DIRECTORY); try { File dest = outputProvider.getContentLocation(jarInput.getName(), jarInput.getContentTypes(), jarInput.getScopes(), Format.JAR); if (dest.exists()) {
transformInvocation .getOutputProvider() .getContentLocation(TRANSFORM_OUTPUT, getOutputTypes(), getScopes(), Format.DIRECTORY); transformInvocation .getOutputProvider() .getContentLocation(inputJar.getName(), getOutputTypes(), getScopes(), Format.JAR); outputJar.getParentFile().mkdirs();
outputProvider.deleteAll(); File output = outputProvider.getContentLocation( directoryInput.getName(), directoryInput.getContentTypes(), File output = outputProvider.getContentLocation( jarInput.getName(), jarInput.getContentTypes(), } else { classpathFiles.add(jarInput.getFile()); File output = outputProvider.getContentLocation( jarInput.getName(), jarInput.getContentTypes(), File output = outputProvider.getContentLocation(NAME, getOutputTypes(), Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT), Format.DIRECTORY);
private File classRootFor(String id) { return invocation.getOutputProvider().getContentLocation("capt-generated-by:" + id, Collections.singleton(QualifiedContent.DefaultContentType.CLASSES), Collections.singleton(QualifiedContent.Scope.EXTERNAL_LIBRARIES), Format.DIRECTORY); }
outputProvider.deleteAll(); File output = outputProvider.getContentLocation( directoryInput.getName(), getInputTypes(), File outFile = outputProvider.getContentLocation( jarInput.getName(), getInputTypes(),
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); } } }
throw new IllegalStateException("Incremental mode is not supported yet."); } else { outputProvider.deleteAll(); } else { if (outFolder == null) { outFolder = outputProvider.getContentLocation( "main", getOutputTypes(), getScopes(), outJar = outputProvider.getContentLocation( "main", getOutputTypes(), getScopes(), Format.JAR); mkdirs(outJar.getParentFile()); outJar = outputProvider.getContentLocation( "main", getOutputTypes(), getScopes(), Format.JAR); mkdirs(outJar.getParentFile()); } else { if (outFolder == null) { outFolder = outputProvider.getContentLocation( "main", getOutputTypes(), getScopes(),
File dest = outputProvider.getContentLocation(directoryInput.getName(),directoryInput.getContentTypes(),directoryInput.getScopes(), Format.DIRECTORY); FileUtils.copyDirectory(directoryInput.getFile(),dest); name = name.substring(0,name.length()-4); File dest = outputProvider.getContentLocation(name + md5Name,jarInput.getContentTypes(),jarInput.getScopes(),Format.JAR); FileUtils.copyFile(jarInput.getFile(),dest);
outputProvider.deleteAll(); File outputDir = outputProvider.getContentLocation("main", getOutputTypes(), TransformManager.SCOPE_FULL_PROJECT, File outputDir = outputProvider.getContentLocation("main", TransformManager.CONTENT_DEX, TransformManager.SCOPE_FULL_PROJECT, Format.DIRECTORY);
Util.deleteIFExists(invocation.getOutputProvider().getContentLocation( jar.getName(), jar.getContentTypes(), jar.getScopes(), Format.JAR)); File output = invocation.getOutputProvider().getContentLocation( jar.getName(), jar.getContentTypes(), jar.getScopes(), Format.JAR); zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(output)));
outputProvider.deleteAll(); File inputJar = jarInput.getFile(); File outputJar = outputProvider.getContentLocation( jarInput.getName(), jarInput.getContentTypes(), File inputDir = di.getFile(); File outputDir = outputProvider.getContentLocation( di.getName(), di.getContentTypes(),
/** * Tries to determine the output class file, for rewriting the given class file. * * <p>This will return {@link Optional#absent()} if the class is not part of the program to * shrink (e.g. comes from a platform JAR). */ @NonNull protected Optional<File> chooseOutputFile( @NonNull T klass, @NonNull File classFile, @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) { String classFilePath = classFile.getAbsolutePath(); for (TransformInput input : inputs) { Iterable<QualifiedContent> directoriesAndJars = Iterables.concat(input.getDirectoryInputs(), input.getJarInputs()); for (QualifiedContent directoryOrJar : directoriesAndJars) { File file = directoryOrJar.getFile(); if (classFilePath.startsWith(file.getAbsolutePath())) { File outputDir = output.getContentLocation( FileUtils.getDirectoryNameForJar(file), directoryOrJar.getContentTypes(), directoryOrJar.getScopes(), Format.DIRECTORY); return Optional.of(new File(outputDir, mGraph.getClassName(klass) + ".class")); } } } return Optional.absent(); }
outputProvider.deleteAll(); File dirOutput = outputProvider.getContentLocation(dirInput.getName() + "-" + dirInput.getFile().getAbsolutePath().hashCode(), dirInput.getContentTypes(), final File outJarFolder = outputProvider.getContentLocation( jarFile.getName() + "-" + jarFile.getPath().hashCode(), jarInput.getContentTypes(),
private static File getOutputStreamForFile( @NonNull TransformOutputProvider transformOutputProvider, @NonNull DirectoryInput input, @NonNull File file, @NonNull Slices slices) { String relativePackagePath = FileUtils.relativePossiblyNonExistingPath(file.getParentFile(), input.getFile()); Slice slice = slices.getSliceFor(new Slice.SlicedElement(relativePackagePath, file)); return transformOutputProvider.getContentLocation(slice.name, TransformManager.CONTENT_CLASS, Sets.immutableEnumSet(Scope.PROJECT, Scope.SUB_PROJECTS), Format.DIRECTORY); }
Thread.currentThread().setContextClassLoader(urlClassLoader); File classesTwoOutput = outputProvider.getContentLocation("main", TransformManager.CONTENT_CLASS, getScopes(), Format.DIRECTORY); File classesThreeOutput = outputProvider.getContentLocation("enhanced", ImmutableSet.of(ExtendedContentType.CLASSES_ENHANCED), getScopes(), Format.DIRECTORY);