private final String readNinjaVersion ( ) { // location of the properties file String LOCATION_OF_NINJA_BUILTIN_PROPERTIES = "ninja/ninja-builtin.properties" ; // and the key inside the properties file. String NINJA_VERSION_PROPERTY_KEY = "ninja.version" ; String ninjaVersion ; try ( InputStream stream = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( LOCATION_OF_NINJA_BUILTIN_PROPERTIES ) ) { Properties prop = new Properties ( ) ; prop . load ( stream ) ; ninjaVersion = prop . getProperty ( NINJA_VERSION_PROPERTY_KEY ) ; } catch ( Exception e ) { //this should not happen. Never. throw new RuntimeErrorException ( new Error ( "Something is wrong with your build. Cannot find resource " + LOCATION_OF_NINJA_BUILTIN_PROPERTIES ) ) ; } return ninjaVersion ; }
Simply reads a property resource file that contains the version of this Ninja build . Helps to identify the Ninja version currently running .