Class ManifestMerger2.Invoker

java.lang.Object
com.android.manifmerger.ManifestMerger2.Invoker
Enclosing class:
ManifestMerger2

public static class ManifestMerger2.Invoker extends Object
This class will hold all invocation parameters for the manifest merging tool.

There are broadly three types of input to the merging tool :

  • Build types and flavors overriding manifests
  • Application main manifest
  • Library manifest files
Only the main manifest file is a mandatory parameter.

High level description of the merging will be as follow :

  1. Build type and flavors will be merged first in the order they were added. Highest priority file added first, lowest added last.
  2. Resulting document is merged with lower priority application main manifest file.
  3. Resulting document is merged with each library file manifest file in the order they were added. Highest priority added first, lowest added last.
  4. Resulting document is returned as results of the merging process.
  • Field Details

    • mMainManifestFile

      protected final File mMainManifestFile
    • mSystemProperties

      protected final com.google.common.collect.ImmutableMap.Builder<com.android.manifmerger.ManifestSystemProperty,Object> mSystemProperties
    • mLogger

      @NonNull protected final com.android.utils.ILogger mLogger
    • mPlaceholders

      @NonNull protected final com.google.common.collect.ImmutableMap.Builder<String,Object> mPlaceholders
  • Method Details

    • setOverride

      @NonNull public ManifestMerger2.Invoker setOverride(@NonNull com.android.manifmerger.ManifestSystemProperty override, @NonNull String value)
      Sets a value for a ManifestSystemProperty
      Parameters:
      override - the property to set
      value - the value for the property
      Returns:
      itself.
    • setPlaceHolderValues

      @NonNull public ManifestMerger2.Invoker setPlaceHolderValues(@NonNull Map<String,Object> keyValuePairs)
      Adds placeholders names and associated values for substitution.
      Returns:
      itself.
    • setPlaceHolderValue

      @NonNull public ManifestMerger2.Invoker setPlaceHolderValue(@NonNull String placeHolderName, @NonNull String value)
      Adds a new placeholder name and value for substitution.
      Returns:
      itself.
    • setMergeReportFile

      @NonNull public ManifestMerger2.Invoker setMergeReportFile(@Nullable File mergeReport)
      Sets the file to use to write the merging report. If not called, the merging process will not write a report.
      Parameters:
      mergeReport - the file to write the report in.
      Returns:
      itself.
    • addLibraryManifest

      @NonNull public ManifestMerger2.Invoker addLibraryManifest(@NonNull File file)
      Add one library file manifest, will be added last in the list of library files which will make the parameter the lowest priority library manifest file.
      Parameters:
      file - the library manifest file to add.
      Returns:
      itself.
    • addLibraryManifest

      @NonNull public ManifestMerger2.Invoker addLibraryManifest(@NonNull String name, @NonNull File file)
      Add one library file manifest, will be added last in the list of library files which will make the parameter the lowest priority library manifest file.
      Parameters:
      file - the library manifest file to add.
      name - the library name.
      Returns:
      itself.
    • addManifestProviders

      @NonNull public ManifestMerger2.Invoker addManifestProviders(@NonNull Iterable<? extends ManifestProvider> providers)
      Sets manifest providers for this merging activity.
      Parameters:
      providers - the list of manifest providers.
      Returns:
      itself.
    • addLibraryManifests

      @NonNull public ManifestMerger2.Invoker addLibraryManifests(@NonNull File... files)
      Add several library file manifests at the end of the list which will make them the lowest priority manifest files. The relative priority between all the files passed as parameters will be respected.
      Parameters:
      files - library manifest files to add last.
      Returns:
      itself.
    • addFlavorAndBuildTypeManifest

      @NonNull public ManifestMerger2.Invoker addFlavorAndBuildTypeManifest(@NonNull File file)
      Add a flavor or build type manifest file last in the list.
      Parameters:
      file - build type or flavor manifest file
      Returns:
      itself.
    • addFlavorAndBuildTypeManifests

      @NonNull public ManifestMerger2.Invoker addFlavorAndBuildTypeManifests(File... files)
      Add several flavor or build type manifest files last in the list. Relative priorities between the passed files as parameters will be respected.
      Parameters:
      files - build type of flavor manifest files to add.
      Returns:
      itself.
    • withFeatures

      @NonNull public ManifestMerger2.Invoker withFeatures(ManifestMerger2.Invoker.Feature... features)
      Sets some optional features for the merge tool.
      Parameters:
      features - one to many features to set.
      Returns:
      itself.
    • withFileStreamProvider

      @NonNull public ManifestMerger2.Invoker withFileStreamProvider(@Nullable ManifestMerger2.FileStreamProvider provider)
      Sets a file stream provider which allows the client of the manifest merger to provide arbitrary content lookup for files.

      NOTE: There should only be one.

      Parameters:
      provider - the provider to use
      Returns:
      itself.
    • withManifestDocumentProvider

      @NonNull public ManifestMerger2.Invoker withManifestDocumentProvider(@Nullable ManifestMerger2.ManifestDocumentProvider provider)
      Sets a manifest XML document provider which allows the client of the manifest merger to provide manifest DOM Document object lookup for given files.

      NOTE: There should only be one.

      Parameters:
      provider - the provider to use
      Returns:
      itself.
    • withProcessCancellationChecker

      @NonNull public ManifestMerger2.Invoker withProcessCancellationChecker(@NonNull ManifestMerger2.ProcessCancellationChecker checker)
    • setFeatureName

      @NonNull public ManifestMerger2.Invoker setFeatureName(@Nullable String featureName)
      Specify the feature name for feature merging.
      Parameters:
      featureName - the feature name to use.
      Returns:
      itself.
    • setNamespace

      @NonNull public ManifestMerger2.Invoker setNamespace(@NonNull String namespace)
      Specify the module namespace.
      Parameters:
      namespace - the namespace, used to create or shorten fully qualified class names. If specified, this namespace will override the package name in the source manifest.
      Returns:
      itself.
    • addNavigationFiles

      @NonNull public ManifestMerger2.Invoker addNavigationFiles(@NonNull Iterable<File> files)
      Add several navigation files last in the list. Relative priorities between the passed files as parameters will be respected.
      Parameters:
      files - the navigation files to add.
      Returns:
      itself.
    • addNavigationJsons

      @NonNull public ManifestMerger2.Invoker addNavigationJsons(@NonNull Iterable<File> files)
      Add several navigation.json files in the list.
      Parameters:
      files - the navigation.json files to add.
      Returns:
      itself.
    • asType

      @NonNull public ManifestMerger2.Invoker asType(XmlDocument.Type type)
      Specify if the file being merged is an overlay (flavor). If not called, the merging process will assume a master manifest merge. The master manifest needs to have a package and some other mandatory fields like "uses-sdk", etc.
      Returns:
      itself.
    • addDependencyFeatureNames

      public ManifestMerger2.Invoker addDependencyFeatureNames(@NonNull Iterable<String> names)
      Specifies a list of feature modules on which this module will depend. This is only valid for feature manifests.
      Parameters:
      names - the names of the dynamic features.
      Returns:
      itself.
    • addAllowedNonUniqueNamespace

      public ManifestMerger2.Invoker addAllowedNonUniqueNamespace(String namespace)
      Add a namespace that is allowed to appear in more than one library.
      Parameters:
      namespace - the namespace
      Returns:
      itself
    • setGeneratedLocaleConfigAttribute

      public ManifestMerger2.Invoker setGeneratedLocaleConfigAttribute(String generatedLocaleConfigAttribute)
      Set the location of the generated locale config to add to the manifest.
      Parameters:
      generatedLocaleConfigAttribute - the attribute pointing to the generated locale config.
      Returns:
      itself
    • merge

      @NonNull public MergingReport merge() throws ManifestMerger2.MergeFailureException
      Perform the merging and return the result.
      Returns:
      an instance of MergingReport that will give access to all the logging and merging records.

      This method can be invoked several time and will re-do the file merges.

      Throws:
      ManifestMerger2.MergeFailureException - if the merging cannot be completed successfully.