@Test public void testIncrementalMode_changedAndAdded() throws TransformException, IOException, InterruptedException { InstantRunVerifierTransform transform = getTransform(); final File tmpDir = temporaryFolder.newFolder(); final File addedFile = new File(tmpDir, "com/foo/bar/NewInputFile.class"); Files.createParentDirs(addedFile); assertTrue(addedFile.createNewFile()); final File changedFile = new File(tmpDir, "com/foo/bar/ChangedFile.class"); assertTrue(changedFile.createNewFile()); final File lastIterationChangedFile = new File(backupDir, "com/foo/bar/ChangedFile.class"); Files.createParentDirs(lastIterationChangedFile); assertTrue(lastIterationChangedFile.createNewFile()); ImmutableList<TransformInput> transformInputs = ImmutableList.<TransformInput>of(new TransformInput() { @NonNull @Override public Collection<JarInput> getJarInputs() { return ImmutableList.of(); } @NonNull @Override public Collection<DirectoryInput> getDirectoryInputs() { return ImmutableList.<DirectoryInput>of(new DirectoryInputForTests() { @NonNull @Override public Map<File, Status> getChangedFiles() { return ImmutableMap.<File, Status>builder() .put(addedFile, Status.ADDED) .put(changedFile, Status.CHANGED) .build(); } @NonNull @Override public File getFile() { return tmpDir; } }); } }); transform.transform(new TransformInvocationBuilder(context) .addOutputProvider(transformOutputProvider) .addReferencedInputs(transformInputs) .setIncrementalMode(true) .build()); FileUtils.deletePath(tmpDir); assertThat(recordedVerification).isEmpty(); assertThat(recordedCopies).hasSize(2); assertThat(recordedCopies).containsEntry( changedFile, lastIterationChangedFile); assertThat(recordedCopies).containsEntry(addedFile, new File(backupDir, "com/foo/bar/NewInputFile.class")); }
@Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { if (invocation.getReferencedInputs().isEmpty()) { throw new RuntimeException("Empty list of referenced inputs"); } try { variantScope.getInstantRunBuildContext().startRecording( InstantRunBuildContext.TaskType.VERIFIER); doTransform(invocation.getReferencedInputs(), invocation.isIncremental()); } finally { variantScope.getInstantRunBuildContext().stopRecording( InstantRunBuildContext.TaskType.VERIFIER); } }
InstantRunVerifierTransform extends Transform { @Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { if (invocation.getReferencedInputs().isEmpty()) { throw new RuntimeException("Empty list of referenced inputs"); } try { variantScope.getInstantRunBuildContext().startRecording( InstantRunBuildContext.TaskType.VERIFIER); doTransform(invocation.getReferencedInputs(), invocation.isIncremental()); } finally { variantScope.getInstantRunBuildContext().stopRecording( InstantRunBuildContext.TaskType.VERIFIER); } } }
InstantRunVerifierTransform extends Transform { @Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { if (invocation.getReferencedInputs().isEmpty()) { throw new RuntimeException("Empty list of referenced inputs"); } try { variantScope.getInstantRunBuildContext().startRecording( InstantRunBuildContext.TaskType.VERIFIER); doTransform(invocation.getReferencedInputs(), invocation.isIncremental()); } finally { variantScope.getInstantRunBuildContext().stopRecording( InstantRunBuildContext.TaskType.VERIFIER); } } InstantRunVerifierTransform(InstantRunVariantScope variantScope); }
InstantRunVerifierTransform extends Transform { @Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { if (invocation.getReferencedInputs().isEmpty()) { throw new RuntimeException("Empty list of referenced inputs"); } try { variantScope.getInstantRunBuildContext().startRecording( InstantRunBuildContext.TaskType.VERIFIER); doTransform(invocation.getReferencedInputs(), invocation.isIncremental()); } finally { variantScope.getInstantRunBuildContext().stopRecording( InstantRunBuildContext.TaskType.VERIFIER); } } InstantRunVerifierTransform(InstantRunVariantScope variantScope); @Override void transform(@NonNull TransformInvocation invocation); @NonNull @Override String getName(); @NonNull @Override Set<QualifiedContent.ContentType> getInputTypes(); @NonNull @Override Set<QualifiedContent.ContentType> getOutputTypes(); @NonNull @Override Set<QualifiedContent.Scope> getScopes(); @NonNull @Override Set<QualifiedContent.Scope> getReferencedScopes(); @NonNull @Override Collection<File> getSecondaryDirectoryOutputs(); @Override boolean isIncremental(); }
InstantRunVerifierTransform extends Transform { @Override public void transform(@NonNull TransformInvocation invocation) throws IOException, TransformException, InterruptedException { if (invocation.getReferencedInputs().isEmpty()) { throw new RuntimeException("Empty list of referenced inputs"); } try { variantScope.getInstantRunBuildContext().startRecording( InstantRunBuildContext.TaskType.VERIFIER); doTransform(invocation.getReferencedInputs(), invocation.isIncremental()); } finally { variantScope.getInstantRunBuildContext().stopRecording( InstantRunBuildContext.TaskType.VERIFIER); } } InstantRunVerifierTransform(InstantRunVariantScope variantScope); @Override void transform(@NonNull TransformInvocation invocation); @NonNull @Override String getName(); @NonNull @Override Set<QualifiedContent.ContentType> getInputTypes(); @NonNull @Override Set<QualifiedContent.ContentType> getOutputTypes(); @NonNull @Override Set<QualifiedContent.Scope> getScopes(); @NonNull @Override Set<QualifiedContent.Scope> getReferencedScopes(); @NonNull @Override Collection<File> getSecondaryDirectoryOutputs(); @Override boolean isIncremental();  }