@Test public void simple_testIncrementalUpdate() throws Exception { Files.write(Simple.aaa(), new File(mTestPackageDir, "Aaa.class")); Files.write(Simple.bbb(), new File(mTestPackageDir, "Bbb.class")); Files.write(Simple.main1(), new File(mTestPackageDir, "Main.class")); Files.write(TestClasses.emptyClass("NotUsed"), new File(mTestPackageDir, "NotUsed.class")); fullRun("Main", "main:()V"); assertTrue(new File(mIncrementalDir, "shrinker.bin").exists()); assertMembersLeft("Main", "main:()V"); assertMembersLeft("Aaa", "<init>:()V", "m1:()V"); assertMembersLeft("Bbb", "<init>:()V"); assertClassSkipped("NotUsed"); long timestampBbb = getOutputClassFile("Bbb").lastModified(); long timestampMain = getOutputClassFile("Main").lastModified(); Thread.sleep(1000); Files.write(Simple.main2(), new File(mTestPackageDir, "Main.class")); incrementalRun(ImmutableMap.of("Main", Status.CHANGED)); assertMembersLeft("Main", "main:()V"); assertMembersLeft("Aaa", "<init>:()V", "m2:()V"); assertMembersLeft("Bbb", "<init>:()V"); assertClassSkipped("NotUsed"); assertTrue(timestampMain < getOutputClassFile("Main").lastModified()); assertEquals(timestampBbb, getOutputClassFile("Bbb").lastModified()); }
public void incrementalRun( @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) throws IOException, IncrementalRunImpossibleException { final Set<T> classesToWrite = Sets.newConcurrentHashSet(); final Set<File> classFilesToDelete = Sets.newConcurrentHashSet(); final Set<PostProcessingData.UnresolvedReference<T>> unresolvedReferences = Sets.newConcurrentHashSet(); Stopwatch stopwatch = Stopwatch.createStarted(); SetMultimap<T, String> oldState = resetState(); logTime("resetState()", stopwatch); processInputs(inputs, classesToWrite, unresolvedReferences); logTime("processInputs", stopwatch); finishGraph(unresolvedReferences); logTime("finish graph", stopwatch); setCounters(CounterSet.SHRINK); logTime("set counters", stopwatch); chooseClassesToWrite(inputs, output, classesToWrite, classFilesToDelete, oldState); logTime("choose classes", stopwatch); updateClassFiles(classesToWrite, classFilesToDelete, inputs, output); logTime("update class files", stopwatch); mGraph.saveState(); logTime("save state", stopwatch); }
IncrementalShrinker extends AbstractShrinker<T> { public void incrementalRun( @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) throws IOException, IncrementalRunImpossibleException { final Set<T> classesToWrite = Sets.newConcurrentHashSet(); final Set<File> classFilesToDelete = Sets.newConcurrentHashSet(); final Set<PostProcessingData.UnresolvedReference<T>> unresolvedReferences = Sets.newConcurrentHashSet(); Stopwatch stopwatch = Stopwatch.createStarted(); SetMultimap<T, String> oldState = resetState(); logTime("resetState()", stopwatch); processInputs(inputs, classesToWrite, unresolvedReferences); logTime("processInputs", stopwatch); finishGraph(unresolvedReferences); logTime("finish graph", stopwatch); setCounters(CounterSet.SHRINK); logTime("set counters", stopwatch); chooseClassesToWrite(inputs, output, classesToWrite, classFilesToDelete, oldState); logTime("choose classes", stopwatch); updateClassFiles(classesToWrite, classFilesToDelete, inputs, output); logTime("update class files", stopwatch); mGraph.saveState(); logTime("save state", stopwatch); } }
IncrementalShrinker extends AbstractShrinker<T> { public void incrementalRun( @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) throws IOException, IncrementalRunImpossibleException { final Set<T> classesToWrite = Sets.newConcurrentHashSet(); final Set<File> classFilesToDelete = Sets.newConcurrentHashSet(); final Set<PostProcessingData.UnresolvedReference<T>> unresolvedReferences = Sets.newConcurrentHashSet(); Stopwatch stopwatch = Stopwatch.createStarted(); SetMultimap<T, String> oldState = resetState(); logTime("resetState()", stopwatch); processInputs(inputs, classesToWrite, unresolvedReferences); logTime("processInputs", stopwatch); finishGraph(unresolvedReferences); logTime("finish graph", stopwatch); setCounters(CounterSet.SHRINK); logTime("set counters", stopwatch); chooseClassesToWrite(inputs, output, classesToWrite, classFilesToDelete, oldState); logTime("choose classes", stopwatch); updateClassFiles(classesToWrite, classFilesToDelete, inputs, output); logTime("update class files", stopwatch); mGraph.saveState(); logTime("save state", stopwatch); } IncrementalShrinker(
            WaitableExecutor<Void> executor,
            ShrinkerGraph<T> graph,
            ShrinkerLogger shrinkerLogger); }
IncrementalShrinker extends AbstractShrinker<T> { public void incrementalRun( @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) throws IOException, IncrementalRunImpossibleException { final Set<T> classesToWrite = Sets.newConcurrentHashSet(); final Set<File> classFilesToDelete = Sets.newConcurrentHashSet(); final Set<PostProcessingData.UnresolvedReference<T>> unresolvedReferences = Sets.newConcurrentHashSet(); Stopwatch stopwatch = Stopwatch.createStarted(); SetMultimap<T, String> oldState = resetState(); logTime("resetState()", stopwatch); processInputs(inputs, classesToWrite, unresolvedReferences); logTime("processInputs", stopwatch); finishGraph(unresolvedReferences); logTime("finish graph", stopwatch); setCounters(CounterSet.SHRINK); logTime("set counters", stopwatch); chooseClassesToWrite(inputs, output, classesToWrite, classFilesToDelete, oldState); logTime("choose classes", stopwatch); updateClassFiles(classesToWrite, classFilesToDelete, inputs, output); logTime("update class files", stopwatch); mGraph.saveState(); logTime("save state", stopwatch); } IncrementalShrinker(
            WaitableExecutor<Void> executor,
            ShrinkerGraph<T> graph,
            ShrinkerLogger shrinkerLogger); void incrementalRun(
            @NonNull Iterable<TransformInput> inputs,
            @NonNull TransformOutputProvider output); }
IncrementalShrinker extends AbstractShrinker<T> { public void incrementalRun( @NonNull Iterable<TransformInput> inputs, @NonNull TransformOutputProvider output) throws IOException, IncrementalRunImpossibleException { final Set<T> classesToWrite = Sets.newConcurrentHashSet(); final Set<File> classFilesToDelete = Sets.newConcurrentHashSet(); final Set<PostProcessingData.UnresolvedReference<T>> unresolvedReferences = Sets.newConcurrentHashSet(); Stopwatch stopwatch = Stopwatch.createStarted(); SetMultimap<T, String> oldState = resetState(); logTime("resetState()", stopwatch); processInputs(inputs, classesToWrite, unresolvedReferences); logTime("processInputs", stopwatch); finishGraph(unresolvedReferences); logTime("finish graph", stopwatch); setCounters(CounterSet.SHRINK); logTime("set counters", stopwatch); chooseClassesToWrite(inputs, output, classesToWrite, classFilesToDelete, oldState); logTime("choose classes", stopwatch); updateClassFiles(classesToWrite, classFilesToDelete, inputs, output); logTime("update class files", stopwatch); mGraph.saveState(); logTime("save state", stopwatch); } IncrementalShrinker(
            WaitableExecutor<Void> executor,
            ShrinkerGraph<T> graph,
            ShrinkerLogger shrinkerLogger); void incrementalRun(
            @NonNull Iterable<TransformInput> inputs,
            @NonNull TransformOutputProvider output);  }