Have a barrel with the following module in source/FooConversion.mc
module Foo { (:all :temp :dist) module Conversion { (:all :temp) module Temperature { function toFahrenheit(temp) { return toF(temp); } function toF(temp) { return (temp.toDouble() * 9/5) + 32; } } (:all :dist) module Distance { function toMiles(dist) { return dist.toDouble() * 0.6213711922d; } } }
Have the annotations set in your manifest.xml
Have a test file in your barrel:
using Foo.Conversion.Distance as dist; using Foo.Conversion.Temperature as temp; using Toybox.Test as t; module Foo { (:test) function testThings(logger) { t.assertEqualMessage(temp.toF(0), 32d, "0 C == 32 F"); } }
In the consuming project, include in your monkey.jungle file the following:
Foo = /path/to/barrel.barrel base.Foo.annotations = dist;temp;all base.barreltPath = $(base.barrelPath);$(Foo)
Now compile code and run the tests
Notice you see the following error:
- Unknown module Foo.Conversion.Distance in using or import clause
- Unknown module Foo.Conversion.Temperature in using or import clause
When you remove :temp and :dist annotations from the module Foo (only remove them in the code, leave the other bits), everything gets imported correctly and your tests does not fail. One would expect that multiple annotations work within Barrels.