Build Tag

This example shows how to generate a "BuildTag" class which contains the current version number, git hash, timestamp, user, etc. info from when the software was built. By compiling it into the generated source, we have an accurate tag to help diagnose problems and trace the history of a given executable. This examples shows a few different features:

Here's the source for the BuildTag subclass that is generated to include the build info:

file: example/buildTag/
import sc.obj.BuildInit;
import sc.layer.LayerUtil;

  * This file is used to inject values from build-time expressions into the generated code. 
  * We can take the binaries with specific info derived from when it was built. 
object ExBuildTag extends sc.util.BuildTag {
   override @BuildInit("new java.util.Date().toString()") timeStamp;
   override @BuildInit("System.getProperty(\"\")") user;
   override @BuildInit("System.getProperty(\"java.version\")") javaVersion;
   // Want one string for the osVersion.  TODO: maybe call this osVersionStamp?
   override @BuildInit("System.getProperty(\"\") + '.' + System.getProperty(\"os.arch\") + '.' + System.getProperty(\"os.version\")") osVersion;
   // Returns the top-most '' definition of a property or null if there is none
   override @BuildInit("getLayerProperty(\"build\",\"version\")") version;
   override @BuildInit("getLayerProperty(\"build\",\"tag\")") tag;
   override @BuildInit("getLayerProperty(\"build\",\"revision\")") revision;
   override @BuildInit("sc.layer.LayerUtil.incrBuildNumber(\"scc\")") buildNumber;
   // Evaluates a layer variable scmVersion
   override @BuildInit("scmVersion") scmVersion;
And for the default build properties:
version=0.1.0 tag=dev

To compile a release build, you can override the defaults by adding a command line option: scc -Pbuild.tag=release example.buildTag