Package com.android.manifmerger
Class ManifestMerger2.Invoker
java.lang.Object
com.android.manifmerger.ManifestMerger2.Invoker
- Enclosing class:
- ManifestMerger2
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
High level description of the merging will be as follow :
- Build type and flavors will be merged first in the order they were added. Highest priority file added first, lowest added last.
- Resulting document is merged with lower priority application main manifest file.
- Resulting document is merged with each library file manifest file in the order they were added. Highest priority added first, lowest added last.
- Resulting document is returned as results of the merging process.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOptional behavior of the merging tool can be turned on by setting these Feature. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaddAllowedNonUniqueNamespace(String namespace) Add a namespace that is allowed to appear in more than one library.addDependencyFeatureNames(Iterable<String> names) Specifies a list of feature modules on which this module will depend.Add a flavor or build type manifest file last in the list.addFlavorAndBuildTypeManifests(File... files) Add several flavor or build type manifest files last in the list.addLibraryManifest(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.addLibraryManifest(String name, 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.addLibraryManifests(File... files) Add several library file manifests at the end of the list which will make them the lowest priority manifest files.addManifestProviders(Iterable<? extends ManifestProvider> providers) Sets manifest providers for this merging activity.addNavigationFiles(Iterable<File> files) Add several navigation files last in the list.addNavigationJsons(Iterable<File> files) Add several navigation.json files in the list.asType(XmlDocument.Type type) Specify if the file being merged is an overlay (flavor).merge()Perform the merging and return the result.setFeatureName(String featureName) Specify the feature name for feature merging.setGeneratedLocaleConfigAttribute(String generatedLocaleConfigAttribute) Set the location of the generated locale config to add to the manifest.setMergeReportFile(File mergeReport) Sets the file to use to write the merging report.setNamespace(String namespace) Specify the module namespace.setOverride(com.android.manifmerger.ManifestSystemProperty override, String value) Sets a value for aManifestSystemPropertysetPlaceHolderValue(String placeHolderName, String value) Adds a new placeholder name and value for substitution.setPlaceHolderValues(Map<String, Object> keyValuePairs) Adds placeholders names and associated values for substitution.withFeatures(ManifestMerger2.Invoker.Feature... features) Sets some optional features for the merge tool.Sets a file stream provider which allows the client of the manifest merger to provide arbitrary content lookup for files.Sets a manifest XML document provider which allows the client of the manifest merger to provide manifest DOM Document object lookup for given files.
-
Field Details
-
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
-
-
Method Details
-
setOverride
@NonNull public ManifestMerger2.Invoker setOverride(@NonNull com.android.manifmerger.ManifestSystemProperty override, @NonNull String value) Sets a value for aManifestSystemProperty- Parameters:
override- the property to setvalue- 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
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
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
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
Add a flavor or build type manifest file last in the list.- Parameters:
file- build type or flavor manifest file- Returns:
- itself.
-
addFlavorAndBuildTypeManifests
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
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
Specify the feature name for feature merging.- Parameters:
featureName- the feature name to use.- Returns:
- itself.
-
setNamespace
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.
-
asType
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
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
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
Perform the merging and return the result.- Returns:
- an instance of
MergingReportthat 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.
-