com.android.build.gradle.internal.pipeline.TransformManager Java Examples

The following examples show how to use com.android.build.gradle.internal.pipeline.TransformManager. 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: AwbDexsMerger.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void merge(TransformInvocation transformInvocation) {

    mainDexOut = getDexOutputLocation(transformInvocation.getOutputProvider(),"main", TransformManager.SCOPE_FULL_PROJECT);
    if (!mainDexOut.exists() || !mainDexOut.isDirectory()){
        return;
    }
    atomicInteger.set(org.apache.commons.io.FileUtils.listFiles(mainDexOut,new String[]{"dex"},true).size());
    for (AwbTransform awbTransform : variantOutputContext.getAwbTransformMap().values()) {
       merge(awbTransform.getAwbBundle());
    }

}
 
Example #2
Source File: AtlasDexMerger.java    From atlas with Apache License 2.0 5 votes vote down vote up
public void mergeAll(TransformInvocation transformInvocation) throws IOException {
    ProcessOutput output = outputHandler.createOutput();
    for (File file:allDexsArchives){
        logger.warning("mergeAll File:"+file.getAbsolutePath());
    }
    TransformOutputProvider outputProvider = transformInvocation.getOutputProvider();
    File outputDir =
            getDexOutputLocation(outputProvider, "main", TransformManager.SCOPE_FULL_PROJECT);

    File finalDexDir = new File(outputDir.getParentFile(),"temp");
    finalDexDir.mkdirs();
    List<ForkJoinTask<Void>> mergeTasks = new ArrayList();
    if (dexingType == DexingType.NATIVE_MULTIDEX) {
        mergeTasks.addAll(
                handleNativeMultiDex(
                        allDexsArchives,
                        output,
                        finalDexDir,
                         null));
    } else {
        mergeTasks.addAll(
                handleLegacyAndMonoDex(
                        allDexsArchives, output, finalDexDir, mainDexListFile == null ? null : mainDexListFile.getSingleFile()));
    }

    mergeTasks.forEach(voidForkJoinTask -> voidForkJoinTask.join());

    FileUtils.deleteDirectory(outputDir);
    FileUtils.moveDirectory(finalDexDir,outputDir);

}
 
Example #3
Source File: AtlasProguardTransform.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Set<ContentType> getOutputTypes() {
    if (appVariantContext.getAtlasExtension().getTBuildConfig().isFastProguard() && !appVariantContext.getAtlasExtension().getTBuildConfig().isKeepJavaResAfterProguard()) {
        return TransformManager.CONTENT_CLASS;
    }
    return super.getOutputTypes();
}
 
Example #4
Source File: AtlasDexMerger.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NonNull
protected File getDexOutputLocation(
        @NonNull TransformOutputProvider outputProvider,
        @NonNull String name,
        @NonNull Set<? super QualifiedContent.Scope> scopes) {
    return outputProvider.getContentLocation(name, TransformManager.CONTENT_DEX, scopes, Format.DIRECTORY);
}
 
Example #5
Source File: AtlasMainDexMerger.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void merge(TransformInvocation transformInvocation) {

    if (dexMerger == DexMergerTool.D8) {
        logger.info("D8 is used to merge dex.");
    }

    TransformOutputProvider outputProvider = transformInvocation.getOutputProvider();
    Collection<TransformInput> transformInputs = transformInvocation.getInputs();

    List<File> mainDexFiles = new ArrayList<>();

    final File[][] mergeDexs = {new File[0]};

    File outputDir =
            getDexOutputLocation(outputProvider, "main", TransformManager.SCOPE_FULL_PROJECT);
    // this deletes and creates the dir for the output
    try {
        FileUtils.cleanOutputDir(outputDir);
    } catch (IOException e) {
        e.printStackTrace();
    }

    variantOutputContext.setDexMergeFolder(outputDir);

    transformInputs.forEach((TransformInput transformInput) -> {
        File file = (File) ReflectUtils.getField(transformInput, "optionalRootLocation");
        if (file != null && file.exists()) {
            mainDexFiles.addAll(org.apache.commons.io.FileUtils.listFiles(file, new String[]{"jar", "dex"}, true));
            mergeDexs[0] = file.listFiles(pathname -> pathname.getName().endsWith(".jar") || pathname.isDirectory());
        }
    });


    merge(mainDexFiles,outputDir,mergeDexs);

}
 
Example #6
Source File: TaobaoInstantRunSlicer.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #7
Source File: ResourcesShrinker.java    From atlas with Apache License 2.0 4 votes vote down vote up
public Set<QualifiedContent.Scope> getReferencedScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #8
Source File: AtlasDataBindingMergeArtifactsTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.DATA_BINDING_ARTIFACT;
}
 
Example #9
Source File: AtlasDataBindingMergeArtifactsTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Set<QualifiedContent.Scope> getScopes() {
    return TransformManager.EMPTY_SCOPES;
}
 
Example #10
Source File: AtlasDesugarTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}
 
Example #11
Source File: AtlasDesugarTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #12
Source File: ClassInjectTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_CLASS;
}
 
Example #13
Source File: DelegateProguardTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
    return TransformManager.CONTENT_JARS;
}
 
Example #14
Source File: DelegateProguardTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #15
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 #16
Source File: AbstractTransform.java    From SocialSdkLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #17
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 #18
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;
}
 
Example #19
Source File: ApplicationTransform.java    From EasyRouter with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #20
Source File: ClassInjectTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ScopeType> getScopes() {
    return TransformManager.SCOPE_FULL_WITH_IR_FOR_DEXING;
}
 
Example #21
Source File: ClassInjectTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getOutputTypes() {
    return TransformManager.CONTENT_JARS;
}
 
Example #22
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 #23
Source File: AtlasDexMergerTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_WITH_IR_FOR_DEXING;

}
 
Example #24
Source File: AtlasDexMergerTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.ContentType> getOutputTypes() {
    return TransformManager.CONTENT_DEX;
}
 
Example #25
Source File: AtlasMultiDexListTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.Scope> getReferencedScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #26
Source File: AtlasMultiDexListTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<QualifiedContent.Scope> getScopes() {
    return TransformManager.EMPTY_SCOPES;
}
 
Example #27
Source File: AtlasProguardTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void doMainBundleProguard(TransformInvocation invocation) throws Exception {

        //apply bundle Inout
        Profiler.enter("bundleKeep");
        File bundleKeep = AtlasProguardHelper.generateBundleKeepCfg(appVariantContext);
        Profiler.release();

        Input input = new Input();
        AwbBundle awbBundle = new AwbBundle();
        awbBundle.getAndroidLibraries().addAll(AtlasBuildContext.androidDependencyTrees.get(appVariantContext.getVariantName()).getMainBundle().getAndroidLibraries());
        AwbTransform awbTransform = new AwbTransform(awbBundle);
        input.getAwbBundles().add(awbTransform);

        List<File> unProguardJars = new ArrayList<>();
        //Enter the input
        for (TransformInput transformInput : invocation.getInputs()) {
            for (JarInput jarInput : transformInput.getJarInputs()) {
                File file = jarInput.getFile();
                if (file.getName().startsWith("combined-rmerge")) {
                    unProguardJars.add(file);
                } else if (AtlasBuildContext.atlasMainDexHelperMap.get(appVariantContext.getVariantName()).inMainDex(jarInput)) {
                    awbTransform.getInputLibraries().add(file);
                }
            }
            for (DirectoryInput directoryInput : transformInput.getDirectoryInputs()) {
                if (AtlasBuildContext.atlasMainDexHelperMap.get(appVariantContext.getVariantName()).getInputDirs().contains(directoryInput.getFile())) {
                    awbTransform.getInputLibraries().add(directoryInput.getFile());
                }
            }
        }

        //inputting librarys
        input.getLibraries().addAll(
                appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getBootClasspath(true));
        input.getLibraries().addAll(unProguardJars);

        //The default proguard configuration
        input.getDefaultProguardFiles().addAll(defaultProguardFiles);

        //bundle keeps
        input.getParentKeeps().add(bundleKeep);

        File outFile = invocation.getOutputProvider().getContentLocation("main", getOutputTypes(), getScopes(),
                Format.JAR);

        outFile.delete();
        input.proguardOutputDir = invocation.getOutputProvider().getContentLocation("main", getOutputTypes(), getScopes(),
                Format.DIRECTORY);
        input.printMapping = (File) ReflectUtils.getField(oldTransform, "printMapping");
        input.dump = (File) ReflectUtils.getField(oldTransform, "dump");
        input.printSeeds = (File) ReflectUtils.getField(oldTransform, "printSeeds");
        input.printUsage = (File) ReflectUtils.getField(oldTransform, "printUsage");
        input.printConfiguration = new File(appVariantContext.getProject().getBuildDir(), "outputs/proguard.cfg");

        Profiler.enter("executeproguard");
        BundleProguarder.execute(appVariantContext, input);
        transformInput(input);

        Profiler.release();

        for (File jar : unProguardJars) {

            File to = invocation.getOutputProvider().getContentLocation(FileNameUtils.getUniqueJarName(jar),
                    getOutputTypes(), getScopes(),
                    Format.JAR);
            FileUtils.copyFile(jar, to);

        }

        OriginalStream originalStream = OriginalStream.builder(appVariantContext.getProject(), "proguard-classes")
                .addContentTypes(com.android.build.gradle.internal.pipeline.TransformManager.CONTENT_CLASS)
                .addScope(QualifiedContent.Scope.PROJECT)
                .setFileCollection(appVariantContext.getProject().files(AtlasBuildContext.atlasMainDexHelperMap.get(appVariantContext.getVariantName()).getAllMainDexJars()))
                .build();

        if (nextTransformTask != null) {
            Collection consumedInputStreams = (Collection) ReflectUtils.getField(nextTransformTask, "consumedInputStreams");
            if (appVariantContext.getAtlasExtension().getTBuildConfig().isFastProguard() && consumedInputStreams != null) {
                consumedInputStreams.add(originalStream);
            }
        }

    }
 
Example #28
Source File: WMRouterTransform.java    From WMRouter with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}
 
Example #29
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 #30
Source File: CollectTransform.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getScopes() {
    return TransformManager.SCOPE_FULL_PROJECT;
}