Search in sources :

Example 1 with AndroidComponetCreator

use of com.taobao.android.builder.tasks.library.AndroidComponetCreator in project atlas by alibaba.

the class AtlasLibTaskManager method runTask.

@Override
public void runTask() {
    //不做资源的合并
    if (!atlasExtension.getBundleConfig().isMergeRes()) {
        new ResMerger(project).mergeRes();
    }
    //对maven发布失败做异常翻译, 一目了然
    new PublishHooker(project).hookPublish();
    libraryExtension.getLibraryVariants().forEach(new Consumer<LibraryVariant>() {

        @Override
        public void accept(LibraryVariant libraryVariant) {
            //if ("debug".equals(libraryVariant.getBaseName())) {
            //    new ModuleInfoWriter(project,libraryVariant).write();
            //}
            LibVariantContext libVariantContext = new LibVariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
            List<Zip> zipTasks = libVariantContext.getZipTasks();
            if (zipTasks.isEmpty()) {
                return;
            }
            for (Zip zipTask : zipTasks) {
                new AndroidComponetCreator(atlasExtension, project).createAndroidComponent(zipTask);
                //生成 awb 和 jar
                new AwbGenerator(atlasExtension).generate(zipTask);
            }
        }
    });
    libraryExtension.getLibraryVariants().forEach(new Consumer<LibraryVariant>() {

        @Override
        public void accept(LibraryVariant libraryVariant) {
            LibVariantContext libVariantContext = new LibVariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
            List<Zip> zipTasks = libVariantContext.getZipTasks();
            if (zipTasks.isEmpty()) {
                return;
            }
            for (Zip zipTask : zipTasks) {
                TBuildType tBuildType = libVariantContext.getBuildType();
                if (null != tBuildType) {
                    try {
                        new AwoPropHandler().process(tBuildType, atlasExtension.getBundleConfig());
                    } catch (Exception e) {
                        throw new GradleException("process awo exception", e);
                    }
                }
                //TODO DEBUG it
                if (atlasExtension.getBundleConfig().isAwoBuildEnabled() && libraryVariant.getName().equals("debug")) {
                    libVariantContext.setBundleTask(zipTask);
                    try {
                        libVariantContext.setAwbBundle(createAwbBundle(libVariantContext, libraryVariant.getName()));
                    } catch (IOException e) {
                        throw new GradleException("set awb bundle error");
                    }
                    if (atlasExtension.getBundleConfig().isAwbBundle()) {
                        createAwoTask(libVariantContext, zipTask);
                    } else {
                        createDexTask(libVariantContext, zipTask);
                    }
                }
            }
        }
    });
}
Also used : Zip(org.gradle.api.tasks.bundling.Zip) ResMerger(com.taobao.android.builder.tasks.library.ResMerger) PublishHooker(com.taobao.android.builder.tasks.library.PublishHooker) LibVariantContext(com.android.build.gradle.internal.api.LibVariantContext) IOException(java.io.IOException) AndroidComponetCreator(com.taobao.android.builder.tasks.library.AndroidComponetCreator) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) AwoPropHandler(com.taobao.android.builder.tools.ideaplugin.AwoPropHandler) AwbGenerator(com.taobao.android.builder.tasks.library.AwbGenerator) LibraryVariant(com.android.build.gradle.api.LibraryVariant) GradleException(org.gradle.api.GradleException) ArrayList(java.util.ArrayList) List(java.util.List) LibraryVariantImpl(com.android.build.gradle.internal.api.LibraryVariantImpl) TBuildType(com.taobao.android.builder.extension.TBuildType)

Aggregations

LibraryVariant (com.android.build.gradle.api.LibraryVariant)1 LibVariantContext (com.android.build.gradle.internal.api.LibVariantContext)1 LibraryVariantImpl (com.android.build.gradle.internal.api.LibraryVariantImpl)1 TBuildType (com.taobao.android.builder.extension.TBuildType)1 AndroidComponetCreator (com.taobao.android.builder.tasks.library.AndroidComponetCreator)1 AwbGenerator (com.taobao.android.builder.tasks.library.AwbGenerator)1 PublishHooker (com.taobao.android.builder.tasks.library.PublishHooker)1 ResMerger (com.taobao.android.builder.tasks.library.ResMerger)1 AwoPropHandler (com.taobao.android.builder.tools.ideaplugin.AwoPropHandler)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GradleException (org.gradle.api.GradleException)1 Zip (org.gradle.api.tasks.bundling.Zip)1