Thursday, August 16, 2018, 5:34:49 PM, Woonsan Ko wrote:

> On Thu, Aug 16, 2018 at 7:19 AM, Dékány Dániel <[email protected]> wrote:
>> Woonsan Ko <[email protected]> írta:
>>>Hi Mark,
>>>
>>>Thanks a lot for the elaborated answers!
>>>Now I understand the use case and its goodness by having "spec" json
>>>file for each "generated source" with being able to use the shared
>>>FreeMarker "template".
>>>
>>>I'm just thinking aloud, but from user's perspective, I'm thinking of
>>>an example structure (package structure is up to users) like this:
>>>
>>>- [Template] 
>>>src/main/freemarker/com/example/templates/generic-code-gen-template.ftl
>>>- [Spec] src/main/freemarker/com/example/Foo.spec.json
>>>- [Spec] src/main/freemarker/com/example/Bar.spec.json
>>>
>>>==> Generating Foo.java and Bar.java under the outputDirectory.
>>
>> I miss the ".java" from that. The original logic is that you remove the 
>> ".json" from the end, and that's the output file name. Like you could have a 
>> foo.xml.json, and now it generates foo.xml, not a java file.
>
> I thought ".java" could be the default output extension to be appended
> after removing the suffix, ".spec.json", but your idea sounds better:
> Output file name followed by .json.
>
>>
>> So, I guess that the containing directory decides the purpose of the file is 
>> find.

I meant "is fine" above.

>> That all this is inside /src/main/freemarker is more questionable though. 
>> Similarly as docgen has /src/main/docgen (and that uses FreeMarker too BTW), 
>> this should have some more specific name as well.
>
> It could be single directory, by default, for both .json and .ftl,
> with options to allow override the plugin configurations.

I don't know, to me it seems practical that you have a directory where
you see what output files you will have, and nothing more. If you mix
that with the templates, which themselves do not produce output...
it's kind of confusing.

> e.g,
> <sourceDirectory>src/main/data</sourceDirectory>,
> <templateDirectory>src/main/freemarker</templateDirectory>.
>
>>
>> A more interesting question is if this plugin could support the other 
>> approach as well, where you have one template per output file, and usually 
>> one shared data-model. That's the logic that FMPP follows for example (with 
>> some twist, like its XML file transformation feature works more like this 
>> plugin). Of course, FMPP targets a different use case than this plugin, but 
>> maybe it can do both without becoming messy.
>
> The use case with single shared data-model could be covered by an
> optional plugin configuration, as a global model. In that case the
> spec json file just points to the processing FreeMarker template. Or
> even the default FreeMarker template could be configured in the plugin
> configuration optionally. Then there could be only marker spec json
> file.

Yes. (Furthermore what the default template is can be associated with
a pattern, like **/foo/*.java is generated with `foo.ftl`, others with
`default.ftl`.)

> Regards,
>
> Woonsan
>

-- 
Thanks,
 Daniel Dekany

Reply via email to