Search in sources :

Example 21 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.

the class MergeManifestAwbsConfigAction method execute.

@Override
public void execute(MtlParallelTask parallelTask) {
    super.execute(parallelTask);
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName());
    if (null == androidDependencyTree) {
        return;
    }
    List<DefaultTask> tasks = new ArrayList<DefaultTask>();
    AppVariantOutputContext appVariantOutputContext = getAppVariantOutputContext();
    for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
        List<ManifestMerger2.Invoker.Feature> optionalFeatures = ImmutableList.<ManifestMerger2.Invoker.Feature>of();
        MergeAwbManifests.ConfigAction configAction = new MergeAwbManifests.ConfigAction(appVariantOutputContext.getOutputScope(), awbBundle, optionalFeatures, appVariantOutputContext);
        MergeAwbManifests mergeAwbManifests = TaskCreater.create(appVariantContext.getProject(), configAction.getName(), configAction.getType());
        configAction.execute(mergeAwbManifests);
        tasks.add(mergeAwbManifests);
    }
    parallelTask.parallelTask = tasks;
    parallelTask.uniqueTaskName = getName();
}
Also used : ArrayList(java.util.ArrayList) DefaultTask(org.gradle.api.DefaultTask) ManifestMerger2(com.android.manifmerger.ManifestMerger2) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AppVariantOutputContext(com.android.build.gradle.internal.api.AppVariantOutputContext) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle)

Example 22 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.

the class PrepareAwoBundleTask method doFullTaskAction.

@TaskAction
public void doFullTaskAction() throws IOException {
    AwbBundle awbBundle = libVariantContext.getAwbBundle();
    prepare(awbBundle.getBundle(), awbBundle.getFolder(), true);
    List<SoLibrary> soLibraries = awbBundle.getSoLibraries();
    for (final SoLibrary soLibrary : soLibraries) {
        prepare(soLibrary.getSoLibFile(), soLibrary.getFolder(), false);
    }
    List<? extends AndroidLibrary> aarBundles = awbBundle.getLibraryDependencies();
    for (final AndroidLibrary libraryDependency : aarBundles) {
        if (libraryDependency instanceof AarBundle) {
            AarBundle aarBundle = (AarBundle) libraryDependency;
            prepare(aarBundle.getBundle(), aarBundle.getFolder(), true);
        }
    }
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 23 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.

the class ApkFileListUtils method recordApkFileInfos.

/**
     * 记录apk文件的资源信息
     */
public static void recordApkFileInfos(AppVariantContext appVariantContext) {
    if (inited) {
        return;
    }
    inited = true;
    List<File> mainBundleResFolders = new ArrayList<File>();
    mainBundleResFolders.add(appVariantContext.getScope().getVariantData().mergeResourcesTask.getOutputDir());
    prepareApkFileList(appVariantContext.getScope().getVariantData().mergeAssetsTask.getOutputDir(), "assets");
    for (File resFolder : mainBundleResFolders) {
        prepareApkFileList(resFolder, "res");
    }
    // 记录各自bundle的资源信息
    AndroidDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(appVariantContext.getScope().getVariantConfiguration().getFullName());
    if (null == dependencyTree) {
        throw new StopExecutionException("DependencyTree cannot be null!");
    }
    List<AwbBundle> libs = dependencyTree.getAwbBundles();
    for (AwbBundle awbLib : libs) {
        File mergeAssertFolder = appVariantContext.getMergeAssets(awbLib);
        File mergeResFolder = appVariantContext.getMergeResources(awbLib);
        String awbName = awbLib.getName();
        prepareApkFileList(mergeAssertFolder, "assets", awbName);
        prepareApkFileList(mergeResFolder, "res", awbName);
    }
}
Also used : StopExecutionException(org.gradle.api.tasks.StopExecutionException) ArrayList(java.util.ArrayList) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File)

Example 24 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.

the class BundleInfoUtils method setupAwbBundleInfos.

public static void setupAwbBundleInfos(AppVariantContext appVariantContext) throws IOException, DocumentException {
    String apkVersion = appVariantContext.getVariantConfiguration().getVersionName();
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(appVariantContext.getScope().getVariantConfiguration().getFullName());
    /**
         * name 是artifictId
         */
    Map<String, BundleInfo> bundleInfoMap = getBundleInfoMap(appVariantContext);
    for (AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
        update(awbBundle, bundleInfoMap, appVariantContext, apkVersion);
    }
}
Also used : BundleInfo(com.taobao.android.builder.tools.bundleinfo.model.BundleInfo) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle)

Example 25 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle in project atlas by alibaba.

the class DiffBundleInfoTask method getArtifactBundleInfo.

private Set<ArtifactBundleInfo> getArtifactBundleInfo(DependencyDiff dependencyDiff, File mainfestFile, File apDir) throws IOException, DocumentException {
    Set<ArtifactBundleInfo> artifactBundleInfos = new HashSet<ArtifactBundleInfo>();
    if (null == apDir) {
        throw new GradleException("No Ap dependency found!");
    }
    File apManifest = new File(apDir, "AndroidManifest.xml");
    String apVersion = null;
    try {
        apVersion = ManifestFileUtils.getVersionName(apManifest);
    } catch (Exception e) {
        throw new GradleException(e.getMessage(), e);
    }
    // 1. 首先添加主bundle
    ArtifactBundleInfo mainBundleInfo = getMainArtifactBundInfo(mainfestFile);
    mainBundleInfo.setBaseVersion(apVersion);
    mainBundleInfo.setMainBundle(true);
    mainBundleInfo.setVersion(appVariantOutputContext.getVariantContext().getVariantConfiguration().getVersionName());
    if (dependencyDiff.getMainDexDiffs().size() > 0) {
        mainBundleInfo.setDiffType(DiffType.MODIFY);
    } else {
        mainBundleInfo.setDiffType(DiffType.NONE);
    }
    artifactBundleInfos.add(mainBundleInfo);
    // 2. 添加各自的bundle
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(appVariantOutputContext.getVariantContext().getVariantConfiguration().getFullName());
    for (AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
        BundleInfo bundleInfo = awbBundle.bundleInfo;
        ArtifactBundleInfo awbBundleInfo = new ArtifactBundleInfo();
        awbBundleInfo.setMainBundle(false);
        awbBundleInfo.setDependency(bundleInfo.getDependency());
        awbBundleInfo.setPkgName(bundleInfo.getPkgName());
        awbBundleInfo.setApplicationName(bundleInfo.getApplicationName());
        awbBundleInfo.setArtifactId(awbBundle.getResolvedCoordinates().getArtifactId());
        awbBundleInfo.setName(bundleInfo.getName());
        String version = bundleInfo.getVersion();
        if (version.indexOf("@") > 0) {
            String[] arr = version.split("@");
            version = arr[arr.length - 1];
        }
        awbBundleInfo.setVersion(version);
        String libBundleName = getBundleName(awbBundle);
        if (dependencyDiff.getAwbDiffs().contains(libBundleName)) {
            if (dependencyDiff.getNewAwbs().contains(libBundleName)) {
                awbBundleInfo.setDiffType(DiffType.ADD);
            } else {
                awbBundleInfo.setDiffType(DiffType.MODIFY);
            }
        } else {
            awbBundleInfo.setDiffType(DiffType.NONE);
        }
        artifactBundleInfos.add(awbBundleInfo);
    }
    return artifactBundleInfos;
}
Also used : ArtifactBundleInfo(com.taobao.android.object.ArtifactBundleInfo) BundleInfo(com.taobao.android.builder.tools.bundleinfo.model.BundleInfo) ArtifactBundleInfo(com.taobao.android.object.ArtifactBundleInfo) GradleException(org.gradle.api.GradleException) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) HashSet(java.util.HashSet)

Aggregations

AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)25 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)19 ArrayList (java.util.ArrayList)13 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)10 File (java.io.File)10 TaskAction (org.gradle.api.tasks.TaskAction)10 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)6 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)5 DefaultTask (org.gradle.api.DefaultTask)5 GradleException (org.gradle.api.GradleException)5 AndroidLibrary (com.android.builder.model.AndroidLibrary)4 BundleInfo (com.taobao.android.builder.tools.bundleinfo.model.BundleInfo)4 AarBundle (com.taobao.android.builder.dependency.model.AarBundle)3 HashSet (java.util.HashSet)3 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)2 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)2 JarDependency (com.android.builder.dependency.JarDependency)2 LibraryDependency (com.android.builder.dependency.LibraryDependency)2 JavaLibrary (com.android.builder.model.JavaLibrary)2 IOException (java.io.IOException)2