You'll need to take a look at the Clojure source code, to see how it create its own directives. It's quite easy.
First, you need to understand how to implement a Directive. To do that, see an example. Download the clojure templates source code and look into:
./java/tests/com/google/template/soy/basicdirectives/TruncateDirective.java
Then, you'll need to understand a litte bit of Google Guice. Create a Guice module to add your directives:
public class MySoyModule extends AbstractModule {
@Override
protected void configure() {
Multibinder<SoyPrintDirective> soyDirectivesSetBinder = Multibinder.newSetBinder(binder(), SoyPrintDirective.class);
soyDirectivesSetBinder.addBinding().to(DateDirective.class);
}
}
Then, instantiate your builder, using the Guice injector, like this:
Injector injector = Guice.createInjector(new SoyModule(), new MySoyModule());
SoyFileSet.Builder sfsBuilder = injector.getInstance(SoyFileSet.Builder.class);
SoyFileSet sfs = sfsBuilder.add(SoyUtils.class.getResource(source)).build();
Now you can invoke your templates:
SoyTofu simpleTofu = sfs.compileToTofu().forNamespace("soy.examples.simple");
That's it.