Search code examples
ballerina

How to include resources in a BALA file


When I'm packing a ballerina project in a BALA file with bal pack, I need to pack some resources that are in the ballerina project into the BALA.

I tried packing the resources inside the ballerina project but it didn't get packed in the BALA.

|- main.bal
|- Ballerina.toml
|- resources
   |- help.txt

I need to pack help.txt in the BALA.


Solution

  • You can use the include field of the [package] table in the Ballerina.toml to pack any resources in the BALA. Here you can use a file path relative to the root of the package or a gitignore type wildcard to pack the files.

    [package]
    include = [“resources/help.txt”]
    

    or,

    [package]
    include = [“resources/*.txt”, “*.png”]