Java Code Examples for com.android.build.api.transform.QualifiedContent#ContentType

The following examples show how to use com.android.build.api.transform.QualifiedContent#ContentType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformReplacer.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void replaceMergeJavaResourcesTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
            variantContext, MergeJavaResourcesTransform.class);
    for (TransformTask transformTask : baseTransforms) {
        MergeJavaResourcesTransform transform = (MergeJavaResourcesTransform) transformTask.getTransform();
        PackagingOptions packagingOptions = (PackagingOptions) ReflectUtils.getField(transform, "packagingOptions");
        packagingOptions.exclude("**.aidl");
        packagingOptions.exclude("**.cfg");
        Set<? super QualifiedContent.Scope> mergeScopes = (Set<? super QualifiedContent.Scope>) ReflectUtils.getField(transform, "mergeScopes");
        Set<QualifiedContent.ContentType> mergedType = (Set<QualifiedContent.ContentType>) ReflectUtils.getField(transform, "mergedType");
        String name = (String) ReflectUtils.getField(transform, "name");
        AtlasMergeJavaResourcesTransform atlasMergeJavaResourcesTransform = new AtlasMergeJavaResourcesTransform(appVariantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), packagingOptions, mergeScopes, mergedType.iterator().next(), name, appVariantContext.getScope());
        ReflectUtils.updateField(transformTask, "transform",
                atlasMergeJavaResourcesTransform);
    }

}
 
Example 2
Source File: AtlasIntermediateStreamHelper.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void replaceProvider(TransformInvocation transformInvocation){
    try {
        Field field = intermediateStream.getClass().getDeclaredField("folderUtils");
        field.setAccessible(true);
        IntermediateFolderUtils intermediateFolderUtils = (IntermediateFolderUtils) field.get(intermediateStream);
        Set<QualifiedContent.ContentType> types = (Set<QualifiedContent.ContentType>) ReflectUtils.getField(intermediateFolderUtils,"types");
        Set<? super QualifiedContent.Scope> scopes = (Set<? super QualifiedContent.Scope>) ReflectUtils.getField(intermediateFolderUtils,"scopes");
        AtlasIntermediateFolderUtils atlasIntermediateFolderUtils = new AtlasIntermediateFolderUtils(intermediateFolderUtils.getRootFolder(),types,scopes);
        field.set(intermediateStream,atlasIntermediateFolderUtils);
        TransformOutputProvider transformOutputProvider = transformInvocation.getOutputProvider();
        ReflectUtils.updateField(transformOutputProvider,"folderUtils",atlasIntermediateFolderUtils);

    }catch (Exception e){

    }


}
 
Example 3
Source File: InjectTransformManager.java    From atlas with Apache License 2.0 6 votes vote down vote up
@NonNull
private static String getTaskNamePrefix(@NonNull Transform transform) {
    StringBuilder sb = new StringBuilder(100);
    sb.append("transform");

    Iterator<QualifiedContent.ContentType> iterator = transform.getInputTypes().iterator();
    // there's always at least one
    sb.append(capitalize(iterator.next().name().toLowerCase(Locale.getDefault())));
    while (iterator.hasNext()) {
        sb.append("And")
                .append(capitalize(iterator.next().name().toLowerCase(Locale.getDefault())));
    }

    sb.append("With").append(capitalize(transform.getName())).append("For");

    return sb.toString();
}
 
Example 4
Source File: TransformInputUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static DirectoryInput makeDirectoryInput(File file, AppVariantContext variantContext) {
    return new DirectoryInput() {
        @Override
        public Map<File, Status> getChangedFiles() {
            return ImmutableMap.of(file, Status.CHANGED);
        }

        @Override
        public String getName() {
            return "folder";
        }

        @Override
        public File getFile() {
            return file;
        }

        @Override
        public Set<QualifiedContent.ContentType> getContentTypes() {
            return ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES);
        }

        @Override
        public Set<? super QualifiedContent.Scope> getScopes() {
            return ImmutableSet.of(Scope.EXTERNAL_LIBRARIES);
        }
    };

}
 
Example 5
Source File: TransformInputUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static JarInput makeJarInput(File file,AppVariantContext variantContext) {
    BuildAtlasEnvTask.FileIdentity finalFileIdentity = AtlasBuildContext.atlasMainDexHelperMap.get(variantContext.getVariantName()).get(file);
    return new JarInput() {
        @Override
        public Status getStatus() {
            return Status.ADDED;
        }

        @Override
        public String getName() {

            return MD5Util.getFileMD5(file);
        }

        @Override
        public File getFile() {
            return file;
        }

        @Override
        public Set<QualifiedContent.ContentType> getContentTypes() {
            return ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES);
        }

        @Override
        public Set<? super QualifiedContent.Scope> getScopes() {
            if (finalFileIdentity == null){
                return  ImmutableSet.of(Scope.EXTERNAL_LIBRARIES);
            }
            if (finalFileIdentity.subProject) {
                return ImmutableSet.of(Scope.SUB_PROJECTS);
            } else {
                return ImmutableSet.of(Scope.EXTERNAL_LIBRARIES);
            }
        }
    };
}
 
Example 6
Source File: DataLoaderTransform.java    From DataLoader with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_JARS;
}
 
Example 7
Source File: WMRouterTransform.java    From WMRouter with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}
 
Example 8
Source File: InlineRTransform.java    From shrinker with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return ImmutableSet.of(CLASSES);
}
 
Example 9
Source File: AbstractTransform.java    From SocialSdkLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}
 
Example 10
Source File: LibraryTransform.java    From EasyRouter with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}
 
Example 11
Source File: ApplicationTransform.java    From EasyRouter with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}