Search in sources :

Example 51 with AndroidLibrary

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

the class ManifestHelper method getManifestDependencies.

public static List<? extends AndroidLibrary> getManifestDependencies(List<AwbBundle> awbBundles, Set<String> notMergedArtifacts, org.gradle.api.logging.Logger logger) {
    List<AndroidLibrary> list = new ArrayList<>();
    for (AwbBundle lib : awbBundles) {
        // get the dependencies
        // [vliux] respect manifestOption.notMergedBundle
        String cord = String.format("%s:%s", lib.getResolvedCoordinates().getGroupId(), lib.getResolvedCoordinates().getArtifactId());
        if (null == notMergedArtifacts || !notMergedArtifacts.contains(cord)) {
            list.add(lib.getAndroidLibrary());
            list.addAll(lib.getAndroidLibraries());
        } else {
            logger.info("[NotMergedManifest] " + cord);
        }
    }
    return list;
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) ArrayList(java.util.ArrayList) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle)

Example 52 with AndroidLibrary

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

the class ManifestHelper method getMainDexManifest.

public static List<ManifestProvider> getMainDexManifest(AppVariantContext appVariantContext, AtlasDependencyTree dependencyTree, AtlasExtension atlasExtension) {
    Set<String> notMergedArtifacts = getNotMergedBundles(atlasExtension);
    List<ManifestProvider> mainProviders = new ArrayList<>();
    for (AndroidLibrary androidLibrary : dependencyTree.getMainBundle().getAndroidLibraries()) {
        String cord = String.format("%s:%s", androidLibrary.getResolvedCoordinates().getGroupId(), androidLibrary.getResolvedCoordinates().getArtifactId());
        if (null != notMergedArtifacts && notMergedArtifacts.contains(cord)) {
            continue;
        }
        mainProviders.add(createManifestProvider(androidLibrary, appVariantContext));
    }
    return mainProviders;
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) ArrayList(java.util.ArrayList) ManifestProvider(com.android.manifmerger.ManifestProvider)

Example 53 with AndroidLibrary

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

the class ManifestHelper method collectBundleInfo.

public static void collectBundleInfo(AppVariantContext appVariantContext, BundleInfo bundleInfo, File manifest, List<AndroidLibrary> androidLibraries) throws DocumentException {
    SAXReader reader = new SAXReader();
    // Read the XML file
    Document document = reader.read(getModifyManifestFile(manifest, appVariantContext));
    // Get the root node
    Element root = document.getRootElement();
    List<? extends Node> metadataNodes = root.selectNodes("//meta-data");
    for (Node node : metadataNodes) {
        Element element = (Element) node;
        Attribute attribute = element.attribute("name");
        if (attribute.getValue().equals("label")) {
            Attribute labelAttribute = element.attribute("value");
            bundleInfo.setName(labelAttribute.getValue());
        } else if (attribute.getValue().equals("description")) {
            Attribute descAttribute = element.attribute("value");
            bundleInfo.setDesc(descAttribute.getValue());
        } else if (attribute.getValue().startsWith("atlas.fragment.intent.action.")) {
            bundleInfo.getRemoteFragments().put(attribute.getValue(), element.attribute("value").getValue());
        } else if (attribute.getValue().startsWith("atlas.view.intent.action")) {
            bundleInfo.getRemoteViews().put(attribute.getValue(), element.attribute("value").getValue());
        } else if (attribute.getValue().startsWith("atlas.transaction.intent.action")) {
            bundleInfo.getRemoteTransactors().put(attribute.getValue(), element.attribute("value").getValue());
        }
    }
    addComponents(bundleInfo, root);
    if (null != androidLibraries) {
        for (AndroidLibrary depLib : androidLibraries) {
            SAXReader reader2 = new SAXReader();
            Document document2 = reader2.read(// Read the XML file
            getModifyManifestFile(depLib.getManifest(), appVariantContext));
            // Get the root node
            Element root2 = document2.getRootElement();
            addComponents(bundleInfo, root2);
        }
    }
}
Also used : Attribute(org.dom4j.Attribute) AndroidLibrary(com.android.builder.model.AndroidLibrary) SAXReader(org.dom4j.io.SAXReader) Element(org.dom4j.Element) Node(org.dom4j.Node) Document(org.dom4j.Document)

Example 54 with AndroidLibrary

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

the class PostProcessManifestAction method getLibManifestDepenendyMap.

private 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) HashMultimap(com.google.common.collect.HashMultimap)

Example 55 with AndroidLibrary

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

the class PostProcessManifestAction method getLibManifestMap.

private 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)

Aggregations

AndroidLibrary (com.android.builder.model.AndroidLibrary)59 File (java.io.File)39 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)13 JavaLibrary (com.android.builder.model.JavaLibrary)11 ArrayList (java.util.ArrayList)11 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)9 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)8 TaskAction (org.gradle.api.tasks.TaskAction)8 NotNull (org.jetbrains.annotations.NotNull)8 GradleException (org.gradle.api.GradleException)6 VariantScope (com.android.build.gradle.internal.scope.VariantScope)5 MavenCoordinates (com.android.builder.model.MavenCoordinates)5 Variant (com.android.builder.model.Variant)5 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)5 Module (com.intellij.openapi.module.Module)5 JarFile (java.util.jar.JarFile)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 InputFile (org.gradle.api.tasks.InputFile)4 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)4