Search in sources :

Example 6 with FolderResource

use of org.bndtools.templating.FolderResource in project bndtools by bndtools.

the class MustacheTemplateEngineTest method testBasic.

@Test
public void testBasic() throws Exception {
    MustacheTemplateEngine engine = new MustacheTemplateEngine();
    ResourceMap input = new ResourceMap();
    input.put("{{srcDir}}/", new FolderResource());
    input.put("{{srcDir}}/{{packageDir}}/", new FolderResource());
    input.put("{{srcDir}}/{{packageDir}}/package-info.java", new StringResource("package {{packageName}};"));
    Map<String, List<Object>> params = new HashMap<>();
    params.put("srcDir", Collections.<Object>singletonList("src"));
    params.put("packageDir", Collections.<Object>singletonList("org/example/foo"));
    params.put("packageName", Collections.<Object>singletonList("org.example.foo"));
    ResourceMap output = engine.generateOutputs(input, params, new NullProgressMonitor());
    assertEquals(3, output.size());
    assertEquals("package org.example.foo;", IO.collect(output.get("src/org/example/foo/package-info.java").getContent()));
}
Also used : ResourceMap(org.bndtools.templating.ResourceMap) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) StringResource(org.bndtools.templating.StringResource) HashMap(java.util.HashMap) FolderResource(org.bndtools.templating.FolderResource) List(java.util.List) Test(org.junit.Test)

Aggregations

FolderResource (org.bndtools.templating.FolderResource)6 ResourceMap (org.bndtools.templating.ResourceMap)5 HashMap (java.util.HashMap)4 List (java.util.List)4 StringResource (org.bndtools.templating.StringResource)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 Test (org.junit.Test)4 File (java.io.File)2 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 JarInputStream (java.util.jar.JarInputStream)1 BytesResource (org.bndtools.templating.BytesResource)1 FileResource (org.bndtools.templating.FileResource)1 Resource (org.bndtools.templating.Resource)1