Search in sources :

Example 1 with UpdatePomTask

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

the class AtlasLibTaskManager method runTask.

@Override
public void runTask() {
    new UpdatePomTask(project).updatePom();
    libraryExtension.getLibraryVariants().forEach(libraryVariant -> {
        LibVariantContext libVariantContext = new LibVariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
        TBuildType tBuildType = libVariantContext.getBuildType();
        if (null != tBuildType) {
            try {
                new AwoPropHandler().process(tBuildType, atlasExtension.getBundleConfig());
            } catch (Exception e) {
                throw new GradleException("process awo exception", e);
            }
        }
        AwbGenerator awbGenerator = new AwbGenerator(atlasExtension);
        Collection<BaseVariantOutput> list = libVariantContext.getBaseVariant().getOutputs();
        if (null != list) {
            for (BaseVariantOutput libVariantOutputData : list) {
                Zip zipTask = ((LibraryVariantOutput) (libVariantOutputData)).getPackageLibrary();
                if (atlasExtension.getBundleConfig().isJarEnabled()) {
                    new JarExtractTask().generateJarArtifict(zipTask);
                }
                // Build the awb and extension
                if (atlasExtension.getBundleConfig().isAwbBundle()) {
                    awbGenerator.generateAwbArtifict(zipTask, libVariantContext);
                }
                if (null != tBuildType && (StringUtils.isNotEmpty(tBuildType.getBaseApDependency()) || null != tBuildType.getBaseApFile()) && libraryVariant.getName().equals("debug")) {
                    atlasExtension.getTBuildConfig().setUseCustomAapt(true);
                    libVariantContext.setBundleTask(zipTask);
                    try {
                        libVariantContext.setAwbBundle(awbGenerator.createAwbBundle(libVariantContext));
                    } catch (IOException e) {
                        throw new GradleException("set awb bundle error");
                    }
                // if (atlasExtension.getBundleConfig().isAwbBundle()) {
                // createAwoTask(libVariantContext, zipTask);
                // } else {
                // createDexTask(libVariantContext, zipTask);
                // }
                }
            }
        // List<TransformTask>transformTasks =  TransformManager.findTransformTaskByTransformType(libVariantContext,LibraryAarJarsTransform.class);
        // for (TransformTask transformTask: transformTasks){
        // Transform transform = transformTask.getTransform();
        // if (transform instanceof LibraryBaseTransform){
        // ReflectUtils.updateField(transform,"excludeListProviders", Lists.newArrayList(new AtlasExcludeListProvider()));
        // }
        // }
        }
    });
}
Also used : Zip(org.gradle.api.tasks.bundling.Zip) JarExtractTask(com.taobao.android.builder.tasks.library.JarExtractTask) UpdatePomTask(com.taobao.android.builder.tasks.library.publish.UpdatePomTask) LibVariantContext(com.android.build.gradle.internal.api.LibVariantContext) IOException(java.io.IOException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) AwoPropHandler(com.taobao.android.builder.tools.ideaplugin.AwoPropHandler) BaseVariantOutput(com.android.build.gradle.api.BaseVariantOutput) AwbGenerator(com.taobao.android.builder.tasks.library.AwbGenerator) GradleException(org.gradle.api.GradleException) LibraryVariantOutput(com.android.build.gradle.api.LibraryVariantOutput) TBuildType(com.taobao.android.builder.extension.TBuildType)

Aggregations

BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)1 LibraryVariantOutput (com.android.build.gradle.api.LibraryVariantOutput)1 LibVariantContext (com.android.build.gradle.internal.api.LibVariantContext)1 TBuildType (com.taobao.android.builder.extension.TBuildType)1 AwbGenerator (com.taobao.android.builder.tasks.library.AwbGenerator)1 JarExtractTask (com.taobao.android.builder.tasks.library.JarExtractTask)1 UpdatePomTask (com.taobao.android.builder.tasks.library.publish.UpdatePomTask)1 AwoPropHandler (com.taobao.android.builder.tools.ideaplugin.AwoPropHandler)1 IOException (java.io.IOException)1 GradleException (org.gradle.api.GradleException)1 Zip (org.gradle.api.tasks.bundling.Zip)1