TransformManager extends FilterableStreamCollection { @Nullable public <T extends Transform> AndroidTask<TransformTask> addTransform( @NonNull TaskFactory taskFactory, @NonNull TransformVariantScope scope, @NonNull T transform) { return addTransform(taskFactory, scope, transform, null ); } TransformManager(
            @NonNull AndroidTaskRegistry taskRegistry,
            @NonNull ErrorReporter errorReporter); @NonNull AndroidTaskRegistry getTaskRegistry(); void addStream(@NonNull TransformStream stream); @Nullable AndroidTask<TransformTask> addTransform(
            @NonNull TaskFactory taskFactory,
            @NonNull TransformVariantScope scope,
            @NonNull T transform); @Nullable AndroidTask<TransformTask> addTransform(
            @NonNull TaskFactory taskFactory,
            @NonNull TransformVariantScope scope,
            @NonNull T transform,
            @Nullable TransformTask.ConfigActionCallback<T> callback); @Override @NonNull List<TransformStream> getStreams(); static final Set<Scope> EMPTY_SCOPES; static final Set<ContentType> CONTENT_CLASS; static final Set<ContentType> CONTENT_JARS; static final Set<ContentType> CONTENT_RESOURCES; static final Set<ContentType> CONTENT_NATIVE_LIBS; static final Set<ContentType> CONTENT_DEX; static final Set<ContentType> CONTENT_JACK; static final Set<Scope> SCOPE_FULL_PROJECT; static final Set<Scope> SCOPE_FULL_LIBRARY; }
@Test public void wrongInputType() { Transform t = TestTransform.builder() .setInputTypes(FakeContentType.FOO) .setScopes(Scope.PROJECT) .build(); AndroidTask<TransformTask> task = transformManager.addTransform(taskFactory, scope, t); assertThat(task).isNull(); SyncIssue syncIssue = errorReporter.getSyncIssue(); assertThat(syncIssue).isNotNull(); assertThat(syncIssue.getMessage()).isEqualTo( "Custom content types " + "(com.android.build.gradle.internal.pipeline.TransformManagerTest$FakeContentType)" + " are not supported in transforms (transform name)"); assertThat(syncIssue.getType()).isEqualTo(SyncIssue.TYPE_GENERIC); }
@Test public void wrongOutputType() { Transform t = TestTransform.builder() .setInputTypes(DefaultContentType.CLASSES) .setOutputTypes(FakeContentType.FOO) .setScopes(Scope.PROJECT) .build(); AndroidTask<TransformTask> task = transformManager.addTransform(taskFactory, scope, t); assertThat(task).isNull(); SyncIssue syncIssue = errorReporter.getSyncIssue(); assertThat(syncIssue).isNotNull(); assertThat(syncIssue.getMessage()).isEqualTo( "Custom content types " + "(com.android.build.gradle.internal.pipeline.TransformManagerTest$FakeContentType)" + " are not supported in transforms (transform name)"); assertThat(syncIssue.getType()).isEqualTo(SyncIssue.TYPE_GENERIC); }
@Test public void consumedProvidedOnlyScope() { Transform t = TestTransform.builder() .setInputTypes(DefaultContentType.CLASSES) .setScopes(Scope.PROVIDED_ONLY) .build(); AndroidTask<TransformTask> task = transformManager.addTransform(taskFactory, scope, t); assertThat(task).isNull(); SyncIssue syncIssue = errorReporter.getSyncIssue(); assertThat(syncIssue).isNotNull(); assertThat(syncIssue.getMessage()).isEqualTo( "PROVIDED_ONLY scope cannot be consumed by Transform 'transform name'"); assertThat(syncIssue.getType()).isEqualTo(SyncIssue.TYPE_GENERIC); }
@Test public void consumedTestedScope() { Transform t = TestTransform.builder() .setInputTypes(DefaultContentType.CLASSES) .setScopes(Scope.TESTED_CODE) .build(); AndroidTask<TransformTask> task = transformManager.addTransform(taskFactory, scope, t); assertThat(task).isNull(); SyncIssue syncIssue = errorReporter.getSyncIssue(); assertThat(syncIssue).isNotNull(); assertThat(syncIssue.getMessage()).isEqualTo( "TESTED_CODE scope cannot be consumed by Transform 'transform name'"); assertThat(syncIssue.getType()).isEqualTo(SyncIssue.TYPE_GENERIC); }