Search in sources :

Example 1 with ManifestProvider

use of com.android.manifmerger.ManifestProvider in project atlas by alibaba.

the class AwbBundle method getManifestProviders.

public List<ManifestProvider> getManifestProviders() {
    if (null != _cacheManifestProviders) {
        return _cacheManifestProviders;
    }
    _cacheManifestProviders = new ArrayList<>();
    List<AndroidLibrary> androidLibraries = new ArrayList<>(getAndroidLibraries());
    androidLibraries.add(getAndroidLibrary());
    for (AndroidLibrary androidLibrary : androidLibraries) {
        _cacheManifestProviders.add(new ManifestProvider() {

            @Override
            public File getManifest() {
                return androidLibrary.getManifest();
            }

            @Override
            public String getName() {
                return androidLibrary.getName();
            }
        });
    }
    return _cacheManifestProviders;
}
Also used : AndroidLibrary(com.android.builder.model.AndroidLibrary) ArrayList(java.util.ArrayList) File(java.io.File) ManifestProvider(com.android.manifmerger.ManifestProvider)

Example 2 with ManifestProvider

use of com.android.manifmerger.ManifestProvider in project atlas by alibaba.

the class ManifestHelper method convert.

public static List<ManifestProvider> convert(List<ManifestProvider> manifestProviders, AppVariantContext appVariantContext) {
    List<ManifestProvider> modifyManifest = new ArrayList<>();
    for (ManifestProvider manifestProvider : manifestProviders) {
        File manifest = getModifyManifestFile(manifestProvider.getManifest(), appVariantContext);
        modifyManifest.add(new MainManifestProvider(manifest, manifestProvider.getName()));
    }
    return modifyManifest;
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) ManifestProvider(com.android.manifmerger.ManifestProvider)

Example 3 with ManifestProvider

use of com.android.manifmerger.ManifestProvider in project atlas by alibaba.

the class ManifestHelper method getBundleManifest.

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

Example 4 with ManifestProvider

use of com.android.manifmerger.ManifestProvider 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 5 with ManifestProvider

use of com.android.manifmerger.ManifestProvider in project atlas by alibaba.

the class FeatureLibManifestTask method taskAction.

@TaskAction
public void taskAction() throws DocumentException, IOException {
    mainManifestFile = variantConfiguration.getMainManifest();
    ManifestInfo mainManifestFileObject = getManifestFileObject(mainManifestFile);
    final Set<ResolvedArtifactResult> artifacts = manifests.getArtifacts();
    List<ManifestProvider> providers = Lists.newArrayListWithCapacity(artifacts.size() + 2);
    for (ResolvedArtifactResult artifact : artifacts) {
        File manifestFile = artifact.getFile();
        File modifyManifest = featureVariantContext.getModifiedManifest(artifact);
        ManifestFileUtils.updatePreProcessManifestFile(modifyManifest, manifestFile, mainManifestFileObject, true, featureVariantContext.getAtlasExtension().getTBuildConfig().isIncremental());
        providers.add(new MergeManifests.ConfigAction.ManifestProviderImpl(modifyManifest, MergeManifests.getArtifactName(artifact)));
    }
    if (featureManifests != null) {
        final Set<ResolvedArtifactResult> featureArtifacts = featureManifests.getArtifacts();
        for (ResolvedArtifactResult artifact : featureArtifacts) {
            File directory = artifact.getFile();
            File modifyManifest = featureVariantContext.getModifiedManifest(artifact);
            Collection<BuildOutput> splitOutputs = BuildOutputs.load(VariantScope.TaskOutputType.MERGED_MANIFESTS, directory);
            if (splitOutputs.isEmpty()) {
                throw new GradleException("Could not load manifest from " + directory);
            }
            ManifestFileUtils.updatePreProcessManifestFile(modifyManifest, splitOutputs.iterator().next().getOutputFile(), mainManifestFileObject, true, featureVariantContext.getAtlasExtension().getTBuildConfig().isIncremental());
            providers.add(new MergeManifests.ConfigAction.ManifestProviderImpl(modifyManifest, MergeManifests.getArtifactName(artifact)));
        }
    }
    AtlasBuildContext.androidBuilderMap.get(getProject()).manifestProviders = providers;
}
Also used : BuildOutput(com.android.build.gradle.internal.scope.BuildOutput) GradleException(org.gradle.api.GradleException) ManifestInfo(com.taobao.android.builder.tools.manifest.ManifestInfo) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult) File(java.io.File) ManifestProvider(com.android.manifmerger.ManifestProvider) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

ManifestProvider (com.android.manifmerger.ManifestProvider)6 ArrayList (java.util.ArrayList)5 AndroidLibrary (com.android.builder.model.AndroidLibrary)3 File (java.io.File)3 GradleVariantConfiguration (com.android.build.gradle.internal.core.GradleVariantConfiguration)1 BuildOutput (com.android.build.gradle.internal.scope.BuildOutput)1 VariantScope (com.android.build.gradle.internal.scope.VariantScope)1 ManifestProcessorTask (com.android.build.gradle.tasks.ManifestProcessorTask)1 MergeManifests (com.android.build.gradle.tasks.MergeManifests)1 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 AtlasExtension (com.taobao.android.builder.extension.AtlasExtension)1 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 ManifestInfo (com.taobao.android.builder.tools.manifest.ManifestInfo)1 GradleException (org.gradle.api.GradleException)1 ResolvedArtifactResult (org.gradle.api.artifacts.result.ResolvedArtifactResult)1 TaskAction (org.gradle.api.tasks.TaskAction)1