Search in sources :

Example 21 with AndroidLibrary

use of com.android.builder.model.AndroidLibrary in project atlas by alibaba.

the class AwbBundle method getLibraryJars.

public List<File> getLibraryJars() {
    List<File> jars = Lists.newArrayList();
    File awbJar = this.getJarFile();
    jars.add(awbJar);
    List<? extends AndroidLibrary> aarBundles = this.getLibraryDependencies();
    if (null != aarBundles) {
        for (AndroidLibrary aarBundle : aarBundles) {
            if (aarBundle.getJarFile().exists()) {
                jars.add(aarBundle.getJarFile());
            }
        //jars.addAll(aarBundle.getLocalJars());
        }
    }
    Collection<? extends JavaLibrary> javaDependencies = this.getJavaDependencies();
    if (null != javaDependencies) {
        for (JavaLibrary javaLibrary : javaDependencies) {
            if (javaLibrary.getJarFile().exists()) {
                jars.add(javaLibrary.getJarFile());
            }
        }
    }
    Collection<File> localJars = this.getLocalJars();
    if (null != localJars) {
        jars.addAll(localJars);
    }
    return jars;
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) File(java.io.File)

Example 22 with AndroidLibrary

use of com.android.builder.model.AndroidLibrary in project atlas by alibaba.

the class PostProcessManifestTask method getLibManifestDepenendyMap.

public Multimap<String, File> getLibManifestDepenendyMap() {
    Multimap<String, File> maps = HashMultimap.create();
    List<? extends AndroidLibrary> libs = getAwbLibraries();
    if (libs == null || libs.isEmpty()) {
        return maps;
    }
    for (AndroidLibrary mdi : libs) {
        for (AndroidLibrary childLib : mdi.getLibraryDependencies()) {
            ((HashMultimap<String, File>) maps).put(mdi.getName(), childLib.getManifest());
        }
    }
    return maps;
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) HashMultimap(com.google.common.collect.HashMultimap)

Example 23 with AndroidLibrary

use of com.android.builder.model.AndroidLibrary in project atlas by alibaba.

the class PostProcessManifestTask method getLibManifestMap.

public Map<String, File> getLibManifestMap() {
    Map<String, File> maps = Maps.newHashMap();
    List<? extends AndroidLibrary> libs = getAwbLibraries();
    if (libs == null || libs.isEmpty()) {
        return Collections.emptyMap();
    }
    for (AndroidLibrary mdi : libs) {
        ((HashMap<String, File>) maps).put(mdi.getName(), mdi.getManifest());
    }
    return maps;
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) HashMap(java.util.HashMap) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile)

Example 24 with AndroidLibrary

use of com.android.builder.model.AndroidLibrary in project atlas by alibaba.

the class PreProcessManifestTask method addAwbManifest2Merge.

private void addAwbManifest2Merge() {
    AtlasExtension atlasExtension = appVariantContext.getAtlasExtension();
    for (final BaseVariantOutputData vod : appVariantContext.getVariantData().getOutputs()) {
        ManifestProcessorTask manifestProcessorTask = vod.manifestProcessorTask;
        Set<String> notMergedArtifacts = Sets.newHashSet();
        if (null != atlasExtension.getManifestOptions() && null != atlasExtension.getManifestOptions().getNotMergedBundles()) {
            notMergedArtifacts = atlasExtension.getManifestOptions().getNotMergedBundles();
        }
        if (manifestProcessorTask instanceof MergeManifests) {
            MergeManifests mergeManifests = (MergeManifests) manifestProcessorTask;
            VariantScope variantScope = appVariantContext.getScope();
            GradleVariantConfiguration config = variantScope.getVariantConfiguration();
            AndroidDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(config.getFullName());
            if (null == dependencyTree) {
                throw new StopExecutionException("DependencyTree cannot be null!");
            }
            List<? extends AndroidLibrary> awbManifests = ManifestDependencyUtil.getManifestDependencies(dependencyTree.getAwbBundles(), notMergedArtifacts, getLogger());
            for (AndroidLibrary manifest : awbManifests) {
                getLogger().info("[MTLPlugin]Add manifest:" + manifest.getName() + ",path is:" + manifest.getManifest().getAbsolutePath());
            }
            //FIXME 不加这一步,每次的getibraries 都会从mapping里去重新计算
            mergeManifests.setLibraries(mergeManifests.getLibraries());
            mergeManifests.getLibraries().addAll(awbManifests);
        }
    }
}
Also used : AtlasExtension(com.taobao.android.builder.extension.AtlasExtension) VariantScope(com.android.build.gradle.internal.scope.VariantScope) MergeManifests(com.android.build.gradle.tasks.MergeManifests) StopExecutionException(org.gradle.api.tasks.StopExecutionException) AndroidLibrary(com.android.builder.model.AndroidLibrary) GradleVariantConfiguration(com.android.build.gradle.internal.core.GradleVariantConfiguration) BaseVariantOutputData(com.android.build.gradle.internal.variant.BaseVariantOutputData) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) ManifestProcessorTask(com.android.build.gradle.tasks.ManifestProcessorTask)

Example 25 with AndroidLibrary

use of com.android.builder.model.AndroidLibrary 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)

Aggregations

AndroidLibrary (com.android.builder.model.AndroidLibrary)33 File (java.io.File)18 NotNull (org.jetbrains.annotations.NotNull)6 JavaLibrary (com.android.builder.model.JavaLibrary)5 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)5 Module (com.intellij.openapi.module.Module)5 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)5 MavenCoordinates (com.android.builder.model.MavenCoordinates)4 Variant (com.android.builder.model.Variant)4 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)4 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)4 InputFile (org.gradle.api.tasks.InputFile)4 TaskAction (org.gradle.api.tasks.TaskAction)4 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)4 VariantScope (com.android.build.gradle.internal.scope.VariantScope)3 HashSet (java.util.HashSet)3 List (java.util.List)3 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)2 SymbolLoader (com.android.builder.internal.SymbolLoader)2 SymbolWriter (com.android.builder.internal.SymbolWriter)2