Gradle not generating a String with quotes

I’m trying to include a custom field in BuildConfig containing the build date using this function:

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMddHHmmss')
    return formattedDate
}

Then, in defaultConfig I put:

  • DownloadManager COLUMN_LOCAL_FILENAME deprecated
  • Convert normal Java Array or ArrayList to Json Array in android
  • Force Screen On
  • How to display the value of a variable on the screen
  • Eclipse - Disabling compiling of XML files while in Java perspective
  • Android SQLite database: slow insertion
  • buildConfigField "String", "BUILD_NUMBER", getDate()
    

    Problem is, the field generated by Gradle is:

    public static final String BUILD_NUMBER = 20141108114911;
    

    which throws “Integer too large”, but I don’t want an Integer, I want a String!

    I tried to explicitly replace the def with String, tried getDate().toString, getDate() as String and "${getDate()}", and still no quote to surround my String. I also tried to put a character like “-” in the middle of the date, it stills doesn’t generate quotes, making:

    public static final String BUILD_NUMBER = 20141108-114911;
    

    clearly not making any sense…

    I am out of idea here, not being familiar enough with Groovy and so not sure if there’s another (working) way to “enforce” a String.

    Related posts:

    Android: Capturing the return of an activity
    android - package org.apache.http does not exist sdk 23
    How to share internal storage file with Gmail Client
    A resource exists with a different case
    Close app when hitting back button on android
    How to model game object rendering and behavior in modular way?
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.