Fork us on GitHub

Build Hint Variables

Simplifying the process of customizing cn1libs
Post Image

Build Hint Variables

This is a feature Steve added way back in June but I didn’t get around to documenting it. Build hints can sometimes get "unwieldy" e.g. in the case of ios.plistInject or android.xapplication we sometimes have pretty verbose values.

We now have a way to define a "build hint variable" which the build server substitutes seamlessly. This is useful for "key" values required by API’s that sometimes require boilerplate e.g. the Google Maps support has this:

android.xapplication=<meta-data android:name="" android:value="YOUR_ANDROID_API_KEY"/>

Notice that the one thing that actually matters here is YOUR_ANDROID_API_KEY which makes this problematic. We can’t add this string to the build hints automatically because this is a value you need to set…​

The variables allow us to do this instead:

android.xapplication=<meta-data android:name="" android:value="${var.androidAPIKey}"/>

This might seem more verbose but notice that the cn1lib can now inject the second line automatically and you will need to add this single line: var.androidAPIKey=YOUR_ANDROID_API_KEY

That is far simpler than before and less error prone.

Most cn1libs still don’t take advantage of this syntax but hopefully we’ll move them in that direction as we move forward.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.