Lets take a closer look at Fantom pods, for later we'll look at how they're built by the build.fan
script.
We'll take a real world example and use BedSheet. Fantom .pod
files are just .zip
files with a .pod
extension. With that in mind, lets open up afBedSheet.pod
:
afBedSheet.pod |-- doc/ | |-- BedClient.apidoc | |-- BedClientRes.apidoc | |-- ... | |-- pod.fandoc | `-- ... |-- fcode/ | |-- AppDestroyer$make$0.fcode | |-- AppDestroyer.fcode | `-- ... |-- res/ | |-- web | | |-- bedSheet.css | | |-- bedSheet.html | | `-- ... | `-- misc | `-- quotes.txt |-- src/ | |-- AppDestroyer.fan | |-- AppRestarter.fan | `-- ... |-- index.props `-- meta.props
doc/ - Documentation
.apidoc
files are text files that hold the Fandoc comments from your code. Fandoc comments are those lines of code prefixed with **
. Example:
** This class is AWESOME!** No really, it is!class Awesome { ... }
These comments end up in the pod so they can be extracted by IDEs and editors.
The doc/
directory also holds the pod.fandoc
. This is a fandoc file. This is the text you see at the bottom of API index pages and usually starts with an Overview section.
fcode/ - Fantom Byte Code
If you weren't aware, just as Java compiles to bytecode, Fantom compiles to fcode
. Therefore For each Fantom class you write, there is at least one corresponding .fcode
file. Obviously these guys are important(!) and can be found in the fcode
directory.
res/ - Resources
The res/
directory contains miscellaneous resources, as required by BedSheet. Anything you want can go in here.
src/ - Fantom Source
The src/
directory contains all the BedSheet Fantom code.
Notice that even though the BedSheet code is organised into multiple directories (see the BedSheet BitBucket repo) all the .fan
files are lumped together in the one src
directory. This is why no two Fantom source files can have the same name, even if they're in different source directories.
Similar to the doc/
directory, the src code directory is intended for use by IDEs and editors (as explained on Fantom Forum).
/ - Fantom Meta Data
Then there are the two property files in the root directory, index.props
and meta.props
.
index.props
props are explained here in the Env documentation. Essentially all the index properties from all the pods are aggregated together and made available via Env.index() method. Think of them as system wide properties.
By comparison meta.props
only concern the pod they're found in. It's pod meta data. The BedSheet meta.props
looks like this:
pod.name=afBedSheet pod.version=1.2.2 pod.depends=sys 1.0;concurrent 1.0;web 1.0;webmod 1.0;wisp 1.0;util 1.0;inet 1.0;afIoc 1.4.10+;afIocConfig 0+;afIocEnv 1+;afPlastic 1.0+ pod.summary=Something fresh and clean to lay your web app on! pod.isScript=false fcode.version=1.0.51 build.host=Hudson build.user=Slimer build.ts=2013-12-22T18:29:33.053Z London build.compiler=1.0.65 build.platform=win32-x86_64 pod.docSrc=true afIoc.module=afBedSheet::BedSheetModule proj.name=BedSheet org.uri=http:\u002f/www.alienfactory.co.uk/ org.name=Alien-Factory pod.native.js=false pod.native.dotnet=false license.name=BSD 2-Clause License pod.native.java=false vcs.uri=https:\u002f/bitbucket.org/AlienFactory/afbedsheet repo.private=false pod.docApi=true
And that's it! Next we'll look at build.fan
and how it creates a .pod
.