I’ve just been getting started with Fan and after playing around in the shell and modding a few of the examples, just about the first thing I wanted to do was create my own pod.
Pods are the unit of deployment in Fan (roughly equivalent to .jar files in Java), and also serve a similar namespacing purpose to Java packages. As the structure of pod repos has been in a bit of flux recently (for the 1.0.45 release) I ran into some trouble getting started with creating my own pod, so I figured I’d share the love a bit.
A repo in fan is basically a collection of pods that provide functionality in the Fan runtime. When you install the Fan distribution, you’re installing your boot repo. Currently, there’s only provision for one repo in addition to your boot repo, known as a working repo. This is where any pods that you’re developing might happily live. More info on repos here and more info on pods here.
So we want to create a working repo for our pods-in-development, but how? It turns out all you need to do is set the FAN_REPO environment variable and any subsequent pods you build outside the boot repo will get dropped in there.
The source for each of your pods in development can live independently wherever they like and when you build them, the resultant pod will end up in your working repo. You don’t even need to create the folder that FAN_REPO points to – the build process will create it as needed.
The directory structure for your pod should look something like this:
build.fan - build file
pod.fan - pod properties file
/fan - fan source files
/java - java source files
/dotnet - .NET source files
Once you have this structure set up and you have your pod’s scaffolding in place as shown here, cd into mypod and run fan build.fan. You should see some output like:
FindSourceFiles [4 files]
BUILD SUCCESS [1452ms]!
You can confirm that it’s installed properly by running fan -pods which will give a list of all pods in both your boot and working repos. That’s it!