@@ -27,6 +27,9 @@ import org.jamplate.impl.model.FileDocument
2727import org.jamplate.model.Compilation
2828import org.jamplate.model.Document
2929import org.jamplate.model.Environment
30+ import org.jamplate.model.Memory
31+
32+ import java.util.function.Function
3033
3134@SuppressWarnings (' GrMethodMayBeStatic' )
3235class ProcessJamplateTask extends DefaultTask {
@@ -35,22 +38,19 @@ class ProcessJamplateTask extends DefaultTask {
3538 @OutputDirectory
3639 File output
3740
38- protected Map defaultMemory
41+ protected Map<String , Object > defaultMemory
42+ protected Function<Compilation , Memory > memorySupplier
3943
4044 @TaskAction
4145 void processJamplate () throws IOException {
42- jamplate(input, output, defaultMemory)
43- }
44-
45- protected static void jamplate (File input , File output , Map memoryDefaults ) {
4646 Objects . requireNonNull(input, " input" )
4747 Objects . requireNonNull(output, " output" )
4848
4949 Document [] documents = FileDocument . hierarchy(input)
5050
5151 Environment environment = new EnvironmentImpl ()
5252
53- environment. meta[Meta . MEMORY ] = memoryDefaults
53+ environment. meta[Meta . MEMORY ] = defaultMemory
5454 environment. meta[Meta . PROJECT ] = input
5555 environment. meta[Meta . OUTPUT ] = output
5656
@@ -69,7 +69,9 @@ class ProcessJamplateTask extends DefaultTask {
6969 .filter({ compilation -> compilation. rootTree. document(). toString(). endsWith(" .jamplate" ) })
7070 .toArray({ len -> new Compilation [len] })
7171
72- boolean executed = Jamplate . execute(environment, jamplates)
72+ boolean executed = this . memorySupplier == null ?
73+ Jamplate . execute(environment, jamplates) :
74+ Jamplate . execute(environment, this . memorySupplier, jamplates)
7375
7476 if (! executed) {
7577 System . err. println (" Runtime Error\n " )
0 commit comments