Class BuildConfigs


  • public class BuildConfigs
    extends Object
    Utilities for generating a BuildConfig.java file for Android.
    • Field Detail

      • DEBUG_CONSTANT

        public static final 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.
        See Also:
        Constant Field Values
      • IS_EXO_CONSTANT

        public static final String IS_EXO_CONSTANT
        Name of a Buck-specific global variable that indicates whether an app was built using exopackage.
        See Also:
        Constant Field Values
      • EXOPACKAGE_FLAGS

        public static final String EXOPACKAGE_FLAGS
        Name of a global variable that includes the exopackage configuration as a bitmask.
        See Also:
        Constant Field Values
    • Method Detail

      • generateBuildConfigDotJava

        public 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.

        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.

        Parameters:
        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.