public class BuildConfigs extends Object
BuildConfig.java
file for Android.Modifier and Type | Field and Description |
---|---|
static String |
DEBUG_CONSTANT
Name of the boolean global variable provided by the standard Android tools to indicate whether
an app was built in debug mode or not.
|
static String |
EXOPACKAGE_FLAGS
Name of a global variable that includes the exopackage configuration as a bitmask.
|
static String |
IS_EXO_CONSTANT
Name of a Buck-specific global variable that indicates whether an app was built using
exopackage.
|
Modifier and Type | Method and Description |
---|---|
static String |
generateBuildConfigDotJava(UnflavoredBuildTarget source,
String javaPackage)
Generates the source code for an Android
BuildConfig.java file with the default set of
fields specified by getDefaultBuildConfigFields() . |
static String |
generateBuildConfigDotJava(UnflavoredBuildTarget source,
String javaPackage,
boolean useConstantExpressions,
BuildConfigFields userFields)
Generates the source code for an Android
BuildConfig.java file with fields specified by
userFields . |
static BuildConfigFields |
getDefaultBuildConfigFields()
Returns a list of fields (with values) that every
BuildConfig.java should declare. |
public static final String DEBUG_CONSTANT
public static final String IS_EXO_CONSTANT
public static final String EXOPACKAGE_FLAGS
public static BuildConfigFields getDefaultBuildConfigFields()
BuildConfig.java
should declare. The
default value of each constant may be overridden by the userFields
passed to generateBuildConfigDotJava(UnflavoredBuildTarget, String, boolean, BuildConfigFields)
when
generating a BuildConfig.java
.public static String generateBuildConfigDotJava(UnflavoredBuildTarget source, String javaPackage)
BuildConfig.java
file with the default set of
fields specified by getDefaultBuildConfigFields()
.public static String generateBuildConfigDotJava(UnflavoredBuildTarget source, String javaPackage, boolean useConstantExpressions, BuildConfigFields userFields)
BuildConfig.java
file with fields specified by
userFields
.
The output will also contain a constant for every entry in the collection returned by getDefaultBuildConfigFields()
.
If the name of a field in userFields
matches one in the collection returned by
getDefaultBuildConfigFields()
, the value in the userFields
map will be used.
javaPackage
- The package for the Java class generated by this method.useConstantExpressions
- If true
, the value for each static final field in the
generated class will be declared as the literal value in userFields
. The values of
such fields can be inlined by javac
.
If false
, the value for each static final field in the generated class will be
declared as a non-constant expression that is guaranteed to evaluate to the same value in
userFields
. This ensures that the generated BuildConfig.java
can still be
used in Robolectric tests, but does not run the risk of its values being inlined by javac
. This is important if the generated BuildConfig
class is going to be swapped
out by a different implementation by AndroidBinary
. See AndroidBuildConfig
for details.
userFields
- represents the fields that should be declared in the generated BuildConfig
class.