com.android.manifmerger
Class ManifestMerger2.Invoker<T extends ManifestMerger2.Invoker<T>>

java.lang.Object
  extended by com.android.manifmerger.ManifestMerger2.Invoker<T>
Enclosing class:
ManifestMerger2

public static final class ManifestMerger2.Invoker<T extends ManifestMerger2.Invoker<T>>
extends java.lang.Object

This class will hold all invocation parameters for the manifest merging tool. There are broadly three types of input to the merging tool :

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.


Nested Class Summary
static class ManifestMerger2.Invoker.Feature
          Optional behavior of the merging tool can be turned on by setting these Feature.
 
Field Summary
protected  com.android.utils.ILogger mLogger
           
protected  java.io.File mMainManifestFile
           
protected  com.google.common.collect.ImmutableMap.Builder<java.lang.String,java.lang.Object> mPlaceHolders
           
protected  com.google.common.collect.ImmutableMap.Builder<ManifestMerger2.SystemProperty,java.lang.Object> mSystemProperties
           
 
Method Summary
 ManifestMerger2.Invoker addFlavorAndBuildTypeManifest(java.io.File file)
          Add a flavor or build type manifest file last in the list.
 ManifestMerger2.Invoker addFlavorAndBuildTypeManifests(java.io.File... files)
          Add several flavor or build type manifest files last in the list.
 ManifestMerger2.Invoker addLibraryManifest(java.io.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.
 ManifestMerger2.Invoker addLibraryManifests(java.io.File... files)
          Add several library file manifests at then end of the list which will make them the lowest priority manifest files.
 ManifestMerger2.Invoker addLibraryManifests(java.util.List<com.android.utils.Pair<java.lang.String,java.io.File>> namesAndFiles)
           
 MergingReport merge()
          Perform the merging and return the result.
 ManifestMerger2.Invoker setMergeReportFile(java.io.File mergeReport)
          Sets the file to use to write the merging report.
 ManifestMerger2.Invoker setOverride(ManifestMerger2.SystemProperty override, java.lang.String value)
          Sets a value for a ManifestMerger2.SystemProperty
 ManifestMerger2.Invoker setPlaceHolderValue(java.lang.String placeHolderName, java.lang.String value)
          Adds a new placeholder name and value for substitution.
 ManifestMerger2.Invoker setPlaceHolderValues(java.util.Map<java.lang.String,java.lang.String> keyValuePairs)
          Adds placeholders names and associated values for substitution.
 ManifestMerger2.Invoker withFeatures(ManifestMerger2.Invoker.Feature... features)
          Sets some optional features for the merge tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mMainManifestFile

protected final java.io.File mMainManifestFile

mSystemProperties

protected final com.google.common.collect.ImmutableMap.Builder<ManifestMerger2.SystemProperty,java.lang.Object> mSystemProperties

mLogger

protected final com.android.utils.ILogger mLogger

mPlaceHolders

protected final com.google.common.collect.ImmutableMap.Builder<java.lang.String,java.lang.Object> mPlaceHolders
Method Detail

setOverride

public ManifestMerger2.Invoker setOverride(ManifestMerger2.SystemProperty override,
                                           java.lang.String value)
Sets a value for a ManifestMerger2.SystemProperty

Parameters:
override - the property to set
value - the value for the property
Returns:
itself.

setPlaceHolderValues

public ManifestMerger2.Invoker setPlaceHolderValues(java.util.Map<java.lang.String,java.lang.String> keyValuePairs)
Adds placeholders names and associated values for substitution.

Returns:
itself.

setPlaceHolderValue

public ManifestMerger2.Invoker setPlaceHolderValue(java.lang.String placeHolderName,
                                                   java.lang.String value)
Adds a new placeholder name and value for substitution.

Returns:
itself.

setMergeReportFile

public ManifestMerger2.Invoker setMergeReportFile(@NonNull
                                                  java.io.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

public ManifestMerger2.Invoker addLibraryManifest(java.io.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.

addLibraryManifests

public ManifestMerger2.Invoker addLibraryManifests(java.util.List<com.android.utils.Pair<java.lang.String,java.io.File>> namesAndFiles)

addLibraryManifests

public ManifestMerger2.Invoker addLibraryManifests(java.io.File... files)
Add several library file manifests at then 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

public ManifestMerger2.Invoker addFlavorAndBuildTypeManifest(java.io.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

public ManifestMerger2.Invoker addFlavorAndBuildTypeManifests(java.io.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

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.

merge

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.