Add new operators to Aya at runtime
You can either download the jar from the releases page or build the library yourself (see below)
Then in aya, use the :(library.load)
operator to load the jar. Make sure to use the correct path to where you have the jar saved
:(library.load)
will return a list of loaded operators. In this case, there are 2.
aya> "target/aya-library-example-1.0-SNAPSHOT.jar" :(library.load)
[ ":(example.instruction)" ":(example.instruction2)" ]
aya> :(example.instruction)
"hello, world"
aya> :(example.instruction2)
"foo bar"
aya>
You can also use the import statement to load the jar. This will not return the list of loaded operators
aya> import "target/aya-library-example-1.0-SNAPSHOT.jar"
aya> :(example.instruction)
"hello, world"
To build, first install Aya. To install, clone the repo, then from inside the aya dir, run mvn install
git clone https://github.com/aya-lang/aya.git
cd aya
mvn install
To build this library, run the package command
mvn package
A jar can provide one or more NamedInstructionStore
implementations.
This is done by adding the fully qualified class name(s) to this file:
META-INF/services/aya.instruction.named.NamedInstructionStore
For more information, you should look up 'Java SPI' (Service Provider Interface).
- @BlazingTwist
- @nick-paul