BladeRunner will recognise the newly created folder as a library, as opposed to just a folder containing JS classes and objects. This means you can share your library code across multiple applications, as well as publishing code to make it available to other users of BladeRunner.
Creating a new library
The 'create-library' command will add a library to an existing application directory:
To begin, open up the command-line interface on your machine. From here, navigate to your sdk directory in your BladeRunner installation folder.
Then execute the following command from within the sdk directory, replacing app-name with the name of your existing application, and library-name with a name of your choosing:
bladerunner create-library <app-name> <library-name> <library-namespace>
This should then have created a directory structure that resembles the following:
Following on this structure,
Source code can be placed within the src directory
Resources can be placed within the resource directory
Tests can be placed within the test directory
Directory structure for user libraries
Any resources that are used by a library must reside in the resources directory, reflecting the structure of the src directory, like this:
So, the idea here is that if you refer to
pkg.OtherClass within your code, then only
pkg1/config.xml will be bundled. However, if you refer to
pkg1.pkg2.Class, then it will cause both the resources at the same directory level plus parent package levels to be bundled. In our example, this would give you the following:
Therefore, by being placed at a higher level directory, common resources can be shared across classes in different packages. You can see that the way resources are handled for user libraries differs from that for aspects, blades and bladesets - for user libraries, only the required resources are packaged, whereas for the other BladeRunner structures, everything is packaged.