/** * Returns the type(s) of data that is generated by the Transform. This may be more than * one type. * * <p>The default implementation returns {@link #getInputTypes()}. * * <p><strong>This must be of type {@link QualifiedContent.DefaultContentType}</strong> */ @NonNull public Set<ContentType> getOutputTypes() { return getInputTypes(); }
@VisibleForTesting @NonNull static String getTaskNamePrefix(@NonNull Transform transform) { StringBuilder sb = new StringBuilder(100); sb.append("transform"); sb.append( transform.getInputTypes() .stream() .map(inputType -> CaseFormat.UPPER_UNDERSCORE.to( CaseFormat.UPPER_CAMEL, inputType.name())) .sorted() // Keep the order stable. .collect(Collectors.joining("And"))) .append("With") .append(capitalize(transform.getName())) .append("For"); return sb.toString(); }
@NonNull private List<TransformStream> grabReferencedStreams(@NonNull Transform transform) { Set<? super Scope> requestedScopes = transform.getReferencedScopes(); if (requestedScopes.isEmpty()) { return ImmutableList.of(); } List<TransformStream> streamMatches = Lists.newArrayListWithExpectedSize(streams.size()); Set<ContentType> requestedTypes = transform.getInputTypes(); for (TransformStream stream : streams) { // streams may contain more than we need. In this case, we'll provide the whole // stream as-is since it's not actually consumed. // It'll be up to the TransformTask to make sure that the content of the stream is // usable (for instance when a stream // may contain two scopes, these scopes could be combined or not, impacting consumption) Set<ContentType> availableTypes = stream.getContentTypes(); Set<? super Scope> availableScopes = stream.getScopes(); Set<ContentType> commonTypes = Sets.intersection(requestedTypes, availableTypes); Set<? super Scope> commonScopes = Sets.intersection(requestedScopes, availableScopes); if (!commonTypes.isEmpty() && !commonScopes.isEmpty()) { streamMatches.add(stream); } } return streamMatches; }
if (next.checkRemovedJarFile( Sets.union(transform.getScopes(), transform.getReferencedScopes()), transform.getInputTypes(), removedFile, removedFileSegments) || next.checkRemovedFolderFile( Sets.union(transform.getScopes(), transform.getReferencedScopes()), transform.getInputTypes(), removedFile, removedFileSegments)) {
private boolean validateTransform(@NonNull Transform transform) { // check the content type are of the right Type. if (!checkContentTypes(transform.getInputTypes(), transform) || !checkContentTypes(transform.getOutputTypes(), transform)) { return false; } // check some scopes are not consumed. Set<? super Scope> scopes = transform.getScopes(); // Allow Jack transform to consume provided classes as the .jack files are needed. if (scopes.contains(Scope.PROVIDED_ONLY) && !isJackRuntimeLib(transform)) { errorReporter.handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("PROVIDED_ONLY scope cannot be consumed by Transform '%1$s'", transform.getName())); return false; } if (scopes.contains(Scope.TESTED_CODE)) { errorReporter.handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("TESTED_CODE scope cannot be consumed by Transform '%1$s'", transform.getName())); return false; } return true; }
Set<ContentType> requestedTypes = transform.getInputTypes();
transform.getName(), scope.getFullVariantName(), transform.getScopes(), transform.getReferencedScopes(), transform.getInputTypes())); return Optional.empty();