You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@freemarker.apache.org by Ben Jackson <ph...@gmail.com> on 2018/08/14 16:08:21 UTC
Freemarker Maven Plugin
Hello,
My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
internal Oath (e.g. Yahoo/AOL) project that we are intending to open
source. This project is an Immutable Offheap Cache which is used to store
and access data off-heap for high-performance java server applications.
As a part of our offering, we provide out of the box primitive collections
classes that mirror FastUtils, and we are using Freemarker to generate
source files needed to implement those primitive collections.
Mark built a Maven plugin for Freemarker that we use as a part of our build
process. We built this because the Freemarker project does not provide one
natively and other plugins we found do not offer the power level we needed
(we generate sources from multiple templates during both build and test
phases of the pipeline).
When working with our internal open sourcing team, they suggested that we
first reach out to you to gauge interest in hosting this plugin as a part
of the Freemarker project. This made sense to us as well.
Please let us know if it makes sense to contribute this as a part of
Freemarker. We can support it as needed.
Below the is the existing project README.md:
freemarker-maven-plugin Background
This plugin is used to generate files using FreeMarker template files and
JSON data files.
FreeMarker Template Files
FreeMarker template files must reside in the template sub-directory under
the sourceDirectory. For the default configuration, this is:
src/main/freemarker/template.
By convention, file names for FreeMarker template files use the .ftl
extension. For details on the FreeMarker template syntax, see: Getting
Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
Template Language Reference <https://freemarker.apache.org/docs/ref.html>.
JSON Data Files
The JSON data files must reside in the data sub-directory under
sourceDirectory. For the default configuration, this is:
src/main/freemarker/data.
For each JSON data file, freemarker-maven-plugin will generate a file under
the outputDirectory. The name of the generated file will be based on the
name of the JSON data file. For example, the following JSON file:
<sourceDirectory>/data/my/package/MyClass.java.json
will result in the following file being generated:
<outputDirectory>/my/package/MyClass.java
This plugin parses the JSON data file into a Map<String, Object> instance
(hereafter, referred
to as the data map). The parser allows for comments. After parsing the
file, the plugin will add
a pomProperties entry into the data map, which is itself a map containing
the properties defined in the pom. Thus, your template can reference the
pom property my_property using
${pomProperties.my_property}. If you have a period or dash in the property
name, use
${pomProperties["my.property"]}.
This plugin requires one top-level field in the JSON data file: templateName.
This field
is used to locate the template file under <sourceDirectory>/template that
is used to generate
the file. This plugin provides the data map to FreeMarker as the data model
to process the template identified by templateName.
This plugin currently assumes that the JSON data file encoded using UTF-8.
Example JSON data file:
{
// An end-of-line comment.
# Another end-of-line comment
"templateName": "my-template.ftl",
/* A multi-line
comment */
"myString": "a string",
"myNumber": 1,
"myListOfStrings": ["s1", "s2"],
"myListOfNumbers": [1, 2],
"myMap": {
"key1": "value1",
"key2": 2
}
}
Installation pom.xml
Add the following snippet within the <plugins> tag of your pom.xml:
<plugin>
<groupId>com.oath</groupId>
<artifactId>freemarker-maven-plugin</artifactId>
<version>${freemarker-maven-plugin.version}</version>
<configuration>
<!-- Required. Specifies the compatibility version for
template processing -->
<freeMarkerVersion>2.3.23</freeMarkerVersion>
</configuration>
<executions>
<!-- If you want to generate files during other phases, just
add more execution
tags and specify appropriate phase, sourceDirectory and
outputDirectory values.
-->
<execution>
<id>freemarker</id>
<!-- Optional, defaults to generate-sources -->
<phase>generate-sources</phase>
<goals>
<!-- Required, must be generate -->
<goal>generate</goal>
</goals>
<configuration>
<!-- Optional, defaults to src/main/freemarker -->
<sourceDirectory>src/main/freemarker</sourceDirectory>
<!-- Optional, defaults to target/generated-sources/freemarker -->
<outputDirectory>target/generated-sources/freemarker</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Usage FreeMarker Configuration
Typically, users of this plugin do not need to mess with the FreeMarker
configuration. This plugin explicitly sets two FreeMarker configurations:
1. the default encoding is set to UTF-8
2. the template loader is set to be a FileTemplateLoader that reads from
<sourceDirectory>/template.
If you need to override these configs or set your own, you can put them in a
<sourceDirectory>/freemarker.properties file. If that file exists, this
plugin will read it into
a java Properties instance and pass it to
freemarker.core.Configurable.setSettings() to establish
the FreeMarker configuration. See this javadoc
<https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
for configuration details.
Code Coverage
By default the code coverage report is not generated. You can generate code
coverage on your dev machine with the following maven command:
mvn clean initialize -Dclover-phase=initialize
Bring up the coverage report by pointing your browser to
target/site/clover/dashboard.html
under the root directory of the local repository.
Contribute
See Contributing.md
License
Licenced under the Apache 2.0 license. See: LICENSE.txt
—
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Dékány Dániel <dd...@freemail.hu>.
Ben Jackson <ph...@gmail.com> írta:
>Hi, Dan and Woonsan
>
>Thanks for all of the feedback.
>
>1. Yes, the current design is one output source file per json data file.
>2. We would intend to use the open source version and update as needed.
>3. We don't anticipate any significant development to meet our needs. As
>you said, this is a fairly simple concept. I could imagine some other use
>case that would need some tweaks. We would be able to support the plugin as
>needed.
Participating in decisions, in case someone here wants to change things, would be important. I mean, in your own interest, because some changes might not good for your use case. In general, people who invest more into a project has more weight in such discussions.
>My questions / assumptions.
>
>1. I assume we would host this as a separate repository under the
>apache project, say apache/freemarker-maven-plugn. Is this right?
Yes. (At least in the 2.x branch that's the policy. But for now we only do this there anyway.)
>2. I assume the plugin would follow an independent release cycle...would
>you manage the publication throug the existing freemarker project
>credentials?
Yes, it would have an independent release cycle, and same credentials.
>3. Would you want us to use some specific CI/CD process for the project?
>If so, is it documented somewhere?
It isn't documented, but a Travis CI build would be good. Also a coverage report icon, for that mater.
>4. I assume we would need to update the Freemarker website with
>documentation;
The documentation of this tool wouldn't be part of the FreeMarker Manual (https://freemarker.apache.org/docs/). But I would create something like https://freemarker.apache.org/maven-plugin/index.html to hold the documentation and such. It should use use DocBook format and Docgen, as the "freemarker" and "freemarker-site" projects do it. (See also in freemarker-docgen.) The generated documentation is then just manually uploaded into that directory. Well, I guess that part (Docgen and all) is somewhat scary, but I can make the initial version.
>I will have Mark and Myself sign CLAs through our open source team to
>contribute to Freemarker; I will tweak the packaging and copyright to
>something appropriate, and we can then share the source with you. I will
>also review the recommended properties at https://freemarker.apache.org/
>docs/pgui_quickstart_createconfiguration.html.
>
>
>-Ben
>
>
>
>
>
>
>
>On Wed, Aug 15, 2018 at 1:42 PM, Daniel Dekany <dd...@apache.org> wrote:
>
>> It's quite focused on the specific use case, but I guess many use
>> cases where FreeMarker is involved with Maven is similar. (Or not... I
>> don't have the data to tell honestly.) Anyway, as an internal project
>> it's expected to be specialized on one case. Things can be
>> generalized/extended further after contribution. (Then of course
>> question is if the existing solution is solid enough so that it worths
>> building upon it, or it will be refactored beyond recognition. But
>> this we can try to guess if we see the source code.)
>>
>> Another important question is if what are the plans of your company
>> with this plugin. Let's say this comes to Apache. After that, do you
>> plan to use the Apache version of the plugin, contributing to it when
>> you need some improvement? Is such a thing expected at all, or you
>> don't expect that you will develop the plugin further? Any of you is
>> interested to improve it regardless, in your free time?
>>
>> A note regarding the the default FreeMarker configuration... I would
>> recommend setting a few more things according to
>> https://freemarker.apache.org/docs/pgui_quickstart_
>> createconfiguration.html.
>>
>>
>> Tuesday, August 14, 2018, 6:08:21 PM, Ben Jackson wrote:
>>
>> > Hello,
>> >
>> > My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
>> > internal Oath (e.g. Yahoo/AOL) project that we are intending to open
>> > source. This project is an Immutable Offheap Cache which is used to store
>> > and access data off-heap for high-performance java server applications.
>> >
>> > As a part of our offering, we provide out of the box primitive
>> collections
>> > classes that mirror FastUtils, and we are using Freemarker to generate
>> > source files needed to implement those primitive collections.
>> >
>> > Mark built a Maven plugin for Freemarker that we use as a part of our
>> build
>> > process. We built this because the Freemarker project does not provide
>> one
>> > natively and other plugins we found do not offer the power level we
>> needed
>> > (we generate sources from multiple templates during both build and test
>> > phases of the pipeline).
>> >
>> > When working with our internal open sourcing team, they suggested that we
>> > first reach out to you to gauge interest in hosting this plugin as a part
>> > of the Freemarker project. This made sense to us as well.
>> >
>> > Please let us know if it makes sense to contribute this as a part of
>> > Freemarker. We can support it as needed.
>> >
>> > Below the is the existing project README.md:
>> > freemarker-maven-plugin Background
>> >
>> > This plugin is used to generate files using FreeMarker template files and
>> > JSON data files.
>> > FreeMarker Template Files
>> >
>> > FreeMarker template files must reside in the template sub-directory under
>> > the sourceDirectory. For the default configuration, this is:
>> > src/main/freemarker/template.
>> >
>> > By convention, file names for FreeMarker template files use the .ftl
>> > extension. For details on the FreeMarker template syntax, see: Getting
>> > Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
>> > Template Language Reference
>> > <https://freemarker.apache.org/docs/ref.html>.
>> > JSON Data Files
>> >
>> > The JSON data files must reside in the data sub-directory under
>> > sourceDirectory. For the default configuration, this is:
>> > src/main/freemarker/data.
>> >
>> > For each JSON data file, freemarker-maven-plugin will generate a file
>> under
>> > the outputDirectory. The name of the generated file will be based on the
>> > name of the JSON data file. For example, the following JSON file:
>> >
>> > <sourceDirectory>/data/my/package/MyClass.java.json
>> >
>> > will result in the following file being generated:
>> >
>> > <outputDirectory>/my/package/MyClass.java
>> >
>> > This plugin parses the JSON data file into a Map<String, Object> instance
>> > (hereafter, referred
>> > to as the data map). The parser allows for comments. After parsing the
>> > file, the plugin will add
>> > a pomProperties entry into the data map, which is itself a map containing
>> > the properties defined in the pom. Thus, your template can reference the
>> > pom property my_property using
>> > ${pomProperties.my_property}. If you have a period or dash in the
>> property
>> > name, use
>> > ${pomProperties["my.property"]}.
>> >
>> > This plugin requires one top-level field in the JSON data file:
>> templateName.
>> > This field
>> > is used to locate the template file under <sourceDirectory>/template that
>> > is used to generate
>> > the file. This plugin provides the data map to FreeMarker as the data
>> model
>> > to process the template identified by templateName.
>> >
>> > This plugin currently assumes that the JSON data file encoded using
>> UTF-8.
>> >
>> > Example JSON data file:
>> >
>> > {
>> > // An end-of-line comment.
>> > # Another end-of-line comment
>> > "templateName": "my-template.ftl",
>> > /* A multi-line
>> > comment */
>> > "myString": "a string",
>> > "myNumber": 1,
>> > "myListOfStrings": ["s1", "s2"],
>> > "myListOfNumbers": [1, 2],
>> > "myMap": {
>> > "key1": "value1",
>> > "key2": 2
>> > }
>> > }
>> >
>> > Installation pom.xml
>> >
>> > Add the following snippet within the <plugins> tag of your pom.xml:
>> >
>> > <plugin>
>> > <groupId>com.oath</groupId>
>> > <artifactId>freemarker-maven-plugin</artifactId>
>> > <version>${freemarker-maven-plugin.version}</version>
>> > <configuration>
>> > <!-- Required. Specifies the compatibility version for
>> > template processing -->
>> > <freeMarkerVersion>2.3.23</freeMarkerVersion>
>> > </configuration>
>> > <executions>
>> > <!-- If you want to generate files during other phases, just
>> > add more execution
>> > tags and specify appropriate phase, sourceDirectory and
>> > outputDirectory values.
>> > -->
>> > <execution>
>> > <id>freemarker</id>
>> > <!-- Optional, defaults to generate-sources -->
>> > <phase>generate-sources</phase>
>> > <goals>
>> > <!-- Required, must be generate -->
>> > <goal>generate</goal>
>> > </goals>
>> > <configuration>
>> > <!-- Optional, defaults to src/main/freemarker -->
>> > <sourceDirectory>src/main/freemarker</sourceDirectory>
>> > <!-- Optional, defaults to
>> > target/generated-sources/freemarker -->
>> >
>> > <outputDirectory>target/generated-sources/freemarker</outputDirectory>
>> > </configuration>
>> > </execution>
>> > </executions>
>> > </plugin>
>> >
>> > Usage FreeMarker Configuration
>> >
>> > Typically, users of this plugin do not need to mess with the FreeMarker
>> > configuration. This plugin explicitly sets two FreeMarker configurations:
>> >
>> > 1. the default encoding is set to UTF-8
>> > 2. the template loader is set to be a FileTemplateLoader that reads
>> from
>> > <sourceDirectory>/template.
>> >
>> > If you need to override these configs or set your own, you can put them
>> in a
>> > <sourceDirectory>/freemarker.properties file. If that file exists, this
>> > plugin will read it into
>> > a java Properties instance and pass it to
>> > freemarker.core.Configurable.setSettings() to establish
>> > the FreeMarker configuration. See this javadoc
>> > <https://freemarker.apache.org/docs/api/freemarker/
>> template/Configuration.html#setSetting-java.lang.String-java.lang.String->
>> > for configuration details.
>> > Code Coverage
>> >
>> > By default the code coverage report is not generated. You can generate
>> code
>> > coverage on your dev machine with the following maven command:
>> >
>> > mvn clean initialize -Dclover-phase=initialize
>> >
>> > Bring up the coverage report by pointing your browser to
>> > target/site/clover/dashboard.html
>> > under the root directory of the local repository.
>> > Contribute
>> >
>> > See Contributing.md
>> > License
>> >
>> > Licenced under the Apache 2.0 license. See: LICENSE.txt
>> >
>> > —
>> > Benjamin Grant Jackson
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>>
>
>
>--
>Benjamin Grant Jackson
>
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
Hi, Dan and Woonsan
Thanks for all of the feedback.
1. Yes, the current design is one output source file per json data file.
2. We would intend to use the open source version and update as needed.
3. We don't anticipate any significant development to meet our needs. As
you said, this is a fairly simple concept. I could imagine some other use
case that would need some tweaks. We would be able to support the plugin as
needed.
My questions / assumptions.
1. I assume we would host this as a separate repository under the
apache project, say apache/freemarker-maven-plugn. Is this right?
2. I assume the plugin would follow an independent release cycle...would
you manage the publication throug the existing freemarker project
credentials?
3. Would you want us to use some specific CI/CD process for the project?
If so, is it documented somewhere?
4. I assume we would need to update the Freemarker website with
documentation;
I will have Mark and Myself sign CLAs through our open source team to
contribute to Freemarker; I will tweak the packaging and copyright to
something appropriate, and we can then share the source with you. I will
also review the recommended properties at https://freemarker.apache.org/
docs/pgui_quickstart_createconfiguration.html.
-Ben
On Wed, Aug 15, 2018 at 1:42 PM, Daniel Dekany <dd...@apache.org> wrote:
> It's quite focused on the specific use case, but I guess many use
> cases where FreeMarker is involved with Maven is similar. (Or not... I
> don't have the data to tell honestly.) Anyway, as an internal project
> it's expected to be specialized on one case. Things can be
> generalized/extended further after contribution. (Then of course
> question is if the existing solution is solid enough so that it worths
> building upon it, or it will be refactored beyond recognition. But
> this we can try to guess if we see the source code.)
>
> Another important question is if what are the plans of your company
> with this plugin. Let's say this comes to Apache. After that, do you
> plan to use the Apache version of the plugin, contributing to it when
> you need some improvement? Is such a thing expected at all, or you
> don't expect that you will develop the plugin further? Any of you is
> interested to improve it regardless, in your free time?
>
> A note regarding the the default FreeMarker configuration... I would
> recommend setting a few more things according to
> https://freemarker.apache.org/docs/pgui_quickstart_
> createconfiguration.html.
>
>
> Tuesday, August 14, 2018, 6:08:21 PM, Ben Jackson wrote:
>
> > Hello,
> >
> > My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
> > internal Oath (e.g. Yahoo/AOL) project that we are intending to open
> > source. This project is an Immutable Offheap Cache which is used to store
> > and access data off-heap for high-performance java server applications.
> >
> > As a part of our offering, we provide out of the box primitive
> collections
> > classes that mirror FastUtils, and we are using Freemarker to generate
> > source files needed to implement those primitive collections.
> >
> > Mark built a Maven plugin for Freemarker that we use as a part of our
> build
> > process. We built this because the Freemarker project does not provide
> one
> > natively and other plugins we found do not offer the power level we
> needed
> > (we generate sources from multiple templates during both build and test
> > phases of the pipeline).
> >
> > When working with our internal open sourcing team, they suggested that we
> > first reach out to you to gauge interest in hosting this plugin as a part
> > of the Freemarker project. This made sense to us as well.
> >
> > Please let us know if it makes sense to contribute this as a part of
> > Freemarker. We can support it as needed.
> >
> > Below the is the existing project README.md:
> > freemarker-maven-plugin Background
> >
> > This plugin is used to generate files using FreeMarker template files and
> > JSON data files.
> > FreeMarker Template Files
> >
> > FreeMarker template files must reside in the template sub-directory under
> > the sourceDirectory. For the default configuration, this is:
> > src/main/freemarker/template.
> >
> > By convention, file names for FreeMarker template files use the .ftl
> > extension. For details on the FreeMarker template syntax, see: Getting
> > Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
> > Template Language Reference
> > <https://freemarker.apache.org/docs/ref.html>.
> > JSON Data Files
> >
> > The JSON data files must reside in the data sub-directory under
> > sourceDirectory. For the default configuration, this is:
> > src/main/freemarker/data.
> >
> > For each JSON data file, freemarker-maven-plugin will generate a file
> under
> > the outputDirectory. The name of the generated file will be based on the
> > name of the JSON data file. For example, the following JSON file:
> >
> > <sourceDirectory>/data/my/package/MyClass.java.json
> >
> > will result in the following file being generated:
> >
> > <outputDirectory>/my/package/MyClass.java
> >
> > This plugin parses the JSON data file into a Map<String, Object> instance
> > (hereafter, referred
> > to as the data map). The parser allows for comments. After parsing the
> > file, the plugin will add
> > a pomProperties entry into the data map, which is itself a map containing
> > the properties defined in the pom. Thus, your template can reference the
> > pom property my_property using
> > ${pomProperties.my_property}. If you have a period or dash in the
> property
> > name, use
> > ${pomProperties["my.property"]}.
> >
> > This plugin requires one top-level field in the JSON data file:
> templateName.
> > This field
> > is used to locate the template file under <sourceDirectory>/template that
> > is used to generate
> > the file. This plugin provides the data map to FreeMarker as the data
> model
> > to process the template identified by templateName.
> >
> > This plugin currently assumes that the JSON data file encoded using
> UTF-8.
> >
> > Example JSON data file:
> >
> > {
> > // An end-of-line comment.
> > # Another end-of-line comment
> > "templateName": "my-template.ftl",
> > /* A multi-line
> > comment */
> > "myString": "a string",
> > "myNumber": 1,
> > "myListOfStrings": ["s1", "s2"],
> > "myListOfNumbers": [1, 2],
> > "myMap": {
> > "key1": "value1",
> > "key2": 2
> > }
> > }
> >
> > Installation pom.xml
> >
> > Add the following snippet within the <plugins> tag of your pom.xml:
> >
> > <plugin>
> > <groupId>com.oath</groupId>
> > <artifactId>freemarker-maven-plugin</artifactId>
> > <version>${freemarker-maven-plugin.version}</version>
> > <configuration>
> > <!-- Required. Specifies the compatibility version for
> > template processing -->
> > <freeMarkerVersion>2.3.23</freeMarkerVersion>
> > </configuration>
> > <executions>
> > <!-- If you want to generate files during other phases, just
> > add more execution
> > tags and specify appropriate phase, sourceDirectory and
> > outputDirectory values.
> > -->
> > <execution>
> > <id>freemarker</id>
> > <!-- Optional, defaults to generate-sources -->
> > <phase>generate-sources</phase>
> > <goals>
> > <!-- Required, must be generate -->
> > <goal>generate</goal>
> > </goals>
> > <configuration>
> > <!-- Optional, defaults to src/main/freemarker -->
> > <sourceDirectory>src/main/freemarker</sourceDirectory>
> > <!-- Optional, defaults to
> > target/generated-sources/freemarker -->
> >
> > <outputDirectory>target/generated-sources/freemarker</outputDirectory>
> > </configuration>
> > </execution>
> > </executions>
> > </plugin>
> >
> > Usage FreeMarker Configuration
> >
> > Typically, users of this plugin do not need to mess with the FreeMarker
> > configuration. This plugin explicitly sets two FreeMarker configurations:
> >
> > 1. the default encoding is set to UTF-8
> > 2. the template loader is set to be a FileTemplateLoader that reads
> from
> > <sourceDirectory>/template.
> >
> > If you need to override these configs or set your own, you can put them
> in a
> > <sourceDirectory>/freemarker.properties file. If that file exists, this
> > plugin will read it into
> > a java Properties instance and pass it to
> > freemarker.core.Configurable.setSettings() to establish
> > the FreeMarker configuration. See this javadoc
> > <https://freemarker.apache.org/docs/api/freemarker/
> template/Configuration.html#setSetting-java.lang.String-java.lang.String->
> > for configuration details.
> > Code Coverage
> >
> > By default the code coverage report is not generated. You can generate
> code
> > coverage on your dev machine with the following maven command:
> >
> > mvn clean initialize -Dclover-phase=initialize
> >
> > Bring up the coverage report by pointing your browser to
> > target/site/clover/dashboard.html
> > under the root directory of the local repository.
> > Contribute
> >
> > See Contributing.md
> > License
> >
> > Licenced under the Apache 2.0 license. See: LICENSE.txt
> >
> > —
> > Benjamin Grant Jackson
>
> --
> Thanks,
> Daniel Dekany
>
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
It's quite focused on the specific use case, but I guess many use
cases where FreeMarker is involved with Maven is similar. (Or not... I
don't have the data to tell honestly.) Anyway, as an internal project
it's expected to be specialized on one case. Things can be
generalized/extended further after contribution. (Then of course
question is if the existing solution is solid enough so that it worths
building upon it, or it will be refactored beyond recognition. But
this we can try to guess if we see the source code.)
Another important question is if what are the plans of your company
with this plugin. Let's say this comes to Apache. After that, do you
plan to use the Apache version of the plugin, contributing to it when
you need some improvement? Is such a thing expected at all, or you
don't expect that you will develop the plugin further? Any of you is
interested to improve it regardless, in your free time?
A note regarding the the default FreeMarker configuration... I would
recommend setting a few more things according to
https://freemarker.apache.org/docs/pgui_quickstart_createconfiguration.html.
Tuesday, August 14, 2018, 6:08:21 PM, Ben Jackson wrote:
> Hello,
>
> My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
> internal Oath (e.g. Yahoo/AOL) project that we are intending to open
> source. This project is an Immutable Offheap Cache which is used to store
> and access data off-heap for high-performance java server applications.
>
> As a part of our offering, we provide out of the box primitive collections
> classes that mirror FastUtils, and we are using Freemarker to generate
> source files needed to implement those primitive collections.
>
> Mark built a Maven plugin for Freemarker that we use as a part of our build
> process. We built this because the Freemarker project does not provide one
> natively and other plugins we found do not offer the power level we needed
> (we generate sources from multiple templates during both build and test
> phases of the pipeline).
>
> When working with our internal open sourcing team, they suggested that we
> first reach out to you to gauge interest in hosting this plugin as a part
> of the Freemarker project. This made sense to us as well.
>
> Please let us know if it makes sense to contribute this as a part of
> Freemarker. We can support it as needed.
>
> Below the is the existing project README.md:
> freemarker-maven-plugin Background
>
> This plugin is used to generate files using FreeMarker template files and
> JSON data files.
> FreeMarker Template Files
>
> FreeMarker template files must reside in the template sub-directory under
> the sourceDirectory. For the default configuration, this is:
> src/main/freemarker/template.
>
> By convention, file names for FreeMarker template files use the .ftl
> extension. For details on the FreeMarker template syntax, see: Getting
> Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
> Template Language Reference
> <https://freemarker.apache.org/docs/ref.html>.
> JSON Data Files
>
> The JSON data files must reside in the data sub-directory under
> sourceDirectory. For the default configuration, this is:
> src/main/freemarker/data.
>
> For each JSON data file, freemarker-maven-plugin will generate a file under
> the outputDirectory. The name of the generated file will be based on the
> name of the JSON data file. For example, the following JSON file:
>
> <sourceDirectory>/data/my/package/MyClass.java.json
>
> will result in the following file being generated:
>
> <outputDirectory>/my/package/MyClass.java
>
> This plugin parses the JSON data file into a Map<String, Object> instance
> (hereafter, referred
> to as the data map). The parser allows for comments. After parsing the
> file, the plugin will add
> a pomProperties entry into the data map, which is itself a map containing
> the properties defined in the pom. Thus, your template can reference the
> pom property my_property using
> ${pomProperties.my_property}. If you have a period or dash in the property
> name, use
> ${pomProperties["my.property"]}.
>
> This plugin requires one top-level field in the JSON data file: templateName.
> This field
> is used to locate the template file under <sourceDirectory>/template that
> is used to generate
> the file. This plugin provides the data map to FreeMarker as the data model
> to process the template identified by templateName.
>
> This plugin currently assumes that the JSON data file encoded using UTF-8.
>
> Example JSON data file:
>
> {
> // An end-of-line comment.
> # Another end-of-line comment
> "templateName": "my-template.ftl",
> /* A multi-line
> comment */
> "myString": "a string",
> "myNumber": 1,
> "myListOfStrings": ["s1", "s2"],
> "myListOfNumbers": [1, 2],
> "myMap": {
> "key1": "value1",
> "key2": 2
> }
> }
>
> Installation pom.xml
>
> Add the following snippet within the <plugins> tag of your pom.xml:
>
> <plugin>
> <groupId>com.oath</groupId>
> <artifactId>freemarker-maven-plugin</artifactId>
> <version>${freemarker-maven-plugin.version}</version>
> <configuration>
> <!-- Required. Specifies the compatibility version for
> template processing -->
> <freeMarkerVersion>2.3.23</freeMarkerVersion>
> </configuration>
> <executions>
> <!-- If you want to generate files during other phases, just
> add more execution
> tags and specify appropriate phase, sourceDirectory and
> outputDirectory values.
> -->
> <execution>
> <id>freemarker</id>
> <!-- Optional, defaults to generate-sources -->
> <phase>generate-sources</phase>
> <goals>
> <!-- Required, must be generate -->
> <goal>generate</goal>
> </goals>
> <configuration>
> <!-- Optional, defaults to src/main/freemarker -->
> <sourceDirectory>src/main/freemarker</sourceDirectory>
> <!-- Optional, defaults to
> target/generated-sources/freemarker -->
>
> <outputDirectory>target/generated-sources/freemarker</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> Usage FreeMarker Configuration
>
> Typically, users of this plugin do not need to mess with the FreeMarker
> configuration. This plugin explicitly sets two FreeMarker configurations:
>
> 1. the default encoding is set to UTF-8
> 2. the template loader is set to be a FileTemplateLoader that reads from
> <sourceDirectory>/template.
>
> If you need to override these configs or set your own, you can put them in a
> <sourceDirectory>/freemarker.properties file. If that file exists, this
> plugin will read it into
> a java Properties instance and pass it to
> freemarker.core.Configurable.setSettings() to establish
> the FreeMarker configuration. See this javadoc
> <https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
> for configuration details.
> Code Coverage
>
> By default the code coverage report is not generated. You can generate code
> coverage on your dev machine with the following maven command:
>
> mvn clean initialize -Dclover-phase=initialize
>
> Bring up the coverage report by pointing your browser to
> target/site/clover/dashboard.html
> under the root directory of the local repository.
> Contribute
>
> See Contributing.md
> License
>
> Licenced under the Apache 2.0 license. See: LICENSE.txt
>
> —
> Benjamin Grant Jackson
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Thursday, August 16, 2018, 1:19:55 PM, Dékány Dániel wrote:
[snip]
> 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.
[snip]
Continuing my above thought... I think we could have 2 kind of source
sub-directories:
- "generators" (instead of "data"):
So these are currently the <outoutFileName>.json files. Each file in
the generator subdirectory generates an output file with similar
name (after removing the last file extensions). Why not "data"?
Because my idea is that we should allow FreeMarker templates here as
well. Those aren't templates that a json file can refer to, but a
template that will generate an output file itself. Kind of like it
does in FMPP (see figures on
http://fmpp.sourceforge.net/qtour.html). BTW, if there's a need, of
course we can add support xml files there as well (which is then
processed similarly to a json, but the data-model is created by the
usual FreeMarker XML wrapper).
- "templates":
Like in the current version. Used by the generator files. How the
output generator refers to them depends on the output generator
format (currently the only one format is a JSON object with the
reserved "templateName" key).
We can further extend this with allowing the definition of a global
data-model that's accessible for all output generators, as Woosan
said. If we support templates as "generators", that's essential.
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
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 <dd...@freemail.hu> wrote:
>> Woonsan Ko <wo...@apache.org> í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
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Thu, Aug 16, 2018 at 7:19 AM, Dékány Dániel <dd...@freemail.hu> wrote:
> Woonsan Ko <wo...@apache.org> í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.
>
> 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. 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.
Regards,
Woonsan
Re: Freemarker Maven Plugin
Posted by Dékány Dániel <dd...@freemail.hu>.
Woonsan Ko <wo...@apache.org> í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.
So, I guess that the containing directory decides the purpose of the file is find.
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.
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.
>(Just trying to find a more intuitive and conventional project
>structure here...)
>
>The "spec" json file can possibly split metadata such as "template"
>from the 'model':
>
>{
> "template": "/com/example/templates/generic-code-gen-template.ftl",
>// possibly a relative path as well?
> "model": {
> "myString": "a string",
> "myNumber": 1,
> "myListOfStrings": ["s1", "s2"],
> "myListOfNumbers": [1, 2],
> "myMap": {
> "key1": "value1",
> "key2": 2
> }
> }
>}
>
>Perhaps the maven plugin module could be shipped with a versioned JSON
>schema file to avoid any confusions or support any other potential
>tooling, too.
>
>Regards,
>
>Woonsan
>
>On Wed, Aug 15, 2018 at 4:52 PM, Mark Malynn <ma...@gmail.com> wrote:
>> Hi Woonsan,
>>
>> Before writing our freemarker-maven-plugin, I looked for a maven templating
>> plugin that would meet our needs and could not find one. The basic
>> limitation of those existing plugins is that I could only generate one
>> source file per template file. I needed to be able to generate multiple
>> source files per template file.
>>
>> With regards to your inline comments:
>>
>> 1) I separated template and data directories because it was easier to code
>> and I happen to like that organization better. I'd be willing to add support
>> for just one directory that contains both templates and data models (and I'd
>> be willing to have that be the default configuration).
>>
>> 2) Using a naming convention to identify the template (from the name of the
>> json file) prevents my main use case (to generate multiple class source
>> files using the same template).
>>
>> 3) I agree that using the well known json field 'templateName' seems
>> 'hacky' (from a freemarker point of view). However, from the point of view
>> of the maven plugin it works nice. It provides the flexibility I need with
>> the minimum fuss. I will entertain another mechanism as long as it supports
>> my main use case.
>>
>> -Mark
>>
>> On Wed, Aug 15, 2018 at 11:02 AM, Woonsan Ko <wo...@apache.org> wrote:
>>>
>>> Hi Benjamin,
>>>
>>> Thanks for the proposal.
>>> IIUC, it looks similar to maven-velocity-plugin [1], which generates
>>> .java files based on Velocity template files with configured
>>> parameters (models).
>>> But, the module on your end reads models from .json file in addition.
>>> Am I in correct understanding? If so, the scope should not be too big.
>>> It could be useful to many people.
>>> Please see my comments inline below as well.
>>>
>>> [1] https://github.com/nativelibs4java/maven-velocity-plugin
>>>
>>>
>>> On Tue, Aug 14, 2018 at 12:08 PM, Ben Jackson <ph...@gmail.com> wrote:
>>> > Hello,
>>> >
>>> > My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
>>> > internal Oath (e.g. Yahoo/AOL) project that we are intending to open
>>> > source. This project is an Immutable Offheap Cache which is used to
>>> > store
>>> > and access data off-heap for high-performance java server applications.
>>> >
>>> > As a part of our offering, we provide out of the box primitive
>>> > collections
>>> > classes that mirror FastUtils, and we are using Freemarker to generate
>>> > source files needed to implement those primitive collections.
>>> >
>>> > Mark built a Maven plugin for Freemarker that we use as a part of our
>>> > build
>>> > process. We built this because the Freemarker project does not provide
>>> > one
>>> > natively and other plugins we found do not offer the power level we
>>> > needed
>>> > (we generate sources from multiple templates during both build and test
>>> > phases of the pipeline).
>>> >
>>> > When working with our internal open sourcing team, they suggested that
>>> > we
>>> > first reach out to you to gauge interest in hosting this plugin as a
>>> > part
>>> > of the Freemarker project. This made sense to us as well.
>>> >
>>> > Please let us know if it makes sense to contribute this as a part of
>>> > Freemarker. We can support it as needed.
>>> >
>>> > Below the is the existing project README.md:
>>> > freemarker-maven-plugin Background
>>> >
>>> > This plugin is used to generate files using FreeMarker template files
>>> > and
>>> > JSON data files.
>>> > FreeMarker Template Files
>>> >
>>> > FreeMarker template files must reside in the template sub-directory
>>> > under
>>> > the sourceDirectory. For the default configuration, this is:
>>> > src/main/freemarker/template.
>>> Why not simply src/main/freemarker?
>>>
>>> >
>>> > By convention, file names for FreeMarker template files use the .ftl
>>> > extension. For details on the FreeMarker template syntax, see: Getting
>>> > Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
>>> > Template Language Reference
>>> > <https://freemarker.apache.org/docs/ref.html>.
>>> > JSON Data Files
>>> >
>>> > The JSON data files must reside in the data sub-directory under
>>> > sourceDirectory. For the default configuration, this is:
>>> > src/main/freemarker/data.
>>> Why not simply with a different extension? e.g,
>>> src/main/freemarker/com/example/MyClass.ftl.data.json for
>>> src/main/freemarker/com/example/MyClass.ftl.
>>>
>>> >
>>> > For each JSON data file, freemarker-maven-plugin will generate a file
>>> > under
>>> > the outputDirectory. The name of the generated file will be based on the
>>> > name of the JSON data file. For example, the following JSON file:
>>> >
>>> > <sourceDirectory>/data/my/package/MyClass.java.json
>>> >
>>> > will result in the following file being generated:
>>> >
>>> > <outputDirectory>/my/package/MyClass.java
>>> >
>>> > This plugin parses the JSON data file into a Map<String, Object>
>>> > instance
>>> > (hereafter, referred
>>> > to as the data map). The parser allows for comments. After parsing the
>>> > file, the plugin will add
>>> > a pomProperties entry into the data map, which is itself a map
>>> > containing
>>> > the properties defined in the pom. Thus, your template can reference the
>>> > pom property my_property using
>>> > ${pomProperties.my_property}. If you have a period or dash in the
>>> > property
>>> > name, use
>>> > ${pomProperties["my.property"]}.
>>> >
>>> > This plugin requires one top-level field in the JSON data file:
>>> > templateName.
>>> > This field
>>> > is used to locate the template file under <sourceDirectory>/template
>>> > that
>>> > is used to generate
>>> > the file. This plugin provides the data map to FreeMarker as the data
>>> > model
>>> > to process the template identified by templateName.
>>> >
>>> > This plugin currently assumes that the JSON data file encoded using
>>> > UTF-8.
>>> >
>>> > Example JSON data file:
>>> >
>>> > {
>>> > // An end-of-line comment.
>>> > # Another end-of-line comment
>>> > "templateName": "my-template.ftl",
>>> > /* A multi-line
>>> > comment */
>>> > "myString": "a string",
>>> > "myNumber": 1,
>>> > "myListOfStrings": ["s1", "s2"],
>>> > "myListOfNumbers": [1, 2],
>>> > "myMap": {
>>> > "key1": "value1",
>>> > "key2": 2
>>> > }
>>> > }
>>> Isn't the json file intended for model provision to the FreeMarker
>>> template?
>>> If so, it doesn't look good to me to have "templateName" in the model
>>> json file. Convention might be better as mentioned above.
>>>
>>> Regards,
>>>
>>> Woonsan
>>>
>>> >
>>> > Installation pom.xml
>>> >
>>> > Add the following snippet within the <plugins> tag of your pom.xml:
>>> >
>>> > <plugin>
>>> > <groupId>com.oath</groupId>
>>> > <artifactId>freemarker-maven-plugin</artifactId>
>>> > <version>${freemarker-maven-plugin.version}</version>
>>> > <configuration>
>>> > <!-- Required. Specifies the compatibility version for
>>> > template processing -->
>>> > <freeMarkerVersion>2.3.23</freeMarkerVersion>
>>> > </configuration>
>>> > <executions>
>>> > <!-- If you want to generate files during other phases, just
>>> > add more execution
>>> > tags and specify appropriate phase, sourceDirectory and
>>> > outputDirectory values.
>>> > -->
>>> > <execution>
>>> > <id>freemarker</id>
>>> > <!-- Optional, defaults to generate-sources -->
>>> > <phase>generate-sources</phase>
>>> > <goals>
>>> > <!-- Required, must be generate -->
>>> > <goal>generate</goal>
>>> > </goals>
>>> > <configuration>
>>> > <!-- Optional, defaults to src/main/freemarker -->
>>> > <sourceDirectory>src/main/freemarker</sourceDirectory>
>>> > <!-- Optional, defaults to
>>> > target/generated-sources/freemarker -->
>>> >
>>> > <outputDirectory>target/generated-sources/freemarker</outputDirectory>
>>> > </configuration>
>>> > </execution>
>>> > </executions>
>>> > </plugin>
>>> >
>>> > Usage FreeMarker Configuration
>>> >
>>> > Typically, users of this plugin do not need to mess with the FreeMarker
>>> > configuration. This plugin explicitly sets two FreeMarker
>>> > configurations:
>>> >
>>> > 1. the default encoding is set to UTF-8
>>> > 2. the template loader is set to be a FileTemplateLoader that reads
>>> > from
>>> > <sourceDirectory>/template.
>>> >
>>> > If you need to override these configs or set your own, you can put them
>>> > in a
>>> > <sourceDirectory>/freemarker.properties file. If that file exists, this
>>> > plugin will read it into
>>> > a java Properties instance and pass it to
>>> > freemarker.core.Configurable.setSettings() to establish
>>> > the FreeMarker configuration. See this javadoc
>>> >
>>> > <https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
>>> > for configuration details.
>>> > Code Coverage
>>> >
>>> > By default the code coverage report is not generated. You can generate
>>> > code
>>> > coverage on your dev machine with the following maven command:
>>> >
>>> > mvn clean initialize -Dclover-phase=initialize
>>> >
>>> > Bring up the coverage report by pointing your browser to
>>> > target/site/clover/dashboard.html
>>> > under the root directory of the local repository.
>>> > Contribute
>>> >
>>> > See Contributing.md
>>> > License
>>> >
>>> > Licenced under the Apache 2.0 license. See: LICENSE.txt
>>> >
>>> > —
>>> > Benjamin Grant Jackson
>>
>>
>
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
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.
(Just trying to find a more intuitive and conventional project
structure here...)
The "spec" json file can possibly split metadata such as "template"
from the 'model':
{
"template": "/com/example/templates/generic-code-gen-template.ftl",
// possibly a relative path as well?
"model": {
"myString": "a string",
"myNumber": 1,
"myListOfStrings": ["s1", "s2"],
"myListOfNumbers": [1, 2],
"myMap": {
"key1": "value1",
"key2": 2
}
}
}
Perhaps the maven plugin module could be shipped with a versioned JSON
schema file to avoid any confusions or support any other potential
tooling, too.
Regards,
Woonsan
On Wed, Aug 15, 2018 at 4:52 PM, Mark Malynn <ma...@gmail.com> wrote:
> Hi Woonsan,
>
> Before writing our freemarker-maven-plugin, I looked for a maven templating
> plugin that would meet our needs and could not find one. The basic
> limitation of those existing plugins is that I could only generate one
> source file per template file. I needed to be able to generate multiple
> source files per template file.
>
> With regards to your inline comments:
>
> 1) I separated template and data directories because it was easier to code
> and I happen to like that organization better. I'd be willing to add support
> for just one directory that contains both templates and data models (and I'd
> be willing to have that be the default configuration).
>
> 2) Using a naming convention to identify the template (from the name of the
> json file) prevents my main use case (to generate multiple class source
> files using the same template).
>
> 3) I agree that using the well known json field 'templateName' seems
> 'hacky' (from a freemarker point of view). However, from the point of view
> of the maven plugin it works nice. It provides the flexibility I need with
> the minimum fuss. I will entertain another mechanism as long as it supports
> my main use case.
>
> -Mark
>
> On Wed, Aug 15, 2018 at 11:02 AM, Woonsan Ko <wo...@apache.org> wrote:
>>
>> Hi Benjamin,
>>
>> Thanks for the proposal.
>> IIUC, it looks similar to maven-velocity-plugin [1], which generates
>> .java files based on Velocity template files with configured
>> parameters (models).
>> But, the module on your end reads models from .json file in addition.
>> Am I in correct understanding? If so, the scope should not be too big.
>> It could be useful to many people.
>> Please see my comments inline below as well.
>>
>> [1] https://github.com/nativelibs4java/maven-velocity-plugin
>>
>>
>> On Tue, Aug 14, 2018 at 12:08 PM, Ben Jackson <ph...@gmail.com> wrote:
>> > Hello,
>> >
>> > My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
>> > internal Oath (e.g. Yahoo/AOL) project that we are intending to open
>> > source. This project is an Immutable Offheap Cache which is used to
>> > store
>> > and access data off-heap for high-performance java server applications.
>> >
>> > As a part of our offering, we provide out of the box primitive
>> > collections
>> > classes that mirror FastUtils, and we are using Freemarker to generate
>> > source files needed to implement those primitive collections.
>> >
>> > Mark built a Maven plugin for Freemarker that we use as a part of our
>> > build
>> > process. We built this because the Freemarker project does not provide
>> > one
>> > natively and other plugins we found do not offer the power level we
>> > needed
>> > (we generate sources from multiple templates during both build and test
>> > phases of the pipeline).
>> >
>> > When working with our internal open sourcing team, they suggested that
>> > we
>> > first reach out to you to gauge interest in hosting this plugin as a
>> > part
>> > of the Freemarker project. This made sense to us as well.
>> >
>> > Please let us know if it makes sense to contribute this as a part of
>> > Freemarker. We can support it as needed.
>> >
>> > Below the is the existing project README.md:
>> > freemarker-maven-plugin Background
>> >
>> > This plugin is used to generate files using FreeMarker template files
>> > and
>> > JSON data files.
>> > FreeMarker Template Files
>> >
>> > FreeMarker template files must reside in the template sub-directory
>> > under
>> > the sourceDirectory. For the default configuration, this is:
>> > src/main/freemarker/template.
>> Why not simply src/main/freemarker?
>>
>> >
>> > By convention, file names for FreeMarker template files use the .ftl
>> > extension. For details on the FreeMarker template syntax, see: Getting
>> > Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
>> > Template Language Reference
>> > <https://freemarker.apache.org/docs/ref.html>.
>> > JSON Data Files
>> >
>> > The JSON data files must reside in the data sub-directory under
>> > sourceDirectory. For the default configuration, this is:
>> > src/main/freemarker/data.
>> Why not simply with a different extension? e.g,
>> src/main/freemarker/com/example/MyClass.ftl.data.json for
>> src/main/freemarker/com/example/MyClass.ftl.
>>
>> >
>> > For each JSON data file, freemarker-maven-plugin will generate a file
>> > under
>> > the outputDirectory. The name of the generated file will be based on the
>> > name of the JSON data file. For example, the following JSON file:
>> >
>> > <sourceDirectory>/data/my/package/MyClass.java.json
>> >
>> > will result in the following file being generated:
>> >
>> > <outputDirectory>/my/package/MyClass.java
>> >
>> > This plugin parses the JSON data file into a Map<String, Object>
>> > instance
>> > (hereafter, referred
>> > to as the data map). The parser allows for comments. After parsing the
>> > file, the plugin will add
>> > a pomProperties entry into the data map, which is itself a map
>> > containing
>> > the properties defined in the pom. Thus, your template can reference the
>> > pom property my_property using
>> > ${pomProperties.my_property}. If you have a period or dash in the
>> > property
>> > name, use
>> > ${pomProperties["my.property"]}.
>> >
>> > This plugin requires one top-level field in the JSON data file:
>> > templateName.
>> > This field
>> > is used to locate the template file under <sourceDirectory>/template
>> > that
>> > is used to generate
>> > the file. This plugin provides the data map to FreeMarker as the data
>> > model
>> > to process the template identified by templateName.
>> >
>> > This plugin currently assumes that the JSON data file encoded using
>> > UTF-8.
>> >
>> > Example JSON data file:
>> >
>> > {
>> > // An end-of-line comment.
>> > # Another end-of-line comment
>> > "templateName": "my-template.ftl",
>> > /* A multi-line
>> > comment */
>> > "myString": "a string",
>> > "myNumber": 1,
>> > "myListOfStrings": ["s1", "s2"],
>> > "myListOfNumbers": [1, 2],
>> > "myMap": {
>> > "key1": "value1",
>> > "key2": 2
>> > }
>> > }
>> Isn't the json file intended for model provision to the FreeMarker
>> template?
>> If so, it doesn't look good to me to have "templateName" in the model
>> json file. Convention might be better as mentioned above.
>>
>> Regards,
>>
>> Woonsan
>>
>> >
>> > Installation pom.xml
>> >
>> > Add the following snippet within the <plugins> tag of your pom.xml:
>> >
>> > <plugin>
>> > <groupId>com.oath</groupId>
>> > <artifactId>freemarker-maven-plugin</artifactId>
>> > <version>${freemarker-maven-plugin.version}</version>
>> > <configuration>
>> > <!-- Required. Specifies the compatibility version for
>> > template processing -->
>> > <freeMarkerVersion>2.3.23</freeMarkerVersion>
>> > </configuration>
>> > <executions>
>> > <!-- If you want to generate files during other phases, just
>> > add more execution
>> > tags and specify appropriate phase, sourceDirectory and
>> > outputDirectory values.
>> > -->
>> > <execution>
>> > <id>freemarker</id>
>> > <!-- Optional, defaults to generate-sources -->
>> > <phase>generate-sources</phase>
>> > <goals>
>> > <!-- Required, must be generate -->
>> > <goal>generate</goal>
>> > </goals>
>> > <configuration>
>> > <!-- Optional, defaults to src/main/freemarker -->
>> > <sourceDirectory>src/main/freemarker</sourceDirectory>
>> > <!-- Optional, defaults to
>> > target/generated-sources/freemarker -->
>> >
>> > <outputDirectory>target/generated-sources/freemarker</outputDirectory>
>> > </configuration>
>> > </execution>
>> > </executions>
>> > </plugin>
>> >
>> > Usage FreeMarker Configuration
>> >
>> > Typically, users of this plugin do not need to mess with the FreeMarker
>> > configuration. This plugin explicitly sets two FreeMarker
>> > configurations:
>> >
>> > 1. the default encoding is set to UTF-8
>> > 2. the template loader is set to be a FileTemplateLoader that reads
>> > from
>> > <sourceDirectory>/template.
>> >
>> > If you need to override these configs or set your own, you can put them
>> > in a
>> > <sourceDirectory>/freemarker.properties file. If that file exists, this
>> > plugin will read it into
>> > a java Properties instance and pass it to
>> > freemarker.core.Configurable.setSettings() to establish
>> > the FreeMarker configuration. See this javadoc
>> >
>> > <https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
>> > for configuration details.
>> > Code Coverage
>> >
>> > By default the code coverage report is not generated. You can generate
>> > code
>> > coverage on your dev machine with the following maven command:
>> >
>> > mvn clean initialize -Dclover-phase=initialize
>> >
>> > Bring up the coverage report by pointing your browser to
>> > target/site/clover/dashboard.html
>> > under the root directory of the local repository.
>> > Contribute
>> >
>> > See Contributing.md
>> > License
>> >
>> > Licenced under the Apache 2.0 license. See: LICENSE.txt
>> >
>> > —
>> > Benjamin Grant Jackson
>
>
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Thu, Sep 6, 2018 at 12:14 PM Ben Jackson <ph...@gmail.com> wrote:
>
> Here is the existing codebase for this project.
>
> https://github.com/yahoo/freemarker-maven-plugin
Cool!
>
> It seemed more straightforward to work through our opensource team to
> publish the code so that it could be reviewed before continuing this
> conversation. Please comment on any remediations you see as needed (if
> any) before working towards gifting this code to the apache foundation as a
> starting point for this plugin.
Will do.
>
> Also, as mentioned in the conversation above, it would be preferable if
> this plugin had a unique and easily searchable name. Does anyone have
> ideas?
> I have no good ideas; here are some uninspired options:
>
> FreeGenerator
> FMGenerator
> FMGen
> fmg
> fmgen
> FMarkerGen
> MarkerGen
> MGen
> MGenerator
FreeMarkerGenerator?
Woonsan
>
>
> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
>
> > On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
> > wrote:
> > ...snip...
> > > Without an ASF account the contributors couldn't edit the Wiki page.
> > > If *they* open a JIRA issue, then we all can edit it. So that's what I
> > > recommend.
> > Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
> > and we can edit its description together there.
> >
> > ...snip...
> > > This was my intent from the beginning. A generator file can be a
> > > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
> > > that's transformed by a templates/myxmltransformat.ftl). They are
> > > totally unrelated, independent generator files. I have never assumed
> > > that they come in pairs, hence there was never a such thing as "ftl
> > > only generator" in my head either. All generator files are lonely.
> > That's clear now. I think I made an unnecessary confusion by using
> > 'ftl-only' generator when mentioning .ftl type generator.
> > Thanks!
> >
> > Woonsan
> >
>
>
> --
> Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Ben, we have received the notice from the ASF secretary that your ICLA
has been arrived. Thus, we can accept pull requests from you now. Note
that by sending a pull request you grant the Apache Software
Foundation sufficient rights to use and release the submitted work as
its own, under the Apache license. Here's the repo:
https://github.com/apache/freemarker-generator (or for those with
commit right, alternatively:
https://gitbox.apache.org/repos/asf/freemarker-generator.git)
Thank you for work and patience!
Wednesday, September 19, 2018, 10:01:49 PM, Daniel Dekany wrote:
> Wednesday, September 19, 2018, 5:27:36 PM, Ben Jackson wrote:
>
>> According to our open source team when I talked with them last week, we
>> shouldn't need to sign the CCLA because the company has already done so
>> more generally for all Apache foundation projects. We just got the official
>> signoff to sight the ICLAs last Friday. I did send your request above to
>> that team to get their specific feedback.
>
> I didn't know you already have a CCLA. In that case you won't need to
> submit another.
>
>> I submitted my ICLA today and have asked Mark to do the same.
>
> Great!
>
>> Yes, it does make sense for Committer status.
>
> So then we will arrange that. Both you and Mark want Committer status,
> right?
>
>> We would like to get the
>> project in place, publish the first artifact and migrate the dependent.
>> project to use this open source plugin on the way to publishing it over the
>> next month.
>>
>> What would the process for publishing an artifact look like?
>
> That's a somewhat heavy process... I takes at least 4 days, but a week
> is more realistic, and it needs a FreeMarker PMC (Project Management
> Committee) member to execute it. So, you indicate on this list that a
> release should be done, then wait until a FreeMarker PMC member finds
> time to execute process, and I think that's it as far as you are
> concerned. The PMC member will build and upload the release artifacts
> for staging, and hold a voting on releasing them on this list. At
> least 3 FreeMarker PMC members have to vote positively, which might
> takes some time, and the voting will not be closed for a minimum of 72
> hours. Only then will the staged artifacts be published, on the Maven
> Central Repo, among others.
>
> We will also need some page(s) on freemarker.apache.org that contains
> the up to date documentation, including the version history. That's
> not tied to the release process though, and can be uploaded by any
> Committer.
>
>> Best,
>>
>> Ben
>>
>>
>>
>> On Tue, Sep 18, 2018 at 3:19 PM Daniel Dekany <dd...@apache.org> wrote:
>>
>>> Friday, September 7, 2018, 5:57:43 PM, Daniel Dekany wrote:
>>>
>>> > Friday, September 7, 2018, 4:54:15 PM, Ben Jackson wrote:
>>> >
>>> >> I like the name FreeMarker Generator (Maven Plugin). I think we should
>>> >> name the repo freemarker-generator, and then leave open the possibility
>>> of
>>> >> providing additional ways to drive the code generation through
>>> additional
>>> >> build tools.
>>> >
>>> > Indeed, good point. That will be a multi module Maven project, with
>>> > freemarker-generator-core and freemarker-generator-maven-plugin
>>> > submodules.
>>> >
>>> >> - Yes, I believe we can follow a simple CLA process. I will open a
>>> >> ticket today for us to sign the CLAs.
>>> >
>>> > So, both of you should sign an ICLA ("I" for Individual). It's easy;
>>> > print it, sign it, scan it, e-mail it. Then you can contribute to any
>>> > Apache projects on your free time, so it never hurts to have one.
>>> >
>>> > Then, certainly we will also need a CCLA ("C" for Corporate) for the
>>> > contribution, assuming you did this as part of your work, or if your
>>> > employer can claim that for any other reason. The signer of the CCLA
>>> > has to be someone who has right to make such a legal statement in the
>>> > name of the company. But maybe wait until some more FreeMarker PMC
>>> > members respond to this.
>>>
>>> So, the decision on our side is that we go on as planned earlier. If
>>> you agree, you should submit the CCLA (in additionally to the ICLA-s).
>>> In the CCLA, under "Initial list of designated employees", please add
>>> the names of both of you. Again, the signer (and presumably who fills
>>> the whole CCLA) is not you, but someone at Oath Inc. who has right to
>>> make such a legal statement.
>>>
>>> Assuming you intend to develop the freemarker-generator further, you
>>> can also gain Committer status, which practically means that you can
>>> work directly (without PR) on the Git repo, or merge PR-s.
>>>
>>> > See: https://www.apache.org/dev/new-committers-guide.html#cla
>>> >
>>> >> - Only Mark and I have contributed to this codebase.
>>> >> - Only Mark and I currently have contributor rights to the
>>> codebase I
>>> >> shared.
>>> >
>>> > In work time, right?
>>> >
>>> >> - Names.
>>> >>
>>> >>
>>> >> - The repository "freemarker-generator"
>>> >> - The readme "FreeMarker Generator" or "FreeMarker Generator Maven
>>> >> Plugin" (for now, as this is what it limited to)
>>> >> - We would use the Maven *groupId:* "org.apache.freemarker"
>>> >> - We would use the package prefix:
>>> "org.apache.freemarker.generator"
>>> >> - We would use the artifact/plugin name:
>>> >> "freemarker-generator-maven-plugin"
>>> >> - The default locations would be
>>> >> - src/freemarker-generator
>>> >> - src/freemarker-generator/template
>>> >> - src/freemarker-generator/generator
>>> >> - target/generated-sources/freemarker
>>> >
>>> > I agree, assuming the last meant to be
>>> > target/generated-sources/freemarker-generator.
>>> >
>>> >>
>>> >> - What specifically to replace the copyright with? I am sure the open
>>> >> source team can also help me here if there is no specific answer on
>>> your
>>> >> end.
>>> >
>>> > Same header as you see in almost all Apache project files:
>>> >
>>> > /*
>>> > * Licensed to the Apache Software Foundation (ASF) under one
>>> > * or more contributor license agreements. See the NOTICE file
>>> > * distributed with this work for additional information
>>> > * regarding copyright ownership. The ASF licenses this file
>>> > * to you under the Apache License, Version 2.0 (the
>>> > * "License"); you may not use this file except in compliance
>>> > * with the License. You may obtain a copy of the License at
>>> > *
>>> > * http://www.apache.org/licenses/LICENSE-2.0
>>> > *
>>> > * Unless required by applicable law or agreed to in writing,
>>> > * software distributed under the License is distributed on an
>>> > * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>>> > * KIND, either express or implied. See the License for the
>>> > * specific language governing permissions and limitations
>>> > * under the License.
>>> > */
>>> >
>>> > package org.apache.freemarker.generator;
>>> > ...
>>> >
>>> >> -Ben
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
>>> >>
>>> >>> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org>
>>> wrote:
>>> >>> >
>>> >>> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
>>> >>> >
>>> >>> > > BTW,
>>> >>> > >
>>> >>> > > The naming convention for maven plugins is either
>>> 'maven-XXX-plugin' if
>>> >>> > > supported by the maven team or 'XXX-maven-plugin' for all other
>>> >>> plugins;
>>> >>> > > this why Mark originally named it freemarker-maven-plugin. See
>>> >>> > >
>>> >>>
>>> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>>> >>> > >
>>> >>> > > So someone looking for this plugin will almost certainly default to
>>> >>> > > searching for "freemarker-maven-plugin" so it is possible that the
>>> >>> existing
>>> >>> > > name is the superior choice.
>>> >>> >
>>> >>> > I think they will just search the web for `freemarker maven plugin`,
>>> >>> > and not `freemarker-maven-plugin`. So if the thing is called, for
>>> >>> > example, "FreeMarker Generator Maven Plugin", it will be still a top
>>> >>> > hit (especially if someone also looks for "generating" source code
>>> >>> > with FreeMarker). And then the directory can be
>>> >>> > "freemarker-generator", not the overly generic "freemarker" (which
>>> can
>>> >>> > lead to some confusion, like people put their e-mail templates there,
>>> >>> > instead of /src/resources/freemarker/).
>>> >>> >
>>> >>> > But it's not like I want to drag this too long. Either one is
>>> >>> > acceptable to me. So, guys, care for a totally informal vote? (We can
>>> >>> > do a formal one in case no consensus reached soon.)
>>> >>> >
>>> >>> > I prefer ("Offical name" (artifact-name; src/directory-name):
>>> >>> >
>>> >>> > A "Apache FreeMarker Maven Plugin"
>>> >>> > (freemarker-maven-plugin; src/freemarker)
>>> >>> >
>>> >>> > B "Apache FreeMarker Generator Maven Plugin"
>>> >>> > (freemarker-generator-maven-plugin; src/freemarker-generator)
>>> >>> >
>>> >>> > C "Apache FreeMarker File Generator Maven Plugin"
>>> >>> > (freemarker-file-generator-maven-plugin;
>>> >>> src/freemarker-file-generator)
>>> >>> >
>>> >>> > D Something else (please provide the name)
>>> >>> >
>>> >>> >
>>> >>> > I vote for B.
>>> >>> Me, too. :-)
>>> >>>
>>> >>> Woonsan
>>> >>>
>>> >>> >
>>> >>> >
>>> >>> > > -Ben
>>> >>> > >
>>> >>> > >
>>> >>> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
>>> >>> wrote:
>>> >>> > >
>>> >>> > >> Here is the existing codebase for this project.
>>> >>> > >>
>>> >>> > >> https://github.com/yahoo/freemarker-maven-plugin
>>> >>> > >>
>>> >>> > >> It seemed more straightforward to work through our opensource
>>> team to
>>> >>> > >> publish the code so that it could be reviewed before continuing
>>> this
>>> >>> > >> conversation. Please comment on any remediations you see as
>>> needed
>>> >>> (if
>>> >>> > >> any) before working towards gifting this code to the apache
>>> >>> foundation as a
>>> >>> > >> starting point for this plugin.
>>> >>> > >>
>>> >>> > >> Also, as mentioned in the conversation above, it would be
>>> preferable
>>> >>> if
>>> >>> > >> this plugin had a unique and easily searchable name. Does anyone
>>> have
>>> >>> > >> ideas?
>>> >>> > >> I have no good ideas; here are some uninspired options:
>>> >>> > >>
>>> >>> > >> FreeGenerator
>>> >>> > >> FMGenerator
>>> >>> > >> FMGen
>>> >>> > >> fmg
>>> >>> > >> fmgen
>>> >>> > >> FMarkerGen
>>> >>> > >> MarkerGen
>>> >>> > >> MGen
>>> >>> > >> MGenerator
>>> >>> > >>
>>> >>> > >>
>>> >>> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
>>> >>> wrote:
>>> >>> > >>
>>> >>> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <
>>> ddekany@apache.org>
>>> >>> > >>> wrote:
>>> >>> > >>> ...snip...
>>> >>> > >>> > Without an ASF account the contributors couldn't edit the Wiki
>>> >>> page.
>>> >>> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
>>> >>> what I
>>> >>> > >>> > recommend.
>>> >>> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA
>>> ticket
>>> >>> > >>> and we can edit its description together there.
>>> >>> > >>>
>>> >>> > >>> ...snip...
>>> >>> > >>> > This was my intent from the beginning. A generator file can be
>>> a
>>> >>> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later,
>>> like an
>>> >>> xml
>>> >>> > >>> > that's transformed by a templates/myxmltransformat.ftl). They
>>> are
>>> >>> > >>> > totally unrelated, independent generator files. I have never
>>> >>> assumed
>>> >>> > >>> > that they come in pairs, hence there was never a such thing as
>>> "ftl
>>> >>> > >>> > only generator" in my head either. All generator files are
>>> lonely.
>>> >>> > >>> That's clear now. I think I made an unnecessary confusion by
>>> using
>>> >>> > >>> 'ftl-only' generator when mentioning .ftl type generator.
>>> >>> > >>> Thanks!
>>> >>> > >>>
>>> >>> > >>> Woonsan
>>> >>> > >>>
>>> >>> > >>
>>> >>> > >>
>>> >>> > >> --
>>> >>> > >> Benjamin Grant Jackson
>>> >>> > >>
>>> >>> > >
>>> >>> > >
>>> >>> >
>>> >>> > --
>>> >>> > Thanks,
>>> >>> > Daniel Dekany
>>> >>> >
>>> >>>
>>> >>
>>> >>
>>> >
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>>
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Wednesday, September 19, 2018, 5:27:36 PM, Ben Jackson wrote:
> According to our open source team when I talked with them last week, we
> shouldn't need to sign the CCLA because the company has already done so
> more generally for all Apache foundation projects. We just got the official
> signoff to sight the ICLAs last Friday. I did send your request above to
> that team to get their specific feedback.
I didn't know you already have a CCLA. In that case you won't need to
submit another.
> I submitted my ICLA today and have asked Mark to do the same.
Great!
> Yes, it does make sense for Committer status.
So then we will arrange that. Both you and Mark want Committer status,
right?
> We would like to get the
> project in place, publish the first artifact and migrate the dependent.
> project to use this open source plugin on the way to publishing it over the
> next month.
>
> What would the process for publishing an artifact look like?
That's a somewhat heavy process... I takes at least 4 days, but a week
is more realistic, and it needs a FreeMarker PMC (Project Management
Committee) member to execute it. So, you indicate on this list that a
release should be done, then wait until a FreeMarker PMC member finds
time to execute process, and I think that's it as far as you are
concerned. The PMC member will build and upload the release artifacts
for staging, and hold a voting on releasing them on this list. At
least 3 FreeMarker PMC members have to vote positively, which might
takes some time, and the voting will not be closed for a minimum of 72
hours. Only then will the staged artifacts be published, on the Maven
Central Repo, among others.
We will also need some page(s) on freemarker.apache.org that contains
the up to date documentation, including the version history. That's
not tied to the release process though, and can be uploaded by any
Committer.
> Best,
>
> Ben
>
>
>
> On Tue, Sep 18, 2018 at 3:19 PM Daniel Dekany <dd...@apache.org> wrote:
>
>> Friday, September 7, 2018, 5:57:43 PM, Daniel Dekany wrote:
>>
>> > Friday, September 7, 2018, 4:54:15 PM, Ben Jackson wrote:
>> >
>> >> I like the name FreeMarker Generator (Maven Plugin). I think we should
>> >> name the repo freemarker-generator, and then leave open the possibility
>> of
>> >> providing additional ways to drive the code generation through
>> additional
>> >> build tools.
>> >
>> > Indeed, good point. That will be a multi module Maven project, with
>> > freemarker-generator-core and freemarker-generator-maven-plugin
>> > submodules.
>> >
>> >> - Yes, I believe we can follow a simple CLA process. I will open a
>> >> ticket today for us to sign the CLAs.
>> >
>> > So, both of you should sign an ICLA ("I" for Individual). It's easy;
>> > print it, sign it, scan it, e-mail it. Then you can contribute to any
>> > Apache projects on your free time, so it never hurts to have one.
>> >
>> > Then, certainly we will also need a CCLA ("C" for Corporate) for the
>> > contribution, assuming you did this as part of your work, or if your
>> > employer can claim that for any other reason. The signer of the CCLA
>> > has to be someone who has right to make such a legal statement in the
>> > name of the company. But maybe wait until some more FreeMarker PMC
>> > members respond to this.
>>
>> So, the decision on our side is that we go on as planned earlier. If
>> you agree, you should submit the CCLA (in additionally to the ICLA-s).
>> In the CCLA, under "Initial list of designated employees", please add
>> the names of both of you. Again, the signer (and presumably who fills
>> the whole CCLA) is not you, but someone at Oath Inc. who has right to
>> make such a legal statement.
>>
>> Assuming you intend to develop the freemarker-generator further, you
>> can also gain Committer status, which practically means that you can
>> work directly (without PR) on the Git repo, or merge PR-s.
>>
>> > See: https://www.apache.org/dev/new-committers-guide.html#cla
>> >
>> >> - Only Mark and I have contributed to this codebase.
>> >> - Only Mark and I currently have contributor rights to the
>> codebase I
>> >> shared.
>> >
>> > In work time, right?
>> >
>> >> - Names.
>> >>
>> >>
>> >> - The repository "freemarker-generator"
>> >> - The readme "FreeMarker Generator" or "FreeMarker Generator Maven
>> >> Plugin" (for now, as this is what it limited to)
>> >> - We would use the Maven *groupId:* "org.apache.freemarker"
>> >> - We would use the package prefix:
>> "org.apache.freemarker.generator"
>> >> - We would use the artifact/plugin name:
>> >> "freemarker-generator-maven-plugin"
>> >> - The default locations would be
>> >> - src/freemarker-generator
>> >> - src/freemarker-generator/template
>> >> - src/freemarker-generator/generator
>> >> - target/generated-sources/freemarker
>> >
>> > I agree, assuming the last meant to be
>> > target/generated-sources/freemarker-generator.
>> >
>> >>
>> >> - What specifically to replace the copyright with? I am sure the open
>> >> source team can also help me here if there is no specific answer on
>> your
>> >> end.
>> >
>> > Same header as you see in almost all Apache project files:
>> >
>> > /*
>> > * Licensed to the Apache Software Foundation (ASF) under one
>> > * or more contributor license agreements. See the NOTICE file
>> > * distributed with this work for additional information
>> > * regarding copyright ownership. The ASF licenses this file
>> > * to you under the Apache License, Version 2.0 (the
>> > * "License"); you may not use this file except in compliance
>> > * with the License. You may obtain a copy of the License at
>> > *
>> > * http://www.apache.org/licenses/LICENSE-2.0
>> > *
>> > * Unless required by applicable law or agreed to in writing,
>> > * software distributed under the License is distributed on an
>> > * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> > * KIND, either express or implied. See the License for the
>> > * specific language governing permissions and limitations
>> > * under the License.
>> > */
>> >
>> > package org.apache.freemarker.generator;
>> > ...
>> >
>> >> -Ben
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
>> >>
>> >>> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org>
>> wrote:
>> >>> >
>> >>> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
>> >>> >
>> >>> > > BTW,
>> >>> > >
>> >>> > > The naming convention for maven plugins is either
>> 'maven-XXX-plugin' if
>> >>> > > supported by the maven team or 'XXX-maven-plugin' for all other
>> >>> plugins;
>> >>> > > this why Mark originally named it freemarker-maven-plugin. See
>> >>> > >
>> >>>
>> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>> >>> > >
>> >>> > > So someone looking for this plugin will almost certainly default to
>> >>> > > searching for "freemarker-maven-plugin" so it is possible that the
>> >>> existing
>> >>> > > name is the superior choice.
>> >>> >
>> >>> > I think they will just search the web for `freemarker maven plugin`,
>> >>> > and not `freemarker-maven-plugin`. So if the thing is called, for
>> >>> > example, "FreeMarker Generator Maven Plugin", it will be still a top
>> >>> > hit (especially if someone also looks for "generating" source code
>> >>> > with FreeMarker). And then the directory can be
>> >>> > "freemarker-generator", not the overly generic "freemarker" (which
>> can
>> >>> > lead to some confusion, like people put their e-mail templates there,
>> >>> > instead of /src/resources/freemarker/).
>> >>> >
>> >>> > But it's not like I want to drag this too long. Either one is
>> >>> > acceptable to me. So, guys, care for a totally informal vote? (We can
>> >>> > do a formal one in case no consensus reached soon.)
>> >>> >
>> >>> > I prefer ("Offical name" (artifact-name; src/directory-name):
>> >>> >
>> >>> > A "Apache FreeMarker Maven Plugin"
>> >>> > (freemarker-maven-plugin; src/freemarker)
>> >>> >
>> >>> > B "Apache FreeMarker Generator Maven Plugin"
>> >>> > (freemarker-generator-maven-plugin; src/freemarker-generator)
>> >>> >
>> >>> > C "Apache FreeMarker File Generator Maven Plugin"
>> >>> > (freemarker-file-generator-maven-plugin;
>> >>> src/freemarker-file-generator)
>> >>> >
>> >>> > D Something else (please provide the name)
>> >>> >
>> >>> >
>> >>> > I vote for B.
>> >>> Me, too. :-)
>> >>>
>> >>> Woonsan
>> >>>
>> >>> >
>> >>> >
>> >>> > > -Ben
>> >>> > >
>> >>> > >
>> >>> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
>> >>> wrote:
>> >>> > >
>> >>> > >> Here is the existing codebase for this project.
>> >>> > >>
>> >>> > >> https://github.com/yahoo/freemarker-maven-plugin
>> >>> > >>
>> >>> > >> It seemed more straightforward to work through our opensource
>> team to
>> >>> > >> publish the code so that it could be reviewed before continuing
>> this
>> >>> > >> conversation. Please comment on any remediations you see as
>> needed
>> >>> (if
>> >>> > >> any) before working towards gifting this code to the apache
>> >>> foundation as a
>> >>> > >> starting point for this plugin.
>> >>> > >>
>> >>> > >> Also, as mentioned in the conversation above, it would be
>> preferable
>> >>> if
>> >>> > >> this plugin had a unique and easily searchable name. Does anyone
>> have
>> >>> > >> ideas?
>> >>> > >> I have no good ideas; here are some uninspired options:
>> >>> > >>
>> >>> > >> FreeGenerator
>> >>> > >> FMGenerator
>> >>> > >> FMGen
>> >>> > >> fmg
>> >>> > >> fmgen
>> >>> > >> FMarkerGen
>> >>> > >> MarkerGen
>> >>> > >> MGen
>> >>> > >> MGenerator
>> >>> > >>
>> >>> > >>
>> >>> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
>> >>> wrote:
>> >>> > >>
>> >>> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <
>> ddekany@apache.org>
>> >>> > >>> wrote:
>> >>> > >>> ...snip...
>> >>> > >>> > Without an ASF account the contributors couldn't edit the Wiki
>> >>> page.
>> >>> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
>> >>> what I
>> >>> > >>> > recommend.
>> >>> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA
>> ticket
>> >>> > >>> and we can edit its description together there.
>> >>> > >>>
>> >>> > >>> ...snip...
>> >>> > >>> > This was my intent from the beginning. A generator file can be
>> a
>> >>> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later,
>> like an
>> >>> xml
>> >>> > >>> > that's transformed by a templates/myxmltransformat.ftl). They
>> are
>> >>> > >>> > totally unrelated, independent generator files. I have never
>> >>> assumed
>> >>> > >>> > that they come in pairs, hence there was never a such thing as
>> "ftl
>> >>> > >>> > only generator" in my head either. All generator files are
>> lonely.
>> >>> > >>> That's clear now. I think I made an unnecessary confusion by
>> using
>> >>> > >>> 'ftl-only' generator when mentioning .ftl type generator.
>> >>> > >>> Thanks!
>> >>> > >>>
>> >>> > >>> Woonsan
>> >>> > >>>
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Benjamin Grant Jackson
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>> >
>> >>> > --
>> >>> > Thanks,
>> >>> > Daniel Dekany
>> >>> >
>> >>>
>> >>
>> >>
>> >
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
According to our open source team when I talked with them last week, we
shouldn't need to sign the CCLA because the company has already done so
more generally for all Apache foundation projects. We just got the official
signoff to sight the ICLAs last Friday. I did send your request above to
that team to get their specific feedback.
I submitted my ICLA today and have asked Mark to do the same.
Yes, it does make sense for Committer status. We would like to get the
project in place, publish the first artifact and migrate the dependent.
project to use this open source plugin on the way to publishing it over the
next month.
What would the process for publishing an artifact look like?
Best,
Ben
On Tue, Sep 18, 2018 at 3:19 PM Daniel Dekany <dd...@apache.org> wrote:
> Friday, September 7, 2018, 5:57:43 PM, Daniel Dekany wrote:
>
> > Friday, September 7, 2018, 4:54:15 PM, Ben Jackson wrote:
> >
> >> I like the name FreeMarker Generator (Maven Plugin). I think we should
> >> name the repo freemarker-generator, and then leave open the possibility
> of
> >> providing additional ways to drive the code generation through
> additional
> >> build tools.
> >
> > Indeed, good point. That will be a multi module Maven project, with
> > freemarker-generator-core and freemarker-generator-maven-plugin
> > submodules.
> >
> >> - Yes, I believe we can follow a simple CLA process. I will open a
> >> ticket today for us to sign the CLAs.
> >
> > So, both of you should sign an ICLA ("I" for Individual). It's easy;
> > print it, sign it, scan it, e-mail it. Then you can contribute to any
> > Apache projects on your free time, so it never hurts to have one.
> >
> > Then, certainly we will also need a CCLA ("C" for Corporate) for the
> > contribution, assuming you did this as part of your work, or if your
> > employer can claim that for any other reason. The signer of the CCLA
> > has to be someone who has right to make such a legal statement in the
> > name of the company. But maybe wait until some more FreeMarker PMC
> > members respond to this.
>
> So, the decision on our side is that we go on as planned earlier. If
> you agree, you should submit the CCLA (in additionally to the ICLA-s).
> In the CCLA, under "Initial list of designated employees", please add
> the names of both of you. Again, the signer (and presumably who fills
> the whole CCLA) is not you, but someone at Oath Inc. who has right to
> make such a legal statement.
>
> Assuming you intend to develop the freemarker-generator further, you
> can also gain Committer status, which practically means that you can
> work directly (without PR) on the Git repo, or merge PR-s.
>
> > See: https://www.apache.org/dev/new-committers-guide.html#cla
> >
> >> - Only Mark and I have contributed to this codebase.
> >> - Only Mark and I currently have contributor rights to the
> codebase I
> >> shared.
> >
> > In work time, right?
> >
> >> - Names.
> >>
> >>
> >> - The repository "freemarker-generator"
> >> - The readme "FreeMarker Generator" or "FreeMarker Generator Maven
> >> Plugin" (for now, as this is what it limited to)
> >> - We would use the Maven *groupId:* "org.apache.freemarker"
> >> - We would use the package prefix:
> "org.apache.freemarker.generator"
> >> - We would use the artifact/plugin name:
> >> "freemarker-generator-maven-plugin"
> >> - The default locations would be
> >> - src/freemarker-generator
> >> - src/freemarker-generator/template
> >> - src/freemarker-generator/generator
> >> - target/generated-sources/freemarker
> >
> > I agree, assuming the last meant to be
> > target/generated-sources/freemarker-generator.
> >
> >>
> >> - What specifically to replace the copyright with? I am sure the open
> >> source team can also help me here if there is no specific answer on
> your
> >> end.
> >
> > Same header as you see in almost all Apache project files:
> >
> > /*
> > * Licensed to the Apache Software Foundation (ASF) under one
> > * or more contributor license agreements. See the NOTICE file
> > * distributed with this work for additional information
> > * regarding copyright ownership. The ASF licenses this file
> > * to you under the Apache License, Version 2.0 (the
> > * "License"); you may not use this file except in compliance
> > * with the License. You may obtain a copy of the License at
> > *
> > * http://www.apache.org/licenses/LICENSE-2.0
> > *
> > * Unless required by applicable law or agreed to in writing,
> > * software distributed under the License is distributed on an
> > * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > * KIND, either express or implied. See the License for the
> > * specific language governing permissions and limitations
> > * under the License.
> > */
> >
> > package org.apache.freemarker.generator;
> > ...
> >
> >> -Ben
> >>
> >>
> >>
> >>
> >>
> >> On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
> >>
> >>> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org>
> wrote:
> >>> >
> >>> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
> >>> >
> >>> > > BTW,
> >>> > >
> >>> > > The naming convention for maven plugins is either
> 'maven-XXX-plugin' if
> >>> > > supported by the maven team or 'XXX-maven-plugin' for all other
> >>> plugins;
> >>> > > this why Mark originally named it freemarker-maven-plugin. See
> >>> > >
> >>>
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
> >>> > >
> >>> > > So someone looking for this plugin will almost certainly default to
> >>> > > searching for "freemarker-maven-plugin" so it is possible that the
> >>> existing
> >>> > > name is the superior choice.
> >>> >
> >>> > I think they will just search the web for `freemarker maven plugin`,
> >>> > and not `freemarker-maven-plugin`. So if the thing is called, for
> >>> > example, "FreeMarker Generator Maven Plugin", it will be still a top
> >>> > hit (especially if someone also looks for "generating" source code
> >>> > with FreeMarker). And then the directory can be
> >>> > "freemarker-generator", not the overly generic "freemarker" (which
> can
> >>> > lead to some confusion, like people put their e-mail templates there,
> >>> > instead of /src/resources/freemarker/).
> >>> >
> >>> > But it's not like I want to drag this too long. Either one is
> >>> > acceptable to me. So, guys, care for a totally informal vote? (We can
> >>> > do a formal one in case no consensus reached soon.)
> >>> >
> >>> > I prefer ("Offical name" (artifact-name; src/directory-name):
> >>> >
> >>> > A "Apache FreeMarker Maven Plugin"
> >>> > (freemarker-maven-plugin; src/freemarker)
> >>> >
> >>> > B "Apache FreeMarker Generator Maven Plugin"
> >>> > (freemarker-generator-maven-plugin; src/freemarker-generator)
> >>> >
> >>> > C "Apache FreeMarker File Generator Maven Plugin"
> >>> > (freemarker-file-generator-maven-plugin;
> >>> src/freemarker-file-generator)
> >>> >
> >>> > D Something else (please provide the name)
> >>> >
> >>> >
> >>> > I vote for B.
> >>> Me, too. :-)
> >>>
> >>> Woonsan
> >>>
> >>> >
> >>> >
> >>> > > -Ben
> >>> > >
> >>> > >
> >>> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
> >>> wrote:
> >>> > >
> >>> > >> Here is the existing codebase for this project.
> >>> > >>
> >>> > >> https://github.com/yahoo/freemarker-maven-plugin
> >>> > >>
> >>> > >> It seemed more straightforward to work through our opensource
> team to
> >>> > >> publish the code so that it could be reviewed before continuing
> this
> >>> > >> conversation. Please comment on any remediations you see as
> needed
> >>> (if
> >>> > >> any) before working towards gifting this code to the apache
> >>> foundation as a
> >>> > >> starting point for this plugin.
> >>> > >>
> >>> > >> Also, as mentioned in the conversation above, it would be
> preferable
> >>> if
> >>> > >> this plugin had a unique and easily searchable name. Does anyone
> have
> >>> > >> ideas?
> >>> > >> I have no good ideas; here are some uninspired options:
> >>> > >>
> >>> > >> FreeGenerator
> >>> > >> FMGenerator
> >>> > >> FMGen
> >>> > >> fmg
> >>> > >> fmgen
> >>> > >> FMarkerGen
> >>> > >> MarkerGen
> >>> > >> MGen
> >>> > >> MGenerator
> >>> > >>
> >>> > >>
> >>> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
> >>> wrote:
> >>> > >>
> >>> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <
> ddekany@apache.org>
> >>> > >>> wrote:
> >>> > >>> ...snip...
> >>> > >>> > Without an ASF account the contributors couldn't edit the Wiki
> >>> page.
> >>> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
> >>> what I
> >>> > >>> > recommend.
> >>> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA
> ticket
> >>> > >>> and we can edit its description together there.
> >>> > >>>
> >>> > >>> ...snip...
> >>> > >>> > This was my intent from the beginning. A generator file can be
> a
> >>> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later,
> like an
> >>> xml
> >>> > >>> > that's transformed by a templates/myxmltransformat.ftl). They
> are
> >>> > >>> > totally unrelated, independent generator files. I have never
> >>> assumed
> >>> > >>> > that they come in pairs, hence there was never a such thing as
> "ftl
> >>> > >>> > only generator" in my head either. All generator files are
> lonely.
> >>> > >>> That's clear now. I think I made an unnecessary confusion by
> using
> >>> > >>> 'ftl-only' generator when mentioning .ftl type generator.
> >>> > >>> Thanks!
> >>> > >>>
> >>> > >>> Woonsan
> >>> > >>>
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Benjamin Grant Jackson
> >>> > >>
> >>> > >
> >>> > >
> >>> >
> >>> > --
> >>> > Thanks,
> >>> > Daniel Dekany
> >>> >
> >>>
> >>
> >>
> >
>
> --
> Thanks,
> Daniel Dekany
>
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Friday, September 7, 2018, 5:57:43 PM, Daniel Dekany wrote:
> Friday, September 7, 2018, 4:54:15 PM, Ben Jackson wrote:
>
>> I like the name FreeMarker Generator (Maven Plugin). I think we should
>> name the repo freemarker-generator, and then leave open the possibility of
>> providing additional ways to drive the code generation through additional
>> build tools.
>
> Indeed, good point. That will be a multi module Maven project, with
> freemarker-generator-core and freemarker-generator-maven-plugin
> submodules.
>
>> - Yes, I believe we can follow a simple CLA process. I will open a
>> ticket today for us to sign the CLAs.
>
> So, both of you should sign an ICLA ("I" for Individual). It's easy;
> print it, sign it, scan it, e-mail it. Then you can contribute to any
> Apache projects on your free time, so it never hurts to have one.
>
> Then, certainly we will also need a CCLA ("C" for Corporate) for the
> contribution, assuming you did this as part of your work, or if your
> employer can claim that for any other reason. The signer of the CCLA
> has to be someone who has right to make such a legal statement in the
> name of the company. But maybe wait until some more FreeMarker PMC
> members respond to this.
So, the decision on our side is that we go on as planned earlier. If
you agree, you should submit the CCLA (in additionally to the ICLA-s).
In the CCLA, under "Initial list of designated employees", please add
the names of both of you. Again, the signer (and presumably who fills
the whole CCLA) is not you, but someone at Oath Inc. who has right to
make such a legal statement.
Assuming you intend to develop the freemarker-generator further, you
can also gain Committer status, which practically means that you can
work directly (without PR) on the Git repo, or merge PR-s.
> See: https://www.apache.org/dev/new-committers-guide.html#cla
>
>> - Only Mark and I have contributed to this codebase.
>> - Only Mark and I currently have contributor rights to the codebase I
>> shared.
>
> In work time, right?
>
>> - Names.
>>
>>
>> - The repository "freemarker-generator"
>> - The readme "FreeMarker Generator" or "FreeMarker Generator Maven
>> Plugin" (for now, as this is what it limited to)
>> - We would use the Maven *groupId:* "org.apache.freemarker"
>> - We would use the package prefix: "org.apache.freemarker.generator"
>> - We would use the artifact/plugin name:
>> "freemarker-generator-maven-plugin"
>> - The default locations would be
>> - src/freemarker-generator
>> - src/freemarker-generator/template
>> - src/freemarker-generator/generator
>> - target/generated-sources/freemarker
>
> I agree, assuming the last meant to be
> target/generated-sources/freemarker-generator.
>
>>
>> - What specifically to replace the copyright with? I am sure the open
>> source team can also help me here if there is no specific answer on your
>> end.
>
> Same header as you see in almost all Apache project files:
>
> /*
> * Licensed to the Apache Software Foundation (ASF) under one
> * or more contributor license agreements. See the NOTICE file
> * distributed with this work for additional information
> * regarding copyright ownership. The ASF licenses this file
> * to you under the Apache License, Version 2.0 (the
> * "License"); you may not use this file except in compliance
> * with the License. You may obtain a copy of the License at
> *
> * http://www.apache.org/licenses/LICENSE-2.0
> *
> * Unless required by applicable law or agreed to in writing,
> * software distributed under the License is distributed on an
> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> * KIND, either express or implied. See the License for the
> * specific language governing permissions and limitations
> * under the License.
> */
>
> package org.apache.freemarker.generator;
> ...
>
>> -Ben
>>
>>
>>
>>
>>
>> On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
>>
>>> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org> wrote:
>>> >
>>> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
>>> >
>>> > > BTW,
>>> > >
>>> > > The naming convention for maven plugins is either 'maven-XXX-plugin' if
>>> > > supported by the maven team or 'XXX-maven-plugin' for all other
>>> plugins;
>>> > > this why Mark originally named it freemarker-maven-plugin. See
>>> > >
>>> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>>> > >
>>> > > So someone looking for this plugin will almost certainly default to
>>> > > searching for "freemarker-maven-plugin" so it is possible that the
>>> existing
>>> > > name is the superior choice.
>>> >
>>> > I think they will just search the web for `freemarker maven plugin`,
>>> > and not `freemarker-maven-plugin`. So if the thing is called, for
>>> > example, "FreeMarker Generator Maven Plugin", it will be still a top
>>> > hit (especially if someone also looks for "generating" source code
>>> > with FreeMarker). And then the directory can be
>>> > "freemarker-generator", not the overly generic "freemarker" (which can
>>> > lead to some confusion, like people put their e-mail templates there,
>>> > instead of /src/resources/freemarker/).
>>> >
>>> > But it's not like I want to drag this too long. Either one is
>>> > acceptable to me. So, guys, care for a totally informal vote? (We can
>>> > do a formal one in case no consensus reached soon.)
>>> >
>>> > I prefer ("Offical name" (artifact-name; src/directory-name):
>>> >
>>> > A "Apache FreeMarker Maven Plugin"
>>> > (freemarker-maven-plugin; src/freemarker)
>>> >
>>> > B "Apache FreeMarker Generator Maven Plugin"
>>> > (freemarker-generator-maven-plugin; src/freemarker-generator)
>>> >
>>> > C "Apache FreeMarker File Generator Maven Plugin"
>>> > (freemarker-file-generator-maven-plugin;
>>> src/freemarker-file-generator)
>>> >
>>> > D Something else (please provide the name)
>>> >
>>> >
>>> > I vote for B.
>>> Me, too. :-)
>>>
>>> Woonsan
>>>
>>> >
>>> >
>>> > > -Ben
>>> > >
>>> > >
>>> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
>>> wrote:
>>> > >
>>> > >> Here is the existing codebase for this project.
>>> > >>
>>> > >> https://github.com/yahoo/freemarker-maven-plugin
>>> > >>
>>> > >> It seemed more straightforward to work through our opensource team to
>>> > >> publish the code so that it could be reviewed before continuing this
>>> > >> conversation. Please comment on any remediations you see as needed
>>> (if
>>> > >> any) before working towards gifting this code to the apache
>>> foundation as a
>>> > >> starting point for this plugin.
>>> > >>
>>> > >> Also, as mentioned in the conversation above, it would be preferable
>>> if
>>> > >> this plugin had a unique and easily searchable name. Does anyone have
>>> > >> ideas?
>>> > >> I have no good ideas; here are some uninspired options:
>>> > >>
>>> > >> FreeGenerator
>>> > >> FMGenerator
>>> > >> FMGen
>>> > >> fmg
>>> > >> fmgen
>>> > >> FMarkerGen
>>> > >> MarkerGen
>>> > >> MGen
>>> > >> MGenerator
>>> > >>
>>> > >>
>>> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
>>> wrote:
>>> > >>
>>> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
>>> > >>> wrote:
>>> > >>> ...snip...
>>> > >>> > Without an ASF account the contributors couldn't edit the Wiki
>>> page.
>>> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
>>> what I
>>> > >>> > recommend.
>>> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
>>> > >>> and we can edit its description together there.
>>> > >>>
>>> > >>> ...snip...
>>> > >>> > This was my intent from the beginning. A generator file can be a
>>> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an
>>> xml
>>> > >>> > that's transformed by a templates/myxmltransformat.ftl). They are
>>> > >>> > totally unrelated, independent generator files. I have never
>>> assumed
>>> > >>> > that they come in pairs, hence there was never a such thing as "ftl
>>> > >>> > only generator" in my head either. All generator files are lonely.
>>> > >>> That's clear now. I think I made an unnecessary confusion by using
>>> > >>> 'ftl-only' generator when mentioning .ftl type generator.
>>> > >>> Thanks!
>>> > >>>
>>> > >>> Woonsan
>>> > >>>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Benjamin Grant Jackson
>>> > >>
>>> > >
>>> > >
>>> >
>>> > --
>>> > Thanks,
>>> > Daniel Dekany
>>> >
>>>
>>
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Friday, September 7, 2018, 4:54:15 PM, Ben Jackson wrote:
> I like the name FreeMarker Generator (Maven Plugin). I think we should
> name the repo freemarker-generator, and then leave open the possibility of
> providing additional ways to drive the code generation through additional
> build tools.
Indeed, good point. That will be a multi module Maven project, with
freemarker-generator-core and freemarker-generator-maven-plugin
submodules.
> - Yes, I believe we can follow a simple CLA process. I will open a
> ticket today for us to sign the CLAs.
So, both of you should sign an ICLA ("I" for Individual). It's easy;
print it, sign it, scan it, e-mail it. Then you can contribute to any
Apache projects on your free time, so it never hurts to have one.
Then, certainly we will also need a CCLA ("C" for Corporate) for the
contribution, assuming you did this as part of your work, or if your
employer can claim that for any other reason. The signer of the CCLA
has to be someone who has right to make such a legal statement in the
name of the company. But maybe wait until some more FreeMarker PMC
members respond to this.
See: https://www.apache.org/dev/new-committers-guide.html#cla
> - Only Mark and I have contributed to this codebase.
> - Only Mark and I currently have contributor rights to the codebase I
> shared.
In work time, right?
> - Names.
>
>
> - The repository "freemarker-generator"
> - The readme "FreeMarker Generator" or "FreeMarker Generator Maven
> Plugin" (for now, as this is what it limited to)
> - We would use the Maven *groupId:* "org.apache.freemarker"
> - We would use the package prefix: "org.apache.freemarker.generator"
> - We would use the artifact/plugin name:
> "freemarker-generator-maven-plugin"
> - The default locations would be
> - src/freemarker-generator
> - src/freemarker-generator/template
> - src/freemarker-generator/generator
> - target/generated-sources/freemarker
I agree, assuming the last meant to be
target/generated-sources/freemarker-generator.
>
> - What specifically to replace the copyright with? I am sure the open
> source team can also help me here if there is no specific answer on your
> end.
Same header as you see in almost all Apache project files:
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.freemarker.generator;
...
> -Ben
>
>
>
>
>
> On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
>
>> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org> wrote:
>> >
>> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
>> >
>> > > BTW,
>> > >
>> > > The naming convention for maven plugins is either 'maven-XXX-plugin' if
>> > > supported by the maven team or 'XXX-maven-plugin' for all other
>> plugins;
>> > > this why Mark originally named it freemarker-maven-plugin. See
>> > >
>> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>> > >
>> > > So someone looking for this plugin will almost certainly default to
>> > > searching for "freemarker-maven-plugin" so it is possible that the
>> existing
>> > > name is the superior choice.
>> >
>> > I think they will just search the web for `freemarker maven plugin`,
>> > and not `freemarker-maven-plugin`. So if the thing is called, for
>> > example, "FreeMarker Generator Maven Plugin", it will be still a top
>> > hit (especially if someone also looks for "generating" source code
>> > with FreeMarker). And then the directory can be
>> > "freemarker-generator", not the overly generic "freemarker" (which can
>> > lead to some confusion, like people put their e-mail templates there,
>> > instead of /src/resources/freemarker/).
>> >
>> > But it's not like I want to drag this too long. Either one is
>> > acceptable to me. So, guys, care for a totally informal vote? (We can
>> > do a formal one in case no consensus reached soon.)
>> >
>> > I prefer ("Offical name" (artifact-name; src/directory-name):
>> >
>> > A "Apache FreeMarker Maven Plugin"
>> > (freemarker-maven-plugin; src/freemarker)
>> >
>> > B "Apache FreeMarker Generator Maven Plugin"
>> > (freemarker-generator-maven-plugin; src/freemarker-generator)
>> >
>> > C "Apache FreeMarker File Generator Maven Plugin"
>> > (freemarker-file-generator-maven-plugin;
>> src/freemarker-file-generator)
>> >
>> > D Something else (please provide the name)
>> >
>> >
>> > I vote for B.
>> Me, too. :-)
>>
>> Woonsan
>>
>> >
>> >
>> > > -Ben
>> > >
>> > >
>> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
>> wrote:
>> > >
>> > >> Here is the existing codebase for this project.
>> > >>
>> > >> https://github.com/yahoo/freemarker-maven-plugin
>> > >>
>> > >> It seemed more straightforward to work through our opensource team to
>> > >> publish the code so that it could be reviewed before continuing this
>> > >> conversation. Please comment on any remediations you see as needed
>> (if
>> > >> any) before working towards gifting this code to the apache
>> foundation as a
>> > >> starting point for this plugin.
>> > >>
>> > >> Also, as mentioned in the conversation above, it would be preferable
>> if
>> > >> this plugin had a unique and easily searchable name. Does anyone have
>> > >> ideas?
>> > >> I have no good ideas; here are some uninspired options:
>> > >>
>> > >> FreeGenerator
>> > >> FMGenerator
>> > >> FMGen
>> > >> fmg
>> > >> fmgen
>> > >> FMarkerGen
>> > >> MarkerGen
>> > >> MGen
>> > >> MGenerator
>> > >>
>> > >>
>> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
>> wrote:
>> > >>
>> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
>> > >>> wrote:
>> > >>> ...snip...
>> > >>> > Without an ASF account the contributors couldn't edit the Wiki
>> page.
>> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
>> what I
>> > >>> > recommend.
>> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
>> > >>> and we can edit its description together there.
>> > >>>
>> > >>> ...snip...
>> > >>> > This was my intent from the beginning. A generator file can be a
>> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an
>> xml
>> > >>> > that's transformed by a templates/myxmltransformat.ftl). They are
>> > >>> > totally unrelated, independent generator files. I have never
>> assumed
>> > >>> > that they come in pairs, hence there was never a such thing as "ftl
>> > >>> > only generator" in my head either. All generator files are lonely.
>> > >>> That's clear now. I think I made an unnecessary confusion by using
>> > >>> 'ftl-only' generator when mentioning .ftl type generator.
>> > >>> Thanks!
>> > >>>
>> > >>> Woonsan
>> > >>>
>> > >>
>> > >>
>> > >> --
>> > >> Benjamin Grant Jackson
>> > >>
>> > >
>> > >
>> >
>> > --
>> > Thanks,
>> > Daniel Dekany
>> >
>>
>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
I like the name FreeMarker Generator (Maven Plugin). I think we should
name the repo freemarker-generator, and then leave open the possibility of
providing additional ways to drive the code generation through additional
build tools.
- Yes, I believe we can follow a simple CLA process. I will open a
ticket today for us to sign the CLAs.
- Only Mark and I have contributed to this codebase.
- Only Mark and I currently have contributor rights to the codebase I
shared.
- Names.
- The repository "freemarker-generator"
- The readme "FreeMarker Generator" or "FreeMarker Generator Maven
Plugin" (for now, as this is what it limited to)
- We would use the Maven *groupId:* "org.apache.freemarker"
- We would use the package prefix: "org.apache.freemarker.generator"
- We would use the artifact/plugin name:
"freemarker-generator-maven-plugin"
- The default locations would be
- src/freemarker-generator
- src/freemarker-generator/template
- src/freemarker-generator/generator
- target/generated-sources/freemarker
- What specifically to replace the copyright with? I am sure the open
source team can also help me here if there is no specific answer on your
end.
-Ben
On Fri, Sep 7, 2018 at 9:23 AM Woonsan Ko <wo...@apache.org> wrote:
> On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org> wrote:
> >
> > Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
> >
> > > BTW,
> > >
> > > The naming convention for maven plugins is either 'maven-XXX-plugin' if
> > > supported by the maven team or 'XXX-maven-plugin' for all other
> plugins;
> > > this why Mark originally named it freemarker-maven-plugin. See
> > >
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
> > >
> > > So someone looking for this plugin will almost certainly default to
> > > searching for "freemarker-maven-plugin" so it is possible that the
> existing
> > > name is the superior choice.
> >
> > I think they will just search the web for `freemarker maven plugin`,
> > and not `freemarker-maven-plugin`. So if the thing is called, for
> > example, "FreeMarker Generator Maven Plugin", it will be still a top
> > hit (especially if someone also looks for "generating" source code
> > with FreeMarker). And then the directory can be
> > "freemarker-generator", not the overly generic "freemarker" (which can
> > lead to some confusion, like people put their e-mail templates there,
> > instead of /src/resources/freemarker/).
> >
> > But it's not like I want to drag this too long. Either one is
> > acceptable to me. So, guys, care for a totally informal vote? (We can
> > do a formal one in case no consensus reached soon.)
> >
> > I prefer ("Offical name" (artifact-name; src/directory-name):
> >
> > A "Apache FreeMarker Maven Plugin"
> > (freemarker-maven-plugin; src/freemarker)
> >
> > B "Apache FreeMarker Generator Maven Plugin"
> > (freemarker-generator-maven-plugin; src/freemarker-generator)
> >
> > C "Apache FreeMarker File Generator Maven Plugin"
> > (freemarker-file-generator-maven-plugin;
> src/freemarker-file-generator)
> >
> > D Something else (please provide the name)
> >
> >
> > I vote for B.
> Me, too. :-)
>
> Woonsan
>
> >
> >
> > > -Ben
> > >
> > >
> > > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com>
> wrote:
> > >
> > >> Here is the existing codebase for this project.
> > >>
> > >> https://github.com/yahoo/freemarker-maven-plugin
> > >>
> > >> It seemed more straightforward to work through our opensource team to
> > >> publish the code so that it could be reviewed before continuing this
> > >> conversation. Please comment on any remediations you see as needed
> (if
> > >> any) before working towards gifting this code to the apache
> foundation as a
> > >> starting point for this plugin.
> > >>
> > >> Also, as mentioned in the conversation above, it would be preferable
> if
> > >> this plugin had a unique and easily searchable name. Does anyone have
> > >> ideas?
> > >> I have no good ideas; here are some uninspired options:
> > >>
> > >> FreeGenerator
> > >> FMGenerator
> > >> FMGen
> > >> fmg
> > >> fmgen
> > >> FMarkerGen
> > >> MarkerGen
> > >> MGen
> > >> MGenerator
> > >>
> > >>
> > >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org>
> wrote:
> > >>
> > >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
> > >>> wrote:
> > >>> ...snip...
> > >>> > Without an ASF account the contributors couldn't edit the Wiki
> page.
> > >>> > If *they* open a JIRA issue, then we all can edit it. So that's
> what I
> > >>> > recommend.
> > >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
> > >>> and we can edit its description together there.
> > >>>
> > >>> ...snip...
> > >>> > This was my intent from the beginning. A generator file can be a
> > >>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an
> xml
> > >>> > that's transformed by a templates/myxmltransformat.ftl). They are
> > >>> > totally unrelated, independent generator files. I have never
> assumed
> > >>> > that they come in pairs, hence there was never a such thing as "ftl
> > >>> > only generator" in my head either. All generator files are lonely.
> > >>> That's clear now. I think I made an unnecessary confusion by using
> > >>> 'ftl-only' generator when mentioning .ftl type generator.
> > >>> Thanks!
> > >>>
> > >>> Woonsan
> > >>>
> > >>
> > >>
> > >> --
> > >> Benjamin Grant Jackson
> > >>
> > >
> > >
> >
> > --
> > Thanks,
> > Daniel Dekany
> >
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Fri, Sep 7, 2018 at 3:29 AM Daniel Dekany <dd...@apache.org> wrote:
>
> Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
>
> > BTW,
> >
> > The naming convention for maven plugins is either 'maven-XXX-plugin' if
> > supported by the maven team or 'XXX-maven-plugin' for all other plugins;
> > this why Mark originally named it freemarker-maven-plugin. See
> > https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
> >
> > So someone looking for this plugin will almost certainly default to
> > searching for "freemarker-maven-plugin" so it is possible that the existing
> > name is the superior choice.
>
> I think they will just search the web for `freemarker maven plugin`,
> and not `freemarker-maven-plugin`. So if the thing is called, for
> example, "FreeMarker Generator Maven Plugin", it will be still a top
> hit (especially if someone also looks for "generating" source code
> with FreeMarker). And then the directory can be
> "freemarker-generator", not the overly generic "freemarker" (which can
> lead to some confusion, like people put their e-mail templates there,
> instead of /src/resources/freemarker/).
>
> But it's not like I want to drag this too long. Either one is
> acceptable to me. So, guys, care for a totally informal vote? (We can
> do a formal one in case no consensus reached soon.)
>
> I prefer ("Offical name" (artifact-name; src/directory-name):
>
> A "Apache FreeMarker Maven Plugin"
> (freemarker-maven-plugin; src/freemarker)
>
> B "Apache FreeMarker Generator Maven Plugin"
> (freemarker-generator-maven-plugin; src/freemarker-generator)
>
> C "Apache FreeMarker File Generator Maven Plugin"
> (freemarker-file-generator-maven-plugin; src/freemarker-file-generator)
>
> D Something else (please provide the name)
>
>
> I vote for B.
Me, too. :-)
Woonsan
>
>
> > -Ben
> >
> >
> > On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com> wrote:
> >
> >> Here is the existing codebase for this project.
> >>
> >> https://github.com/yahoo/freemarker-maven-plugin
> >>
> >> It seemed more straightforward to work through our opensource team to
> >> publish the code so that it could be reviewed before continuing this
> >> conversation. Please comment on any remediations you see as needed (if
> >> any) before working towards gifting this code to the apache foundation as a
> >> starting point for this plugin.
> >>
> >> Also, as mentioned in the conversation above, it would be preferable if
> >> this plugin had a unique and easily searchable name. Does anyone have
> >> ideas?
> >> I have no good ideas; here are some uninspired options:
> >>
> >> FreeGenerator
> >> FMGenerator
> >> FMGen
> >> fmg
> >> fmgen
> >> FMarkerGen
> >> MarkerGen
> >> MGen
> >> MGenerator
> >>
> >>
> >> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
> >>
> >>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
> >>> wrote:
> >>> ...snip...
> >>> > Without an ASF account the contributors couldn't edit the Wiki page.
> >>> > If *they* open a JIRA issue, then we all can edit it. So that's what I
> >>> > recommend.
> >>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
> >>> and we can edit its description together there.
> >>>
> >>> ...snip...
> >>> > This was my intent from the beginning. A generator file can be a
> >>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
> >>> > that's transformed by a templates/myxmltransformat.ftl). They are
> >>> > totally unrelated, independent generator files. I have never assumed
> >>> > that they come in pairs, hence there was never a such thing as "ftl
> >>> > only generator" in my head either. All generator files are lonely.
> >>> That's clear now. I think I made an unnecessary confusion by using
> >>> 'ftl-only' generator when mentioning .ftl type generator.
> >>> Thanks!
> >>>
> >>> Woonsan
> >>>
> >>
> >>
> >> --
> >> Benjamin Grant Jackson
> >>
> >
> >
>
> --
> Thanks,
> Daniel Dekany
>
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Thursday, September 6, 2018, 6:27:34 PM, Ben Jackson wrote:
> BTW,
>
> The naming convention for maven plugins is either 'maven-XXX-plugin' if
> supported by the maven team or 'XXX-maven-plugin' for all other plugins;
> this why Mark originally named it freemarker-maven-plugin. See
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>
> So someone looking for this plugin will almost certainly default to
> searching for "freemarker-maven-plugin" so it is possible that the existing
> name is the superior choice.
I think they will just search the web for `freemarker maven plugin`,
and not `freemarker-maven-plugin`. So if the thing is called, for
example, "FreeMarker Generator Maven Plugin", it will be still a top
hit (especially if someone also looks for "generating" source code
with FreeMarker). And then the directory can be
"freemarker-generator", not the overly generic "freemarker" (which can
lead to some confusion, like people put their e-mail templates there,
instead of /src/resources/freemarker/).
But it's not like I want to drag this too long. Either one is
acceptable to me. So, guys, care for a totally informal vote? (We can
do a formal one in case no consensus reached soon.)
I prefer ("Offical name" (artifact-name; src/directory-name):
A "Apache FreeMarker Maven Plugin"
(freemarker-maven-plugin; src/freemarker)
B "Apache FreeMarker Generator Maven Plugin"
(freemarker-generator-maven-plugin; src/freemarker-generator)
C "Apache FreeMarker File Generator Maven Plugin"
(freemarker-file-generator-maven-plugin; src/freemarker-file-generator)
D Something else (please provide the name)
I vote for B.
> -Ben
>
>
> On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com> wrote:
>
>> Here is the existing codebase for this project.
>>
>> https://github.com/yahoo/freemarker-maven-plugin
>>
>> It seemed more straightforward to work through our opensource team to
>> publish the code so that it could be reviewed before continuing this
>> conversation. Please comment on any remediations you see as needed (if
>> any) before working towards gifting this code to the apache foundation as a
>> starting point for this plugin.
>>
>> Also, as mentioned in the conversation above, it would be preferable if
>> this plugin had a unique and easily searchable name. Does anyone have
>> ideas?
>> I have no good ideas; here are some uninspired options:
>>
>> FreeGenerator
>> FMGenerator
>> FMGen
>> fmg
>> fmgen
>> FMarkerGen
>> MarkerGen
>> MGen
>> MGenerator
>>
>>
>> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
>>
>>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
>>> wrote:
>>> ...snip...
>>> > Without an ASF account the contributors couldn't edit the Wiki page.
>>> > If *they* open a JIRA issue, then we all can edit it. So that's what I
>>> > recommend.
>>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
>>> and we can edit its description together there.
>>>
>>> ...snip...
>>> > This was my intent from the beginning. A generator file can be a
>>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
>>> > that's transformed by a templates/myxmltransformat.ftl). They are
>>> > totally unrelated, independent generator files. I have never assumed
>>> > that they come in pairs, hence there was never a such thing as "ftl
>>> > only generator" in my head either. All generator files are lonely.
>>> That's clear now. I think I made an unnecessary confusion by using
>>> 'ftl-only' generator when mentioning .ftl type generator.
>>> Thanks!
>>>
>>> Woonsan
>>>
>>
>>
>> --
>> Benjamin Grant Jackson
>>
>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Thu, Sep 6, 2018 at 12:27 PM Ben Jackson <ph...@gmail.com> wrote:
>
> BTW,
>
> The naming convention for maven plugins is either 'maven-XXX-plugin' if
> supported by the maven team or 'XXX-maven-plugin' for all other plugins;
> this why Mark originally named it freemarker-maven-plugin. See
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
Right.
>
> So someone looking for this plugin will almost certainly default to
> searching for "freemarker-maven-plugin" so it is possible that the existing
> name is the superior choice.
Sounds reasonable to me.
Woonsan
>
> -Ben
>
>
> On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com> wrote:
>
> > Here is the existing codebase for this project.
> >
> > https://github.com/yahoo/freemarker-maven-plugin
> >
> > It seemed more straightforward to work through our opensource team to
> > publish the code so that it could be reviewed before continuing this
> > conversation. Please comment on any remediations you see as needed (if
> > any) before working towards gifting this code to the apache foundation as a
> > starting point for this plugin.
> >
> > Also, as mentioned in the conversation above, it would be preferable if
> > this plugin had a unique and easily searchable name. Does anyone have
> > ideas?
> > I have no good ideas; here are some uninspired options:
> >
> > FreeGenerator
> > FMGenerator
> > FMGen
> > fmg
> > fmgen
> > FMarkerGen
> > MarkerGen
> > MGen
> > MGenerator
> >
> >
> > On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
> >
> >> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
> >> wrote:
> >> ...snip...
> >> > Without an ASF account the contributors couldn't edit the Wiki page.
> >> > If *they* open a JIRA issue, then we all can edit it. So that's what I
> >> > recommend.
> >> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
> >> and we can edit its description together there.
> >>
> >> ...snip...
> >> > This was my intent from the beginning. A generator file can be a
> >> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
> >> > that's transformed by a templates/myxmltransformat.ftl). They are
> >> > totally unrelated, independent generator files. I have never assumed
> >> > that they come in pairs, hence there was never a such thing as "ftl
> >> > only generator" in my head either. All generator files are lonely.
> >> That's clear now. I think I made an unnecessary confusion by using
> >> 'ftl-only' generator when mentioning .ftl type generator.
> >> Thanks!
> >>
> >> Woonsan
> >>
> >
> >
> > --
> > Benjamin Grant Jackson
> >
>
>
> --
> Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
BTW,
The naming convention for maven plugins is either 'maven-XXX-plugin' if
supported by the maven team or 'XXX-maven-plugin' for all other plugins;
this why Mark originally named it freemarker-maven-plugin. See
https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
So someone looking for this plugin will almost certainly default to
searching for "freemarker-maven-plugin" so it is possible that the existing
name is the superior choice.
-Ben
On Thu, Sep 6, 2018 at 11:14 AM Ben Jackson <ph...@gmail.com> wrote:
> Here is the existing codebase for this project.
>
> https://github.com/yahoo/freemarker-maven-plugin
>
> It seemed more straightforward to work through our opensource team to
> publish the code so that it could be reviewed before continuing this
> conversation. Please comment on any remediations you see as needed (if
> any) before working towards gifting this code to the apache foundation as a
> starting point for this plugin.
>
> Also, as mentioned in the conversation above, it would be preferable if
> this plugin had a unique and easily searchable name. Does anyone have
> ideas?
> I have no good ideas; here are some uninspired options:
>
> FreeGenerator
> FMGenerator
> FMGen
> fmg
> fmgen
> FMarkerGen
> MarkerGen
> MGen
> MGenerator
>
>
> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
>
>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
>> wrote:
>> ...snip...
>> > Without an ASF account the contributors couldn't edit the Wiki page.
>> > If *they* open a JIRA issue, then we all can edit it. So that's what I
>> > recommend.
>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
>> and we can edit its description together there.
>>
>> ...snip...
>> > This was my intent from the beginning. A generator file can be a
>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
>> > that's transformed by a templates/myxmltransformat.ftl). They are
>> > totally unrelated, independent generator files. I have never assumed
>> > that they come in pairs, hence there was never a such thing as "ftl
>> > only generator" in my head either. All generator files are lonely.
>> That's clear now. I think I made an unnecessary confusion by using
>> 'ftl-only' generator when mentioning .ftl type generator.
>> Thanks!
>>
>> Woonsan
>>
>
>
> --
> Benjamin Grant Jackson
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Great, thanks!
Guys, can we do this like with freemarker-online-tester, i.e., we
create a git repo, put LICENSE and NOTICE into it, then Oath Inc.
signs a CCLA with the employees involved listed, then they replace the
copyright headers and rename the package in their repo, and do a PR,
and we accept the PR, and done. I would still ping legal of course
(someone else?).
Or, we go down on the heavy handed path, with SGA-s and who knows
what? I hope not, as this is young, and small project (there's no much
IP clearance work to do, no history to untangle).
Ben, on your side (Oath Inc.), it would be good if it's kept track
tightly who have contributed to the code, because of the paper work.
(Like I hope on Github nobody will pop up with a PR suddenly. (: ) Are
they all employees of Oath Inc., and did the work as such?
As of the project name, see other mail. (I would add that I prefer a
name that is generic enough to be not (easily...) seen as a
trademark.)
Thursday, September 6, 2018, 6:14:06 PM, Ben Jackson wrote:
> Here is the existing codebase for this project.
>
> https://github.com/yahoo/freemarker-maven-plugin
>
> It seemed more straightforward to work through our opensource team to
> publish the code so that it could be reviewed before continuing this
> conversation. Please comment on any remediations you see as needed (if
> any) before working towards gifting this code to the apache foundation as a
> starting point for this plugin.
>
> Also, as mentioned in the conversation above, it would be preferable if
> this plugin had a unique and easily searchable name. Does anyone have
> ideas?
> I have no good ideas; here are some uninspired options:
>
> FreeGenerator
> FMGenerator
> FMGen
> fmg
> fmgen
> FMarkerGen
> MarkerGen
> MGen
> MGenerator
>
>
> On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
>
>> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
>> wrote:
>> ...snip...
>> > Without an ASF account the contributors couldn't edit the Wiki page.
>> > If *they* open a JIRA issue, then we all can edit it. So that's what I
>> > recommend.
>> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
>> and we can edit its description together there.
>>
>> ...snip...
>> > This was my intent from the beginning. A generator file can be a
>> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
>> > that's transformed by a templates/myxmltransformat.ftl). They are
>> > totally unrelated, independent generator files. I have never assumed
>> > that they come in pairs, hence there was never a such thing as "ftl
>> > only generator" in my head either. All generator files are lonely.
>> That's clear now. I think I made an unnecessary confusion by using
>> 'ftl-only' generator when mentioning .ftl type generator.
>> Thanks!
>>
>> Woonsan
>>
>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
Here is the existing codebase for this project.
https://github.com/yahoo/freemarker-maven-plugin
It seemed more straightforward to work through our opensource team to
publish the code so that it could be reviewed before continuing this
conversation. Please comment on any remediations you see as needed (if
any) before working towards gifting this code to the apache foundation as a
starting point for this plugin.
Also, as mentioned in the conversation above, it would be preferable if
this plugin had a unique and easily searchable name. Does anyone have
ideas?
I have no good ideas; here are some uninspired options:
FreeGenerator
FMGenerator
FMGen
fmg
fmgen
FMarkerGen
MarkerGen
MGen
MGenerator
On Mon, Aug 20, 2018 at 10:05 AM Woonsan Ko <wo...@apache.org> wrote:
> On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org>
> wrote:
> ...snip...
> > Without an ASF account the contributors couldn't edit the Wiki page.
> > If *they* open a JIRA issue, then we all can edit it. So that's what I
> > recommend.
> Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
> and we can edit its description together there.
>
> ...snip...
> > This was my intent from the beginning. A generator file can be a
> > .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
> > that's transformed by a templates/myxmltransformat.ftl). They are
> > totally unrelated, independent generator files. I have never assumed
> > that they come in pairs, hence there was never a such thing as "ftl
> > only generator" in my head either. All generator files are lonely.
> That's clear now. I think I made an unnecessary confusion by using
> 'ftl-only' generator when mentioning .ftl type generator.
> Thanks!
>
> Woonsan
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Mon, Aug 20, 2018 at 10:15 AM, Daniel Dekany <dd...@apache.org> wrote:
...snip...
> Without an ASF account the contributors couldn't edit the Wiki page.
> If *they* open a JIRA issue, then we all can edit it. So that's what I
> recommend.
Makes sense to me. We can wait for Ben/Mark to create a JIRA ticket
and we can edit its description together there.
...snip...
> This was my intent from the beginning. A generator file can be a
> .json, or an .ftl[h|x] (or whatever we come up with later, like an xml
> that's transformed by a templates/myxmltransformat.ftl). They are
> totally unrelated, independent generator files. I have never assumed
> that they come in pairs, hence there was never a such thing as "ftl
> only generator" in my head either. All generator files are lonely.
That's clear now. I think I made an unnecessary confusion by using
'ftl-only' generator when mentioning .ftl type generator.
Thanks!
Woonsan
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Monday, August 20, 2018, 3:18:20 PM, Woonsan Ko wrote:
> On Sat, Aug 18, 2018 at 7:30 PM, Daniel Dekany <dd...@apache.org> wrote:
>> Saturday, August 18, 2018, 7:19:43 PM, Woonsan Ko wrote:
>>
>>> On Fri, Aug 17, 2018 at 6:35 PM, Daniel Dekany <dd...@apache.org> wrote:
>>>> Friday, August 17, 2018, 7:11:33 PM, Woonsan Ko wrote:
>> [snip]
>>> Perhaps we can start simply with <sharedDataModel>, <file>, and
>>> <mavenProperties> (as Ben and Mark has used it) only in the 1st phase.
>>> We can extend it like what you said in the next phases.
>>
>> Sure. It's just that the original architecture should be compatible
>> with the fancier things we are talking about.
> Right.
>
>>
>> [snip]
>>>> That's new approach. Let's see...
>>>
>>> Yeah, that's something we can consider later, indeed. Not in the 1st phase.
>>
>> It's better to know fundamental things like this (how generators work)
>> ahead.
> Right.
> Perhaps we can describe the 'variability' in the next phases from
> architectural perspective somewhere.
> Do we have a wiki?
Yes: https://cwiki.apache.org/confluence/display/FREEMARKER/
> I think wiki is a better place to put all the
> product/architecture descriptions than JIRA tickets. What do you
> think?
Without an ASF account the contributors couldn't edit the Wiki page.
If *they* open a JIRA issue, then we all can edit it. So that's what I
recommend.
>>>> What if you have Foo.java.json and Foo.java.xml? I assume that's an
>>>> error. So if Foo.java.flt is just a generator, and Foo.java.json is
>>>> just a generator, and yet you can pair them, while you can't pair json
>>>> with xml. That makes .ftl generators special.
>>>>
>>>> Also it makes the meaning of templates/ more foggy, since in your
>>>> example Foo.java.ftl is exactly the kind of template that you would
>>>> put into templates/. As you have stated that too.
>>>>
>>>> Also, in principle nothing should stop a generator ftl to specify its
>>>> own data-model. It could specify to the data-model via <#ftl
>>>> attributes={ 'dataModel': ... }>. That's a situation where a json pair
>>>> is strange.
>>>>
>>>> So to me this approach makes the roles of files less clear. But, the
>>>> question is if this approach has practical value. Like is there a
>>>> known usage scenario where you need a lot of data-models, each with a
>>>> specific template that's not used for anything else? What other use
>>>> cases are there where you could utilize this generalization?
>>>
>>> I originally thought this .ftl generator only approach could have a
>>> value (like the velocity maven plugin I referred to before), but now I
>>> realize that as we already have a different directory structure with
>>> separate ones (generator, template, data) already, .ftl generator only
>>> approach doesn't make any sense.
>>> I'm fine without it.
>>
>> I'm confused. What do you mean by ".ftl generator only approach"?
> What I thought was as follows: Optionally they can put only .ftl
> files in the generators directory. e.g,
> src/main/freemarker-generator/generators/.../Foo.java.ftl. Then even
> if they don't have .json, the system would scan the .ftl only
> generator to produce output(s). Just freely write .ftl files
> separately to output file(s). Of course this .ftl file can include
> or import from others in *template* directory. As you pointed out,
> they can define data models in the .ftl only generator files as
> well.
This was my intent from the beginning. A generator file can be a
.json, or an .ftl[h|x] (or whatever we come up with later, like an xml
that's transformed by a templates/myxmltransformat.ftl). They are
totally unrelated, independent generator files. I have never assumed
that they come in pairs, hence there was never a such thing as "ftl
only generator" in my head either. All generator files are lonely.
> I thought this might be helpful to some use cases, and it works
> similarly to how the velocity plugin [1] works.
>
> [1] https://github.com/nativelibs4java/maven-velocity-plugin
>
>> Because, I definitely think that ftl files as generators are useful.
>> It's a common way of generating files (like when you generate a home
>> page that consist of a bunch of files with different structure). So is
>> what the json generators do currently, but it's an approach useful in
>> different applications. My point is that we can support both and still
>> have simple/consistent tool. (Your idea is like if you somehow combine
>> together the files with common extensionless-name, to form a single
>> generator, which is maybe smart, but I believe it's also harder to
>> grasp, so I wanted to see the practical application.)
> I described what I was thinking above. Would it be a problematic to support?
> While describing it again, I've realized that it is still better to
> put the .ftl only generator files under the generators directory while
> any included/imported .ftl templates should be in templates directory.
> Otherwise, the scanning might be problematic.
Each file in "generators/" will be processed to generate output files,
so yes, non-generator files don't go into "generators/".
> Thanks for your elaborations!
>
> Woonsan
>
>>
>>> @Ben / @Mark, what do you think? Would these
>>> generalization/improvements be acceptable to you?
>>>
>>> Regards,
>>>
>>> Woonsan
>>>
>>>>
>>>>> - The output file name is taken after removing the generator file
>>>>> extension (.json or .xml), so it can be applied to various cases. e.g,
>>>>> .../foo.html.json, .../foo.js.json, or even .../foo.json.json.
>>>>>
>>>>> ## AFG Core Module
>>>>>
>>>>> As the features can be useful to any other tools or environments, the
>>>>> generic feature should be implemented in a separate core module,
>>>>> without depending on Maven directly.
>>>>> Maven Plugin submodule or any others depend on this core module.
>>>>>
>>>>> -----
>>>>>
>>>>> Perhaps I missed some details and you guys have some different tastes
>>>>> or flavors on each, but I've tried to capture all the high level
>>>>> features. ;-)
>>>>> Please correct anything if I'm wrong in conceptual level or in detail level.
>>>>> Also, if we come to a consensus in high level about the features,
>>>>> perhaps we can move the feature list/descriptions to a JIRA ticket and
>>>>> its description.
>>>>>
>>>>> What do you think?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Woonsan
>>>>>
>>>>>
>>>>> On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
>>>>>> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>>>>>>
>>>>>>> I think I understand your idea about templates being in both locations, and
>>>>>>> I think it is a reasonable approach.
>>>>>>>
>>>>>>> My thought is that in the case that you have multiple data models, it would
>>>>>>> probably be clearer to have all of the templates one directory and bind
>>>>>>> them to the appropriate data model explicitly.
>>>>>>
>>>>>> All of the templates? No, I certainly want to keep generator/
>>>>>> templates and dependency templates (those in templates/ at the moment)
>>>>>> clearly separated. The primary consideration when choosing the
>>>>>> directory should be the *role* of the files there, not their format.
>>>>>> That generator files can be json-s and ftl-s, and there can be
>>>>>> dependencies of generator files which happen to be also ftl-s is just
>>>>>> a coincidence. Looking at it from another angle, I think it's good if
>>>>>> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
>>>>>> else, then you know that you will have foo.txt and bar.txt in your
>>>>>> output directory. If now there you will also see some-dependency.ftl,
>>>>>> and it won't generate "some-dependency", that's confusing (plus how
>>>>>> will even the plugin know if that's not a generator file).
>>>>>>
>>>>>> As of the data-model, the most comment case when using FreeMarker is
>>>>>> to have a different data-model, per template, and even per execution
>>>>>> (as variables change over time). It's also normal that data-models
>>>>>> have common parts, like applications-scope variables or commonly
>>>>>> utilities. (There's even a Configuration setting for that, called
>>>>>> sharedVariables, but you might chose to make you data-model layered
>>>>>> otherwise). So, I perceive it as completely normal that there's a
>>>>>> shared part of the data-model, and some generator files add their own
>>>>>> layer over that. BTW, this is also what the current version does, only
>>>>>> the shared part of the data-model is fixed to that variable that holds
>>>>>> the Maven properties.
>>>>>>
>>>>>>> And in the case that you have a single data model, you could provide this
>>>>>>> shortcut to not needing to bind it explicitly to all of your templates
>>>>>>> through some configuration option. And in this case, there wouldn't be the
>>>>>>> need to have the templates in the generator directory.
>>>>>>
>>>>>> Ah, I see, you mean there should be a json, that doesn't specify a
>>>>>> data-model, and points to the template. That's conceptually the
>>>>>> cleanest, but that problem is that if your main use case is like in
>>>>>> FMPP, it's annoying to the level that you practically don't support
>>>>>> that use case.
>>>>>>
>>>>>>> The consistent aspect of that approach is that the templates are always in
>>>>>>> the /templates directory,
>>>>>>
>>>>>> That "rhymes", but I don't think should be a goal in itself... We just
>>>>>> low to use ftl-s for all kind of different purposes around here. :)
>>>>>>
>>>>>>> and a "generator" has a consistent definition of
>>>>>>> a configuration file that binds a data model to a template.
>>>>>>
>>>>>> Yeah, but you can see it as if that binding is sometimes implicit. You
>>>>>> can see an quick example of that in the FMPP page linked earlier...
>>>>>> where the red lines fork out.
>>>>>>
>>>>>>> The consistent aspect of the templates in the generator directory approach
>>>>>>> is that things that generate files are always in the same location (the
>>>>>>> generators directory), and we could enforce the property that one source
>>>>>>> file is generated for every file in the generators directory.
>>>>>>
>>>>>> I agree with that, but it's not against putting *generator* ftl-s into
>>>>>> generators/.
>>>>>>
>>>>>> Actually... there's a frequent use case where you want to generate
>>>>>> output files based on the content of the data-model. See this:
>>>>>> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
>>>>>> approach still remains true.
>>>>>>
>>>>>>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>>>>>>
>>>>>>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>>>>>>
>>>>>>>> > Here is my summary of the conversation and my take on it.
>>>>>>>> >
>>>>>>>> > There are two primary use cases discussed in the thread.
>>>>>>>> >
>>>>>>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>>>>>>> > models"). This was our use case.
>>>>>>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>>>>>>> > model"
>>>>>>>> >
>>>>>>>> > So how to best bring together the "data model" and the "template" to fit
>>>>>>>> > these use cases with minimal overhead?
>>>>>>>> > There is the generic way which is to list out all of the templates and
>>>>>>>> data
>>>>>>>> > models in separate locations, and then to bring together the templates
>>>>>>>> and
>>>>>>>> > data models via some configuration. In this world, a structure might be:
>>>>>>>> >
>>>>>>>> > (@daniel you seem concerend by the default location being
>>>>>>>> /src/main/freemarker,
>>>>>>>> > do you have a better idea in mind?)
>>>>>>>>
>>>>>>>> My approach is that this is a product, and products has a somewhat
>>>>>>>> unique (basically means searchable) name. Calling this just the
>>>>>>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>>>>>>> starters, it's functionality is not very much Maven specific, so it
>>>>>>>> might as well will be callable from Gradle, or directly from command
>>>>>>>> line (if you modularize it like that). Also there are a few other
>>>>>>>> FreeMarker Maven Plugins, which makes searching for related content on
>>>>>>>> the web hard. If we have a product name, then it's also obvious what
>>>>>>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>>>>>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>>>>>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>>>>>>> what that does.
>>>>>>>>
>>>>>>>> > /src/main/generated/freemarker/dataModels - data models
>>>>>>>> > /src/main/generated/freemarker/templates - freemarker templates
>>>>>>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>>>>>>
>>>>>>>> Note that it wasn't the structure I have suggested, just in case you
>>>>>>>> (or someone) have missed that. What I said that for case #2, you
>>>>>>>> simply put templates into generators/. And of course you can have both
>>>>>>>> ftl and json files inside generators/, each generating its output file
>>>>>>>> in its own way.
>>>>>>>>
>>>>>>>> As of dataModel-s, the part of the content the json files is also part
>>>>>>>> of the data-model, so it's not the best name. It's rather
>>>>>>>> "shared-dataModel", and in case you specify that directly in the
>>>>>>>> pom.xml, you don't even need that. And of course, we are talking about
>>>>>>>> a layered data-model, where there's a shared data model that's visible
>>>>>>>> from everywhere, and it the case of a json generator file it can adds
>>>>>>>> another layer on top of that.
>>>>>>>>
>>>>>>>> > The issue with this more generic structure is that in exchange for this
>>>>>>>> > flexibility, you might have a bunch of extra files. For example, in the
>>>>>>>> > special case #2, one needs twice as many files in the above structure.
>>>>>>>> >
>>>>>>>> > So instead of the above structure, the suggestion in the thread is to
>>>>>>>> embed
>>>>>>>> > both of the common use cases into the plugin in a way that they "play
>>>>>>>> nice"
>>>>>>>> > together.
>>>>>>>> > Create a generators directory and have the plugin interpret how to
>>>>>>>> generate
>>>>>>>> > the source based on the type of thing in that directory.
>>>>>>>> >
>>>>>>>> > I think that we could instead ask how we might deviate from the above
>>>>>>>> > generic structure that allows a many-to-many mapping while reusing both
>>>>>>>> > data models
>>>>>>>> > and templates in such a way that the two special cases can be naturally
>>>>>>>> > supported.
>>>>>>>> >
>>>>>>>> > The first enhancement is that a generator could optionally embed the data
>>>>>>>> > model. This handles case #1 if you do not want
>>>>>>>> > to reuse data models. It also naturally comes from enhancing the
>>>>>>>> > json structure in the way that Daniel suggested:
>>>>>>>> >
>>>>>>>> > {
>>>>>>>> > "templateName": "foo.ftl",
>>>>>>>> > "otherFutureMavenPluginKey": "something",
>>>>>>>> > "dataModel": {
>>>>>>>> > /* your application-specific stuff */
>>>>>>>> > "myString": "a string",
>>>>>>>> > "myNumber": 1,
>>>>>>>> > ...
>>>>>>>> > }
>>>>>>>> > }
>>>>>>>> >
>>>>>>>> > Here the other option would be for "dataModel" to refer to a file in the
>>>>>>>> > "dataModel" directory.
>>>>>>>>
>>>>>>>> Sure that's a more generic solution. Though usually you don't want to
>>>>>>>> use a json generator file if you don't want a data-model that's
>>>>>>>> specific to that generator file.
>>>>>>>>
>>>>>>>> > I would say that instead of overloading the "generators" directory to
>>>>>>>> also
>>>>>>>> > include templates,
>>>>>>>>
>>>>>>>> To clarify, there are templates in the templates\ directory, and then
>>>>>>>> there can be templates in the generator/ directory. They are
>>>>>>>> completely separate matters. In the 2nd case, they are just a type of
>>>>>>>> a generator files, like json-s are.
>>>>>>>>
>>>>>>>> > we allow the plugin to operate in an alternate mode,
>>>>>>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>>>>>>> In
>>>>>>>> > this mode, we generate sources for all templates in the template
>>>>>>>> directory
>>>>>>>> > from a common data model.
>>>>>>>>
>>>>>>>> My idea was that the we only ever generate output files for what's in
>>>>>>>> the generator directory. There can be files both in generators/ and
>>>>>>>> templates/, but hey have a different role. Templates in templates/ are
>>>>>>>> just dependencies of some generators/ (the jsons, in this case), or
>>>>>>>> maybe they can be #import-ed from templates in generators/.
>>>>>>>>
>>>>>>>> > In this use case, the project would only use
>>>>>>>> > this structure only:
>>>>>>>> >
>>>>>>>> > /src/main/generated/freemarker/dataModel.xml
>>>>>>>>
>>>>>>>> NYW, I think for a dataModel it's important that it can come from
>>>>>>>> various places, like even from a database. So we should keep that in
>>>>>>>> mind.
>>>>>>>>
>>>>>>>> > /src/main/generated/freemarker/templates/...
>>>>>>>> >
>>>>>>>> > Having said all of this, I think the changes we would make in the short
>>>>>>>> > term would be to update the json structure to include the dataModel as a
>>>>>>>> > subtree, and to change the default locations to use the /generated
>>>>>>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>>>>>>> >
>>>>>>>> > -Ben
>>>>>>>> >
>>>>>>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>>>>>>> wrote:
>>>>>>>> >
>>>>>>>> >> Yes, this makes sense.
>>>>>>>> >>
>>>>>>>> >> -Ben
>>>>>>>> >>
>>>>>>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>>>>>>> wrote:
>>>>>>>> >>
>>>>>>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>>>>>> >>>
>>>>>>>> >>> [snip]
>>>>>>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>>>>>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>>>>>>> >>> view
>>>>>>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>>>>>>> >>> with
>>>>>>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>>>>>>> >>> supports
>>>>>>>> >>> > my main use case.
>>>>>>>> >>> [snip]
>>>>>>>> >>>
>>>>>>>> >>> The problem with that is that it doesn't work if you happen to need a
>>>>>>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>>>>>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>>>>>>> solution
>>>>>>>> >>> is like this:
>>>>>>>> >>>
>>>>>>>> >>> {
>>>>>>>> >>> "templateName": "foo.ftl",
>>>>>>>> >>> "otherFutureMavenPluginKey": "something",
>>>>>>>> >>> "dataModel": {
>>>>>>>> >>> /* your application-specific stuff */
>>>>>>>> >>> "myString": "a string",
>>>>>>>> >>> "myNumber": 1,
>>>>>>>> >>> ...
>>>>>>>> >>> }
>>>>>>>> >>> }
>>>>>>>> >>>
>>>>>>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>>>>>>> >>> without breaking backward compatibility.
>>>>>>>> >>>
>>>>>>>> >>> --
>>>>>>>> >>> Thanks,
>>>>>>>> >>> Daniel Dekany
>>>>>>>> >>>
>>>>>>>> >>>
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >> --
>>>>>>>> >> Benjamin Grant Jackson
>>>>>>>> >>
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>>
>>>>>>>> --
>>>>>>>> Thanks,
>>>>>>>> Daniel Dekany
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Thanks,
>>>>>> Daniel Dekany
>>>>>>
>>>>>
>>>>
>>>> --
>>>> Thanks,
>>>> Daniel Dekany
>>>>
>>>
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Sat, Aug 18, 2018 at 7:30 PM, Daniel Dekany <dd...@apache.org> wrote:
> Saturday, August 18, 2018, 7:19:43 PM, Woonsan Ko wrote:
>
>> On Fri, Aug 17, 2018 at 6:35 PM, Daniel Dekany <dd...@apache.org> wrote:
>>> Friday, August 17, 2018, 7:11:33 PM, Woonsan Ko wrote:
> [snip]
>> Perhaps we can start simply with <sharedDataModel>, <file>, and
>> <mavenProperties> (as Ben and Mark has used it) only in the 1st phase.
>> We can extend it like what you said in the next phases.
>
> Sure. It's just that the original architecture should be compatible
> with the fancier things we are talking about.
Right.
>
> [snip]
>>> That's new approach. Let's see...
>>
>> Yeah, that's something we can consider later, indeed. Not in the 1st phase.
>
> It's better to know fundamental things like this (how generators work)
> ahead.
Right.
Perhaps we can describe the 'variability' in the next phases from
architectural perspective somewhere.
Do we have a wiki? I think wiki is a better place to put all the
product/architecture descriptions than JIRA tickets. What do you
think?
>
>>> What if you have Foo.java.json and Foo.java.xml? I assume that's an
>>> error. So if Foo.java.flt is just a generator, and Foo.java.json is
>>> just a generator, and yet you can pair them, while you can't pair json
>>> with xml. That makes .ftl generators special.
>>>
>>> Also it makes the meaning of templates/ more foggy, since in your
>>> example Foo.java.ftl is exactly the kind of template that you would
>>> put into templates/. As you have stated that too.
>>>
>>> Also, in principle nothing should stop a generator ftl to specify its
>>> own data-model. It could specify to the data-model via <#ftl
>>> attributes={ 'dataModel': ... }>. That's a situation where a json pair
>>> is strange.
>>>
>>> So to me this approach makes the roles of files less clear. But, the
>>> question is if this approach has practical value. Like is there a
>>> known usage scenario where you need a lot of data-models, each with a
>>> specific template that's not used for anything else? What other use
>>> cases are there where you could utilize this generalization?
>>
>> I originally thought this .ftl generator only approach could have a
>> value (like the velocity maven plugin I referred to before), but now I
>> realize that as we already have a different directory structure with
>> separate ones (generator, template, data) already, .ftl generator only
>> approach doesn't make any sense.
>> I'm fine without it.
>
> I'm confused. What do you mean by ".ftl generator only approach"?
What I thought was as follows:
Optionally they can put only .ftl files in the generators directory.
e.g, src/main/freemarker-generator/generators/.../Foo.java.ftl.
Then even if they don't have .json, the system would scan the .ftl
only generator to produce output(s). Just freely write .ftl files
separately to output file(s).
Of course this .ftl file can include or import from others in
*template* directory. As you pointed out, they can define data models
in the .ftl only generator files as well.
I thought this might be helpful to some use cases, and it works
similarly to how the velocity plugin [1] works.
[1] https://github.com/nativelibs4java/maven-velocity-plugin
> Because, I definitely think that ftl files as generators are useful.
> It's a common way of generating files (like when you generate a home
> page that consist of a bunch of files with different structure). So is
> what the json generators do currently, but it's an approach useful in
> different applications. My point is that we can support both and still
> have simple/consistent tool. (Your idea is like if you somehow combine
> together the files with common extensionless-name, to form a single
> generator, which is maybe smart, but I believe it's also harder to
> grasp, so I wanted to see the practical application.)
I described what I was thinking above. Would it be a problematic to support?
While describing it again, I've realized that it is still better to
put the .ftl only generator files under the generators directory while
any included/imported .ftl templates should be in templates directory.
Otherwise, the scanning might be problematic.
Thanks for your elaborations!
Woonsan
>
>> @Ben / @Mark, what do you think? Would these
>> generalization/improvements be acceptable to you?
>>
>> Regards,
>>
>> Woonsan
>>
>>>
>>>> - The output file name is taken after removing the generator file
>>>> extension (.json or .xml), so it can be applied to various cases. e.g,
>>>> .../foo.html.json, .../foo.js.json, or even .../foo.json.json.
>>>>
>>>> ## AFG Core Module
>>>>
>>>> As the features can be useful to any other tools or environments, the
>>>> generic feature should be implemented in a separate core module,
>>>> without depending on Maven directly.
>>>> Maven Plugin submodule or any others depend on this core module.
>>>>
>>>> -----
>>>>
>>>> Perhaps I missed some details and you guys have some different tastes
>>>> or flavors on each, but I've tried to capture all the high level
>>>> features. ;-)
>>>> Please correct anything if I'm wrong in conceptual level or in detail level.
>>>> Also, if we come to a consensus in high level about the features,
>>>> perhaps we can move the feature list/descriptions to a JIRA ticket and
>>>> its description.
>>>>
>>>> What do you think?
>>>>
>>>> Regards,
>>>>
>>>> Woonsan
>>>>
>>>>
>>>> On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
>>>>> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>>>>>
>>>>>> I think I understand your idea about templates being in both locations, and
>>>>>> I think it is a reasonable approach.
>>>>>>
>>>>>> My thought is that in the case that you have multiple data models, it would
>>>>>> probably be clearer to have all of the templates one directory and bind
>>>>>> them to the appropriate data model explicitly.
>>>>>
>>>>> All of the templates? No, I certainly want to keep generator/
>>>>> templates and dependency templates (those in templates/ at the moment)
>>>>> clearly separated. The primary consideration when choosing the
>>>>> directory should be the *role* of the files there, not their format.
>>>>> That generator files can be json-s and ftl-s, and there can be
>>>>> dependencies of generator files which happen to be also ftl-s is just
>>>>> a coincidence. Looking at it from another angle, I think it's good if
>>>>> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
>>>>> else, then you know that you will have foo.txt and bar.txt in your
>>>>> output directory. If now there you will also see some-dependency.ftl,
>>>>> and it won't generate "some-dependency", that's confusing (plus how
>>>>> will even the plugin know if that's not a generator file).
>>>>>
>>>>> As of the data-model, the most comment case when using FreeMarker is
>>>>> to have a different data-model, per template, and even per execution
>>>>> (as variables change over time). It's also normal that data-models
>>>>> have common parts, like applications-scope variables or commonly
>>>>> utilities. (There's even a Configuration setting for that, called
>>>>> sharedVariables, but you might chose to make you data-model layered
>>>>> otherwise). So, I perceive it as completely normal that there's a
>>>>> shared part of the data-model, and some generator files add their own
>>>>> layer over that. BTW, this is also what the current version does, only
>>>>> the shared part of the data-model is fixed to that variable that holds
>>>>> the Maven properties.
>>>>>
>>>>>> And in the case that you have a single data model, you could provide this
>>>>>> shortcut to not needing to bind it explicitly to all of your templates
>>>>>> through some configuration option. And in this case, there wouldn't be the
>>>>>> need to have the templates in the generator directory.
>>>>>
>>>>> Ah, I see, you mean there should be a json, that doesn't specify a
>>>>> data-model, and points to the template. That's conceptually the
>>>>> cleanest, but that problem is that if your main use case is like in
>>>>> FMPP, it's annoying to the level that you practically don't support
>>>>> that use case.
>>>>>
>>>>>> The consistent aspect of that approach is that the templates are always in
>>>>>> the /templates directory,
>>>>>
>>>>> That "rhymes", but I don't think should be a goal in itself... We just
>>>>> low to use ftl-s for all kind of different purposes around here. :)
>>>>>
>>>>>> and a "generator" has a consistent definition of
>>>>>> a configuration file that binds a data model to a template.
>>>>>
>>>>> Yeah, but you can see it as if that binding is sometimes implicit. You
>>>>> can see an quick example of that in the FMPP page linked earlier...
>>>>> where the red lines fork out.
>>>>>
>>>>>> The consistent aspect of the templates in the generator directory approach
>>>>>> is that things that generate files are always in the same location (the
>>>>>> generators directory), and we could enforce the property that one source
>>>>>> file is generated for every file in the generators directory.
>>>>>
>>>>> I agree with that, but it's not against putting *generator* ftl-s into
>>>>> generators/.
>>>>>
>>>>> Actually... there's a frequent use case where you want to generate
>>>>> output files based on the content of the data-model. See this:
>>>>> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
>>>>> approach still remains true.
>>>>>
>>>>>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>>>>>
>>>>>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>>>>>
>>>>>>> > Here is my summary of the conversation and my take on it.
>>>>>>> >
>>>>>>> > There are two primary use cases discussed in the thread.
>>>>>>> >
>>>>>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>>>>>> > models"). This was our use case.
>>>>>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>>>>>> > model"
>>>>>>> >
>>>>>>> > So how to best bring together the "data model" and the "template" to fit
>>>>>>> > these use cases with minimal overhead?
>>>>>>> > There is the generic way which is to list out all of the templates and
>>>>>>> data
>>>>>>> > models in separate locations, and then to bring together the templates
>>>>>>> and
>>>>>>> > data models via some configuration. In this world, a structure might be:
>>>>>>> >
>>>>>>> > (@daniel you seem concerend by the default location being
>>>>>>> /src/main/freemarker,
>>>>>>> > do you have a better idea in mind?)
>>>>>>>
>>>>>>> My approach is that this is a product, and products has a somewhat
>>>>>>> unique (basically means searchable) name. Calling this just the
>>>>>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>>>>>> starters, it's functionality is not very much Maven specific, so it
>>>>>>> might as well will be callable from Gradle, or directly from command
>>>>>>> line (if you modularize it like that). Also there are a few other
>>>>>>> FreeMarker Maven Plugins, which makes searching for related content on
>>>>>>> the web hard. If we have a product name, then it's also obvious what
>>>>>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>>>>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>>>>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>>>>>> what that does.
>>>>>>>
>>>>>>> > /src/main/generated/freemarker/dataModels - data models
>>>>>>> > /src/main/generated/freemarker/templates - freemarker templates
>>>>>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>>>>>
>>>>>>> Note that it wasn't the structure I have suggested, just in case you
>>>>>>> (or someone) have missed that. What I said that for case #2, you
>>>>>>> simply put templates into generators/. And of course you can have both
>>>>>>> ftl and json files inside generators/, each generating its output file
>>>>>>> in its own way.
>>>>>>>
>>>>>>> As of dataModel-s, the part of the content the json files is also part
>>>>>>> of the data-model, so it's not the best name. It's rather
>>>>>>> "shared-dataModel", and in case you specify that directly in the
>>>>>>> pom.xml, you don't even need that. And of course, we are talking about
>>>>>>> a layered data-model, where there's a shared data model that's visible
>>>>>>> from everywhere, and it the case of a json generator file it can adds
>>>>>>> another layer on top of that.
>>>>>>>
>>>>>>> > The issue with this more generic structure is that in exchange for this
>>>>>>> > flexibility, you might have a bunch of extra files. For example, in the
>>>>>>> > special case #2, one needs twice as many files in the above structure.
>>>>>>> >
>>>>>>> > So instead of the above structure, the suggestion in the thread is to
>>>>>>> embed
>>>>>>> > both of the common use cases into the plugin in a way that they "play
>>>>>>> nice"
>>>>>>> > together.
>>>>>>> > Create a generators directory and have the plugin interpret how to
>>>>>>> generate
>>>>>>> > the source based on the type of thing in that directory.
>>>>>>> >
>>>>>>> > I think that we could instead ask how we might deviate from the above
>>>>>>> > generic structure that allows a many-to-many mapping while reusing both
>>>>>>> > data models
>>>>>>> > and templates in such a way that the two special cases can be naturally
>>>>>>> > supported.
>>>>>>> >
>>>>>>> > The first enhancement is that a generator could optionally embed the data
>>>>>>> > model. This handles case #1 if you do not want
>>>>>>> > to reuse data models. It also naturally comes from enhancing the
>>>>>>> > json structure in the way that Daniel suggested:
>>>>>>> >
>>>>>>> > {
>>>>>>> > "templateName": "foo.ftl",
>>>>>>> > "otherFutureMavenPluginKey": "something",
>>>>>>> > "dataModel": {
>>>>>>> > /* your application-specific stuff */
>>>>>>> > "myString": "a string",
>>>>>>> > "myNumber": 1,
>>>>>>> > ...
>>>>>>> > }
>>>>>>> > }
>>>>>>> >
>>>>>>> > Here the other option would be for "dataModel" to refer to a file in the
>>>>>>> > "dataModel" directory.
>>>>>>>
>>>>>>> Sure that's a more generic solution. Though usually you don't want to
>>>>>>> use a json generator file if you don't want a data-model that's
>>>>>>> specific to that generator file.
>>>>>>>
>>>>>>> > I would say that instead of overloading the "generators" directory to
>>>>>>> also
>>>>>>> > include templates,
>>>>>>>
>>>>>>> To clarify, there are templates in the templates\ directory, and then
>>>>>>> there can be templates in the generator/ directory. They are
>>>>>>> completely separate matters. In the 2nd case, they are just a type of
>>>>>>> a generator files, like json-s are.
>>>>>>>
>>>>>>> > we allow the plugin to operate in an alternate mode,
>>>>>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>>>>>> In
>>>>>>> > this mode, we generate sources for all templates in the template
>>>>>>> directory
>>>>>>> > from a common data model.
>>>>>>>
>>>>>>> My idea was that the we only ever generate output files for what's in
>>>>>>> the generator directory. There can be files both in generators/ and
>>>>>>> templates/, but hey have a different role. Templates in templates/ are
>>>>>>> just dependencies of some generators/ (the jsons, in this case), or
>>>>>>> maybe they can be #import-ed from templates in generators/.
>>>>>>>
>>>>>>> > In this use case, the project would only use
>>>>>>> > this structure only:
>>>>>>> >
>>>>>>> > /src/main/generated/freemarker/dataModel.xml
>>>>>>>
>>>>>>> NYW, I think for a dataModel it's important that it can come from
>>>>>>> various places, like even from a database. So we should keep that in
>>>>>>> mind.
>>>>>>>
>>>>>>> > /src/main/generated/freemarker/templates/...
>>>>>>> >
>>>>>>> > Having said all of this, I think the changes we would make in the short
>>>>>>> > term would be to update the json structure to include the dataModel as a
>>>>>>> > subtree, and to change the default locations to use the /generated
>>>>>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>>>>>> >
>>>>>>> > -Ben
>>>>>>> >
>>>>>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>>>>>> wrote:
>>>>>>> >
>>>>>>> >> Yes, this makes sense.
>>>>>>> >>
>>>>>>> >> -Ben
>>>>>>> >>
>>>>>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>>>>>> wrote:
>>>>>>> >>
>>>>>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>>>>> >>>
>>>>>>> >>> [snip]
>>>>>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>>>>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>>>>>> >>> view
>>>>>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>>>>>> >>> with
>>>>>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>>>>>> >>> supports
>>>>>>> >>> > my main use case.
>>>>>>> >>> [snip]
>>>>>>> >>>
>>>>>>> >>> The problem with that is that it doesn't work if you happen to need a
>>>>>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>>>>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>>>>>> solution
>>>>>>> >>> is like this:
>>>>>>> >>>
>>>>>>> >>> {
>>>>>>> >>> "templateName": "foo.ftl",
>>>>>>> >>> "otherFutureMavenPluginKey": "something",
>>>>>>> >>> "dataModel": {
>>>>>>> >>> /* your application-specific stuff */
>>>>>>> >>> "myString": "a string",
>>>>>>> >>> "myNumber": 1,
>>>>>>> >>> ...
>>>>>>> >>> }
>>>>>>> >>> }
>>>>>>> >>>
>>>>>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>>>>>> >>> without breaking backward compatibility.
>>>>>>> >>>
>>>>>>> >>> --
>>>>>>> >>> Thanks,
>>>>>>> >>> Daniel Dekany
>>>>>>> >>>
>>>>>>> >>>
>>>>>>> >>
>>>>>>> >>
>>>>>>> >> --
>>>>>>> >> Benjamin Grant Jackson
>>>>>>> >>
>>>>>>> >
>>>>>>> >
>>>>>>> >
>>>>>>>
>>>>>>> --
>>>>>>> Thanks,
>>>>>>> Daniel Dekany
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Thanks,
>>>>> Daniel Dekany
>>>>>
>>>>
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>
>
> --
> Thanks,
> Daniel Dekany
>
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Saturday, August 18, 2018, 7:19:43 PM, Woonsan Ko wrote:
> On Fri, Aug 17, 2018 at 6:35 PM, Daniel Dekany <dd...@apache.org> wrote:
>> Friday, August 17, 2018, 7:11:33 PM, Woonsan Ko wrote:
[snip]
> Perhaps we can start simply with <sharedDataModel>, <file>, and
> <mavenProperties> (as Ben and Mark has used it) only in the 1st phase.
> We can extend it like what you said in the next phases.
Sure. It's just that the original architecture should be compatible
with the fancier things we are talking about.
[snip]
>> That's new approach. Let's see...
>
> Yeah, that's something we can consider later, indeed. Not in the 1st phase.
It's better to know fundamental things like this (how generators work)
ahead.
>> What if you have Foo.java.json and Foo.java.xml? I assume that's an
>> error. So if Foo.java.flt is just a generator, and Foo.java.json is
>> just a generator, and yet you can pair them, while you can't pair json
>> with xml. That makes .ftl generators special.
>>
>> Also it makes the meaning of templates/ more foggy, since in your
>> example Foo.java.ftl is exactly the kind of template that you would
>> put into templates/. As you have stated that too.
>>
>> Also, in principle nothing should stop a generator ftl to specify its
>> own data-model. It could specify to the data-model via <#ftl
>> attributes={ 'dataModel': ... }>. That's a situation where a json pair
>> is strange.
>>
>> So to me this approach makes the roles of files less clear. But, the
>> question is if this approach has practical value. Like is there a
>> known usage scenario where you need a lot of data-models, each with a
>> specific template that's not used for anything else? What other use
>> cases are there where you could utilize this generalization?
>
> I originally thought this .ftl generator only approach could have a
> value (like the velocity maven plugin I referred to before), but now I
> realize that as we already have a different directory structure with
> separate ones (generator, template, data) already, .ftl generator only
> approach doesn't make any sense.
> I'm fine without it.
I'm confused. What do you mean by ".ftl generator only approach"?
Because, I definitely think that ftl files as generators are useful.
It's a common way of generating files (like when you generate a home
page that consist of a bunch of files with different structure). So is
what the json generators do currently, but it's an approach useful in
different applications. My point is that we can support both and still
have simple/consistent tool. (Your idea is like if you somehow combine
together the files with common extensionless-name, to form a single
generator, which is maybe smart, but I believe it's also harder to
grasp, so I wanted to see the practical application.)
> @Ben / @Mark, what do you think? Would these
> generalization/improvements be acceptable to you?
>
> Regards,
>
> Woonsan
>
>>
>>> - The output file name is taken after removing the generator file
>>> extension (.json or .xml), so it can be applied to various cases. e.g,
>>> .../foo.html.json, .../foo.js.json, or even .../foo.json.json.
>>>
>>> ## AFG Core Module
>>>
>>> As the features can be useful to any other tools or environments, the
>>> generic feature should be implemented in a separate core module,
>>> without depending on Maven directly.
>>> Maven Plugin submodule or any others depend on this core module.
>>>
>>> -----
>>>
>>> Perhaps I missed some details and you guys have some different tastes
>>> or flavors on each, but I've tried to capture all the high level
>>> features. ;-)
>>> Please correct anything if I'm wrong in conceptual level or in detail level.
>>> Also, if we come to a consensus in high level about the features,
>>> perhaps we can move the feature list/descriptions to a JIRA ticket and
>>> its description.
>>>
>>> What do you think?
>>>
>>> Regards,
>>>
>>> Woonsan
>>>
>>>
>>> On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
>>>> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>>>>
>>>>> I think I understand your idea about templates being in both locations, and
>>>>> I think it is a reasonable approach.
>>>>>
>>>>> My thought is that in the case that you have multiple data models, it would
>>>>> probably be clearer to have all of the templates one directory and bind
>>>>> them to the appropriate data model explicitly.
>>>>
>>>> All of the templates? No, I certainly want to keep generator/
>>>> templates and dependency templates (those in templates/ at the moment)
>>>> clearly separated. The primary consideration when choosing the
>>>> directory should be the *role* of the files there, not their format.
>>>> That generator files can be json-s and ftl-s, and there can be
>>>> dependencies of generator files which happen to be also ftl-s is just
>>>> a coincidence. Looking at it from another angle, I think it's good if
>>>> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
>>>> else, then you know that you will have foo.txt and bar.txt in your
>>>> output directory. If now there you will also see some-dependency.ftl,
>>>> and it won't generate "some-dependency", that's confusing (plus how
>>>> will even the plugin know if that's not a generator file).
>>>>
>>>> As of the data-model, the most comment case when using FreeMarker is
>>>> to have a different data-model, per template, and even per execution
>>>> (as variables change over time). It's also normal that data-models
>>>> have common parts, like applications-scope variables or commonly
>>>> utilities. (There's even a Configuration setting for that, called
>>>> sharedVariables, but you might chose to make you data-model layered
>>>> otherwise). So, I perceive it as completely normal that there's a
>>>> shared part of the data-model, and some generator files add their own
>>>> layer over that. BTW, this is also what the current version does, only
>>>> the shared part of the data-model is fixed to that variable that holds
>>>> the Maven properties.
>>>>
>>>>> And in the case that you have a single data model, you could provide this
>>>>> shortcut to not needing to bind it explicitly to all of your templates
>>>>> through some configuration option. And in this case, there wouldn't be the
>>>>> need to have the templates in the generator directory.
>>>>
>>>> Ah, I see, you mean there should be a json, that doesn't specify a
>>>> data-model, and points to the template. That's conceptually the
>>>> cleanest, but that problem is that if your main use case is like in
>>>> FMPP, it's annoying to the level that you practically don't support
>>>> that use case.
>>>>
>>>>> The consistent aspect of that approach is that the templates are always in
>>>>> the /templates directory,
>>>>
>>>> That "rhymes", but I don't think should be a goal in itself... We just
>>>> low to use ftl-s for all kind of different purposes around here. :)
>>>>
>>>>> and a "generator" has a consistent definition of
>>>>> a configuration file that binds a data model to a template.
>>>>
>>>> Yeah, but you can see it as if that binding is sometimes implicit. You
>>>> can see an quick example of that in the FMPP page linked earlier...
>>>> where the red lines fork out.
>>>>
>>>>> The consistent aspect of the templates in the generator directory approach
>>>>> is that things that generate files are always in the same location (the
>>>>> generators directory), and we could enforce the property that one source
>>>>> file is generated for every file in the generators directory.
>>>>
>>>> I agree with that, but it's not against putting *generator* ftl-s into
>>>> generators/.
>>>>
>>>> Actually... there's a frequent use case where you want to generate
>>>> output files based on the content of the data-model. See this:
>>>> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
>>>> approach still remains true.
>>>>
>>>>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>>>>
>>>>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>>>>
>>>>>> > Here is my summary of the conversation and my take on it.
>>>>>> >
>>>>>> > There are two primary use cases discussed in the thread.
>>>>>> >
>>>>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>>>>> > models"). This was our use case.
>>>>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>>>>> > model"
>>>>>> >
>>>>>> > So how to best bring together the "data model" and the "template" to fit
>>>>>> > these use cases with minimal overhead?
>>>>>> > There is the generic way which is to list out all of the templates and
>>>>>> data
>>>>>> > models in separate locations, and then to bring together the templates
>>>>>> and
>>>>>> > data models via some configuration. In this world, a structure might be:
>>>>>> >
>>>>>> > (@daniel you seem concerend by the default location being
>>>>>> /src/main/freemarker,
>>>>>> > do you have a better idea in mind?)
>>>>>>
>>>>>> My approach is that this is a product, and products has a somewhat
>>>>>> unique (basically means searchable) name. Calling this just the
>>>>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>>>>> starters, it's functionality is not very much Maven specific, so it
>>>>>> might as well will be callable from Gradle, or directly from command
>>>>>> line (if you modularize it like that). Also there are a few other
>>>>>> FreeMarker Maven Plugins, which makes searching for related content on
>>>>>> the web hard. If we have a product name, then it's also obvious what
>>>>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>>>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>>>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>>>>> what that does.
>>>>>>
>>>>>> > /src/main/generated/freemarker/dataModels - data models
>>>>>> > /src/main/generated/freemarker/templates - freemarker templates
>>>>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>>>>
>>>>>> Note that it wasn't the structure I have suggested, just in case you
>>>>>> (or someone) have missed that. What I said that for case #2, you
>>>>>> simply put templates into generators/. And of course you can have both
>>>>>> ftl and json files inside generators/, each generating its output file
>>>>>> in its own way.
>>>>>>
>>>>>> As of dataModel-s, the part of the content the json files is also part
>>>>>> of the data-model, so it's not the best name. It's rather
>>>>>> "shared-dataModel", and in case you specify that directly in the
>>>>>> pom.xml, you don't even need that. And of course, we are talking about
>>>>>> a layered data-model, where there's a shared data model that's visible
>>>>>> from everywhere, and it the case of a json generator file it can adds
>>>>>> another layer on top of that.
>>>>>>
>>>>>> > The issue with this more generic structure is that in exchange for this
>>>>>> > flexibility, you might have a bunch of extra files. For example, in the
>>>>>> > special case #2, one needs twice as many files in the above structure.
>>>>>> >
>>>>>> > So instead of the above structure, the suggestion in the thread is to
>>>>>> embed
>>>>>> > both of the common use cases into the plugin in a way that they "play
>>>>>> nice"
>>>>>> > together.
>>>>>> > Create a generators directory and have the plugin interpret how to
>>>>>> generate
>>>>>> > the source based on the type of thing in that directory.
>>>>>> >
>>>>>> > I think that we could instead ask how we might deviate from the above
>>>>>> > generic structure that allows a many-to-many mapping while reusing both
>>>>>> > data models
>>>>>> > and templates in such a way that the two special cases can be naturally
>>>>>> > supported.
>>>>>> >
>>>>>> > The first enhancement is that a generator could optionally embed the data
>>>>>> > model. This handles case #1 if you do not want
>>>>>> > to reuse data models. It also naturally comes from enhancing the
>>>>>> > json structure in the way that Daniel suggested:
>>>>>> >
>>>>>> > {
>>>>>> > "templateName": "foo.ftl",
>>>>>> > "otherFutureMavenPluginKey": "something",
>>>>>> > "dataModel": {
>>>>>> > /* your application-specific stuff */
>>>>>> > "myString": "a string",
>>>>>> > "myNumber": 1,
>>>>>> > ...
>>>>>> > }
>>>>>> > }
>>>>>> >
>>>>>> > Here the other option would be for "dataModel" to refer to a file in the
>>>>>> > "dataModel" directory.
>>>>>>
>>>>>> Sure that's a more generic solution. Though usually you don't want to
>>>>>> use a json generator file if you don't want a data-model that's
>>>>>> specific to that generator file.
>>>>>>
>>>>>> > I would say that instead of overloading the "generators" directory to
>>>>>> also
>>>>>> > include templates,
>>>>>>
>>>>>> To clarify, there are templates in the templates\ directory, and then
>>>>>> there can be templates in the generator/ directory. They are
>>>>>> completely separate matters. In the 2nd case, they are just a type of
>>>>>> a generator files, like json-s are.
>>>>>>
>>>>>> > we allow the plugin to operate in an alternate mode,
>>>>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>>>>> In
>>>>>> > this mode, we generate sources for all templates in the template
>>>>>> directory
>>>>>> > from a common data model.
>>>>>>
>>>>>> My idea was that the we only ever generate output files for what's in
>>>>>> the generator directory. There can be files both in generators/ and
>>>>>> templates/, but hey have a different role. Templates in templates/ are
>>>>>> just dependencies of some generators/ (the jsons, in this case), or
>>>>>> maybe they can be #import-ed from templates in generators/.
>>>>>>
>>>>>> > In this use case, the project would only use
>>>>>> > this structure only:
>>>>>> >
>>>>>> > /src/main/generated/freemarker/dataModel.xml
>>>>>>
>>>>>> NYW, I think for a dataModel it's important that it can come from
>>>>>> various places, like even from a database. So we should keep that in
>>>>>> mind.
>>>>>>
>>>>>> > /src/main/generated/freemarker/templates/...
>>>>>> >
>>>>>> > Having said all of this, I think the changes we would make in the short
>>>>>> > term would be to update the json structure to include the dataModel as a
>>>>>> > subtree, and to change the default locations to use the /generated
>>>>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>>>>> >
>>>>>> > -Ben
>>>>>> >
>>>>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>>>>> wrote:
>>>>>> >
>>>>>> >> Yes, this makes sense.
>>>>>> >>
>>>>>> >> -Ben
>>>>>> >>
>>>>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>>>>> wrote:
>>>>>> >>
>>>>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>>>> >>>
>>>>>> >>> [snip]
>>>>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>>>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>>>>> >>> view
>>>>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>>>>> >>> with
>>>>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>>>>> >>> supports
>>>>>> >>> > my main use case.
>>>>>> >>> [snip]
>>>>>> >>>
>>>>>> >>> The problem with that is that it doesn't work if you happen to need a
>>>>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>>>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>>>>> solution
>>>>>> >>> is like this:
>>>>>> >>>
>>>>>> >>> {
>>>>>> >>> "templateName": "foo.ftl",
>>>>>> >>> "otherFutureMavenPluginKey": "something",
>>>>>> >>> "dataModel": {
>>>>>> >>> /* your application-specific stuff */
>>>>>> >>> "myString": "a string",
>>>>>> >>> "myNumber": 1,
>>>>>> >>> ...
>>>>>> >>> }
>>>>>> >>> }
>>>>>> >>>
>>>>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>>>>> >>> without breaking backward compatibility.
>>>>>> >>>
>>>>>> >>> --
>>>>>> >>> Thanks,
>>>>>> >>> Daniel Dekany
>>>>>> >>>
>>>>>> >>>
>>>>>> >>
>>>>>> >>
>>>>>> >> --
>>>>>> >> Benjamin Grant Jackson
>>>>>> >>
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>>
>>>>>> --
>>>>>> Thanks,
>>>>>> Daniel Dekany
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Thanks,
>>>> Daniel Dekany
>>>>
>>>
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
On Fri, Aug 17, 2018 at 6:35 PM, Daniel Dekany <dd...@apache.org> wrote:
> Friday, August 17, 2018, 7:11:33 PM, Woonsan Ko wrote:
>
>> Sorry for top posting, but perhaps a compact summary might help share
>> the whole picture. Let me try to do that from the discussion so far:
>>
>> -----
>>
>> # Apache FreeMarker Generator (the name is probably due to change)
>>
>> A generic module enabling to generate various types of files through
>> Apache FreeMarker templates and defined models.
>>
>> ## Concepts
>>
>> - "templates": source FreeMarker templates used in file generating processes.
>
> Also this is where one should put templates that are
> #import-ed/#include-d in other templates.
+1
>
>> - "generators": source generator definition files to be scanned, for
>> each of which an output file is created.
>
> Or multiple output files for the same generator file, if the generator
> file says so.
+1
We can discuss the detail later (perhaps in the 2nd phase) on how the
generator file (.json) can define it. 2nd phase feature, in my view.
>
>> - "output files": target output files generated.
>> - "dataModels": model objects passed to processing templates,
>> including shared dataModel and generator-specific dataModel.
>
> To clarify, generator-specific data-models can be there, but can also
> be directly inside the generator file. Also, of course we shouldn't
> have upper case letters in a standard directory name.
Not sure, but just in case, I meant only "concepts", not a directory
name by "dataModels" here.
Other than that, I think we're in the same page regarding dataModel
definitions: in either generator file as generator-specific one or in
plugin configuration as shared one.
>
>> ## Overview
>>
>> AFG (Apache FreeMarker Generator)
>
> We shouldn't abbreviate "Apache", so if we really want to abbreviate
> it, then it's "Apache FG" (which is horrid). BTW, any name of that
> kind will mean a legal name check, unlike a non-abbreviated form. /-:
Yes, the name is just an example for now, due to change in the
separate discussion.
>
>> is given "templates", "generators",
>> "output files" and "dataModels" somehow, depending on submodule
>> implementations such as Apache Maven Plugin, and generates various
>> output files based on those in intuitive rules.
>
> So the Maven hierarchy is:
>
> - freemarker-generator (packaging=pom)
> - freemarker-generator-core (packaging=jar)
> - freemarker-generator-maven (packaging=jar)
+1
>
>> ## Maven Plugin Submodule
>>
>> - Maven Plugin configurations include directory paths for "templates",
>> "generators", "output files", "globalDataModel"
>
> Shared... as in configuration.sharedVaribles.
+1
>
>> and "defaultTemplate".
>> For example (the default values are probably due to change),
>>
>> <configuration>
>> <templateDirectory>src/main/freemarker</templateDirectory>
>> <generatorDirectory>src/main/generator</generatorDirectory>
>
> By default these two should have a common plugin-specific parent.
> Like, src/main/freemarker-generator/templates,
> src/main/freemarker-generator/generators.
+1
>
>> <outputDirectory>target/generated-sources</outputDirectory>
>>
>> <globalDataModel>src/main/data/shared-data-model.json</globalDataModel
>
> By default this should also belong under the common parent directory,
> like src/main/freemarker-generator/data.
+1
>
> Also I rather imagine something like this (on the long run):
>
> <sharedDataModel>
> <file>src/main/freemarker-generator/data/shared-data-model.json</file>
> <variable name="bar">baaz ${mavenProperty}</variable>
> <file name="foos">src/main/freemarker-generator/data/foos.xml</file>
> <file name="bars">src/resources/bars.properties</file>
> <mavenProperties name="mavenProps" />
> </sharedDataModel>
+1
Perhaps we can start simply with <sharedDataModel>, <file>, and
<mavenProperties> (as Ben and Mark has used it) only in the 1st phase.
We can extend it like what you said in the next phases.
So, summarizing the maven plugin configuration, it could look like the
following in the first phase:
<configuration>
<templateDirectory>src/main/freemarker-generator/templates</templateDirectory>
<generatorDirectory>src/main/freemarker-generator/generators</generatorDirectory>
<outputDirectory>target/generated-sources</outputDirectory>
<defaultTemplate>src/main/freemarker/default-generating-processor.ftl</defaultTemplate>
<sharedDataModel>
<file>src/main/freemarker-generator/data/shared-data-model.json</file>
<mavenProperties name="mavenProps" />
</sharedDataModel>
</configuration>
The templateDirectory, generatorDirectory and outputDirectory can be
omitted if they use the default values like values shown above.
The defaultTemplate and sharedDataModel can be omitted if they don't need those.
So, following the default conventions, the configuration will be minimal.
In the future phases, we might want to support more sophisticated
configuration in sharedDataModel like Daniel has shown above.
>
>>> <!-- optional -->
>>
>> <defaultTemplate>src/main/freemarker/default-generating-processor.ftl</defaultTemplate>
>> <!-- optional -->
>> </configuration>
>>
>> - In the basic scenario, if you have generator definition files under
>> the generatorDirectory, like .../Foo.java.json which may specify a
>> template name and its optional data model, the plugin generates
>> .../Foo.java, under the outputDirectory, by processing the specified
>> template with a combined data model (the optional global data model +
>> generator specific data model, with the latter shadowing the global).
>> If you don't specify the templateName in the .json file, it would use
>> the defaultTemplate if configured.
>>
>> - Option to find the generator template by name convention:
>> For example, if .../Foo.java.json doesn't define the templateName,
>> but if there exists .../Foo.java.ftl in the same folder in the
>> generatorDirectory, the template file is selected to process before
>> fall-backing to the optional defaultTemplate configured for the
>> plugin.
>>
>> In this case, the template existing in the generatorDirectory is
>> regarded as a special "generator" even if it is in the same form of
>> "templates".
>>
>> - Option to have only generator template without .json file:
>> In some cases, for example, if .../Foo.java.ftl exists in the
>> generatorDirectory without a corresponding .../Foo.java.json in the
>> same directory, .../Foo.java.ftl is used to process and generate an
>> output file with possibly using the optional globalDataModel.
>>
>> - Option to use .xml instead of .json for the generator definition files.
>
> That's new approach. Let's see...
Yeah, that's something we can consider later, indeed. Not in the 1st phase.
>
> What if you have Foo.java.json and Foo.java.xml? I assume that's an
> error. So if Foo.java.flt is just a generator, and Foo.java.json is
> just a generator, and yet you can pair them, while you can't pair json
> with xml. That makes .ftl generators special.
>
> Also it makes the meaning of templates/ more foggy, since in your
> example Foo.java.ftl is exactly the kind of template that you would
> put into templates/. As you have stated that too.
>
> Also, in principle nothing should stop a generator ftl to specify its
> own data-model. It could specify to the data-model via <#ftl
> attributes={ 'dataModel': ... }>. That's a situation where a json pair
> is strange.
>
> So to me this approach makes the roles of files less clear. But, the
> question is if this approach has practical value. Like is there a
> known usage scenario where you need a lot of data-models, each with a
> specific template that's not used for anything else? What other use
> cases are there where you could utilize this generalization?
I originally thought this .ftl generator only approach could have a
value (like the velocity maven plugin I referred to before), but now I
realize that as we already have a different directory structure with
separate ones (generator, template, data) already, .ftl generator only
approach doesn't make any sense.
I'm fine without it.
@Ben / @Mark, what do you think? Would these
generalization/improvements be acceptable to you?
Regards,
Woonsan
>
>> - The output file name is taken after removing the generator file
>> extension (.json or .xml), so it can be applied to various cases. e.g,
>> .../foo.html.json, .../foo.js.json, or even .../foo.json.json.
>>
>> ## AFG Core Module
>>
>> As the features can be useful to any other tools or environments, the
>> generic feature should be implemented in a separate core module,
>> without depending on Maven directly.
>> Maven Plugin submodule or any others depend on this core module.
>>
>> -----
>>
>> Perhaps I missed some details and you guys have some different tastes
>> or flavors on each, but I've tried to capture all the high level
>> features. ;-)
>> Please correct anything if I'm wrong in conceptual level or in detail level.
>> Also, if we come to a consensus in high level about the features,
>> perhaps we can move the feature list/descriptions to a JIRA ticket and
>> its description.
>>
>> What do you think?
>>
>> Regards,
>>
>> Woonsan
>>
>>
>> On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
>>> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>>>
>>>> I think I understand your idea about templates being in both locations, and
>>>> I think it is a reasonable approach.
>>>>
>>>> My thought is that in the case that you have multiple data models, it would
>>>> probably be clearer to have all of the templates one directory and bind
>>>> them to the appropriate data model explicitly.
>>>
>>> All of the templates? No, I certainly want to keep generator/
>>> templates and dependency templates (those in templates/ at the moment)
>>> clearly separated. The primary consideration when choosing the
>>> directory should be the *role* of the files there, not their format.
>>> That generator files can be json-s and ftl-s, and there can be
>>> dependencies of generator files which happen to be also ftl-s is just
>>> a coincidence. Looking at it from another angle, I think it's good if
>>> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
>>> else, then you know that you will have foo.txt and bar.txt in your
>>> output directory. If now there you will also see some-dependency.ftl,
>>> and it won't generate "some-dependency", that's confusing (plus how
>>> will even the plugin know if that's not a generator file).
>>>
>>> As of the data-model, the most comment case when using FreeMarker is
>>> to have a different data-model, per template, and even per execution
>>> (as variables change over time). It's also normal that data-models
>>> have common parts, like applications-scope variables or commonly
>>> utilities. (There's even a Configuration setting for that, called
>>> sharedVariables, but you might chose to make you data-model layered
>>> otherwise). So, I perceive it as completely normal that there's a
>>> shared part of the data-model, and some generator files add their own
>>> layer over that. BTW, this is also what the current version does, only
>>> the shared part of the data-model is fixed to that variable that holds
>>> the Maven properties.
>>>
>>>> And in the case that you have a single data model, you could provide this
>>>> shortcut to not needing to bind it explicitly to all of your templates
>>>> through some configuration option. And in this case, there wouldn't be the
>>>> need to have the templates in the generator directory.
>>>
>>> Ah, I see, you mean there should be a json, that doesn't specify a
>>> data-model, and points to the template. That's conceptually the
>>> cleanest, but that problem is that if your main use case is like in
>>> FMPP, it's annoying to the level that you practically don't support
>>> that use case.
>>>
>>>> The consistent aspect of that approach is that the templates are always in
>>>> the /templates directory,
>>>
>>> That "rhymes", but I don't think should be a goal in itself... We just
>>> low to use ftl-s for all kind of different purposes around here. :)
>>>
>>>> and a "generator" has a consistent definition of
>>>> a configuration file that binds a data model to a template.
>>>
>>> Yeah, but you can see it as if that binding is sometimes implicit. You
>>> can see an quick example of that in the FMPP page linked earlier...
>>> where the red lines fork out.
>>>
>>>> The consistent aspect of the templates in the generator directory approach
>>>> is that things that generate files are always in the same location (the
>>>> generators directory), and we could enforce the property that one source
>>>> file is generated for every file in the generators directory.
>>>
>>> I agree with that, but it's not against putting *generator* ftl-s into
>>> generators/.
>>>
>>> Actually... there's a frequent use case where you want to generate
>>> output files based on the content of the data-model. See this:
>>> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
>>> approach still remains true.
>>>
>>>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>>>
>>>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>>>
>>>>> > Here is my summary of the conversation and my take on it.
>>>>> >
>>>>> > There are two primary use cases discussed in the thread.
>>>>> >
>>>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>>>> > models"). This was our use case.
>>>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>>>> > model"
>>>>> >
>>>>> > So how to best bring together the "data model" and the "template" to fit
>>>>> > these use cases with minimal overhead?
>>>>> > There is the generic way which is to list out all of the templates and
>>>>> data
>>>>> > models in separate locations, and then to bring together the templates
>>>>> and
>>>>> > data models via some configuration. In this world, a structure might be:
>>>>> >
>>>>> > (@daniel you seem concerend by the default location being
>>>>> /src/main/freemarker,
>>>>> > do you have a better idea in mind?)
>>>>>
>>>>> My approach is that this is a product, and products has a somewhat
>>>>> unique (basically means searchable) name. Calling this just the
>>>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>>>> starters, it's functionality is not very much Maven specific, so it
>>>>> might as well will be callable from Gradle, or directly from command
>>>>> line (if you modularize it like that). Also there are a few other
>>>>> FreeMarker Maven Plugins, which makes searching for related content on
>>>>> the web hard. If we have a product name, then it's also obvious what
>>>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>>>> what that does.
>>>>>
>>>>> > /src/main/generated/freemarker/dataModels - data models
>>>>> > /src/main/generated/freemarker/templates - freemarker templates
>>>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>>>
>>>>> Note that it wasn't the structure I have suggested, just in case you
>>>>> (or someone) have missed that. What I said that for case #2, you
>>>>> simply put templates into generators/. And of course you can have both
>>>>> ftl and json files inside generators/, each generating its output file
>>>>> in its own way.
>>>>>
>>>>> As of dataModel-s, the part of the content the json files is also part
>>>>> of the data-model, so it's not the best name. It's rather
>>>>> "shared-dataModel", and in case you specify that directly in the
>>>>> pom.xml, you don't even need that. And of course, we are talking about
>>>>> a layered data-model, where there's a shared data model that's visible
>>>>> from everywhere, and it the case of a json generator file it can adds
>>>>> another layer on top of that.
>>>>>
>>>>> > The issue with this more generic structure is that in exchange for this
>>>>> > flexibility, you might have a bunch of extra files. For example, in the
>>>>> > special case #2, one needs twice as many files in the above structure.
>>>>> >
>>>>> > So instead of the above structure, the suggestion in the thread is to
>>>>> embed
>>>>> > both of the common use cases into the plugin in a way that they "play
>>>>> nice"
>>>>> > together.
>>>>> > Create a generators directory and have the plugin interpret how to
>>>>> generate
>>>>> > the source based on the type of thing in that directory.
>>>>> >
>>>>> > I think that we could instead ask how we might deviate from the above
>>>>> > generic structure that allows a many-to-many mapping while reusing both
>>>>> > data models
>>>>> > and templates in such a way that the two special cases can be naturally
>>>>> > supported.
>>>>> >
>>>>> > The first enhancement is that a generator could optionally embed the data
>>>>> > model. This handles case #1 if you do not want
>>>>> > to reuse data models. It also naturally comes from enhancing the
>>>>> > json structure in the way that Daniel suggested:
>>>>> >
>>>>> > {
>>>>> > "templateName": "foo.ftl",
>>>>> > "otherFutureMavenPluginKey": "something",
>>>>> > "dataModel": {
>>>>> > /* your application-specific stuff */
>>>>> > "myString": "a string",
>>>>> > "myNumber": 1,
>>>>> > ...
>>>>> > }
>>>>> > }
>>>>> >
>>>>> > Here the other option would be for "dataModel" to refer to a file in the
>>>>> > "dataModel" directory.
>>>>>
>>>>> Sure that's a more generic solution. Though usually you don't want to
>>>>> use a json generator file if you don't want a data-model that's
>>>>> specific to that generator file.
>>>>>
>>>>> > I would say that instead of overloading the "generators" directory to
>>>>> also
>>>>> > include templates,
>>>>>
>>>>> To clarify, there are templates in the templates\ directory, and then
>>>>> there can be templates in the generator/ directory. They are
>>>>> completely separate matters. In the 2nd case, they are just a type of
>>>>> a generator files, like json-s are.
>>>>>
>>>>> > we allow the plugin to operate in an alternate mode,
>>>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>>>> In
>>>>> > this mode, we generate sources for all templates in the template
>>>>> directory
>>>>> > from a common data model.
>>>>>
>>>>> My idea was that the we only ever generate output files for what's in
>>>>> the generator directory. There can be files both in generators/ and
>>>>> templates/, but hey have a different role. Templates in templates/ are
>>>>> just dependencies of some generators/ (the jsons, in this case), or
>>>>> maybe they can be #import-ed from templates in generators/.
>>>>>
>>>>> > In this use case, the project would only use
>>>>> > this structure only:
>>>>> >
>>>>> > /src/main/generated/freemarker/dataModel.xml
>>>>>
>>>>> NYW, I think for a dataModel it's important that it can come from
>>>>> various places, like even from a database. So we should keep that in
>>>>> mind.
>>>>>
>>>>> > /src/main/generated/freemarker/templates/...
>>>>> >
>>>>> > Having said all of this, I think the changes we would make in the short
>>>>> > term would be to update the json structure to include the dataModel as a
>>>>> > subtree, and to change the default locations to use the /generated
>>>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>>>> >
>>>>> > -Ben
>>>>> >
>>>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>>>> wrote:
>>>>> >
>>>>> >> Yes, this makes sense.
>>>>> >>
>>>>> >> -Ben
>>>>> >>
>>>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>>>> wrote:
>>>>> >>
>>>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>>> >>>
>>>>> >>> [snip]
>>>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>>>> >>> view
>>>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>>>> >>> with
>>>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>>>> >>> supports
>>>>> >>> > my main use case.
>>>>> >>> [snip]
>>>>> >>>
>>>>> >>> The problem with that is that it doesn't work if you happen to need a
>>>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>>>> solution
>>>>> >>> is like this:
>>>>> >>>
>>>>> >>> {
>>>>> >>> "templateName": "foo.ftl",
>>>>> >>> "otherFutureMavenPluginKey": "something",
>>>>> >>> "dataModel": {
>>>>> >>> /* your application-specific stuff */
>>>>> >>> "myString": "a string",
>>>>> >>> "myNumber": 1,
>>>>> >>> ...
>>>>> >>> }
>>>>> >>> }
>>>>> >>>
>>>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>>>> >>> without breaking backward compatibility.
>>>>> >>>
>>>>> >>> --
>>>>> >>> Thanks,
>>>>> >>> Daniel Dekany
>>>>> >>>
>>>>> >>>
>>>>> >>
>>>>> >>
>>>>> >> --
>>>>> >> Benjamin Grant Jackson
>>>>> >>
>>>>> >
>>>>> >
>>>>> >
>>>>>
>>>>> --
>>>>> Thanks,
>>>>> Daniel Dekany
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>
>
> --
> Thanks,
> Daniel Dekany
>
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Friday, August 17, 2018, 7:11:33 PM, Woonsan Ko wrote:
> Sorry for top posting, but perhaps a compact summary might help share
> the whole picture. Let me try to do that from the discussion so far:
>
> -----
>
> # Apache FreeMarker Generator (the name is probably due to change)
>
> A generic module enabling to generate various types of files through
> Apache FreeMarker templates and defined models.
>
> ## Concepts
>
> - "templates": source FreeMarker templates used in file generating processes.
Also this is where one should put templates that are
#import-ed/#include-d in other templates.
> - "generators": source generator definition files to be scanned, for
> each of which an output file is created.
Or multiple output files for the same generator file, if the generator
file says so.
> - "output files": target output files generated.
> - "dataModels": model objects passed to processing templates,
> including shared dataModel and generator-specific dataModel.
To clarify, generator-specific data-models can be there, but can also
be directly inside the generator file. Also, of course we shouldn't
have upper case letters in a standard directory name.
> ## Overview
>
> AFG (Apache FreeMarker Generator)
We shouldn't abbreviate "Apache", so if we really want to abbreviate
it, then it's "Apache FG" (which is horrid). BTW, any name of that
kind will mean a legal name check, unlike a non-abbreviated form. /-:
> is given "templates", "generators",
> "output files" and "dataModels" somehow, depending on submodule
> implementations such as Apache Maven Plugin, and generates various
> output files based on those in intuitive rules.
So the Maven hierarchy is:
- freemarker-generator (packaging=pom)
- freemarker-generator-core (packaging=jar)
- freemarker-generator-maven (packaging=jar)
> ## Maven Plugin Submodule
>
> - Maven Plugin configurations include directory paths for "templates",
> "generators", "output files", "globalDataModel"
Shared... as in configuration.sharedVaribles.
> and "defaultTemplate".
> For example (the default values are probably due to change),
>
> <configuration>
> <templateDirectory>src/main/freemarker</templateDirectory>
> <generatorDirectory>src/main/generator</generatorDirectory>
By default these two should have a common plugin-specific parent.
Like, src/main/freemarker-generator/templates,
src/main/freemarker-generator/generators.
> <outputDirectory>target/generated-sources</outputDirectory>
>
> <globalDataModel>src/main/data/shared-data-model.json</globalDataModel
By default this should also belong under the common parent directory,
like src/main/freemarker-generator/data.
Also I rather imagine something like this (on the long run):
<sharedDataModel>
<file>src/main/freemarker-generator/data/shared-data-model.json</file>
<variable name="bar">baaz ${mavenProperty}</variable>
<file name="foos">src/main/freemarker-generator/data/foos.xml</file>
<file name="bars">src/resources/bars.properties</file>
<mavenProperties name="mavenProps" />
</sharedDataModel>
>> <!-- optional -->
>
> <defaultTemplate>src/main/freemarker/default-generating-processor.ftl</defaultTemplate>
> <!-- optional -->
> </configuration>
>
> - In the basic scenario, if you have generator definition files under
> the generatorDirectory, like .../Foo.java.json which may specify a
> template name and its optional data model, the plugin generates
> .../Foo.java, under the outputDirectory, by processing the specified
> template with a combined data model (the optional global data model +
> generator specific data model, with the latter shadowing the global).
> If you don't specify the templateName in the .json file, it would use
> the defaultTemplate if configured.
>
> - Option to find the generator template by name convention:
> For example, if .../Foo.java.json doesn't define the templateName,
> but if there exists .../Foo.java.ftl in the same folder in the
> generatorDirectory, the template file is selected to process before
> fall-backing to the optional defaultTemplate configured for the
> plugin.
>
> In this case, the template existing in the generatorDirectory is
> regarded as a special "generator" even if it is in the same form of
> "templates".
>
> - Option to have only generator template without .json file:
> In some cases, for example, if .../Foo.java.ftl exists in the
> generatorDirectory without a corresponding .../Foo.java.json in the
> same directory, .../Foo.java.ftl is used to process and generate an
> output file with possibly using the optional globalDataModel.
>
> - Option to use .xml instead of .json for the generator definition files.
That's new approach. Let's see...
What if you have Foo.java.json and Foo.java.xml? I assume that's an
error. So if Foo.java.flt is just a generator, and Foo.java.json is
just a generator, and yet you can pair them, while you can't pair json
with xml. That makes .ftl generators special.
Also it makes the meaning of templates/ more foggy, since in your
example Foo.java.ftl is exactly the kind of template that you would
put into templates/. As you have stated that too.
Also, in principle nothing should stop a generator ftl to specify its
own data-model. It could specify to the data-model via <#ftl
attributes={ 'dataModel': ... }>. That's a situation where a json pair
is strange.
So to me this approach makes the roles of files less clear. But, the
question is if this approach has practical value. Like is there a
known usage scenario where you need a lot of data-models, each with a
specific template that's not used for anything else? What other use
cases are there where you could utilize this generalization?
> - The output file name is taken after removing the generator file
> extension (.json or .xml), so it can be applied to various cases. e.g,
> .../foo.html.json, .../foo.js.json, or even .../foo.json.json.
>
> ## AFG Core Module
>
> As the features can be useful to any other tools or environments, the
> generic feature should be implemented in a separate core module,
> without depending on Maven directly.
> Maven Plugin submodule or any others depend on this core module.
>
> -----
>
> Perhaps I missed some details and you guys have some different tastes
> or flavors on each, but I've tried to capture all the high level
> features. ;-)
> Please correct anything if I'm wrong in conceptual level or in detail level.
> Also, if we come to a consensus in high level about the features,
> perhaps we can move the feature list/descriptions to a JIRA ticket and
> its description.
>
> What do you think?
>
> Regards,
>
> Woonsan
>
>
> On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
>> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>>
>>> I think I understand your idea about templates being in both locations, and
>>> I think it is a reasonable approach.
>>>
>>> My thought is that in the case that you have multiple data models, it would
>>> probably be clearer to have all of the templates one directory and bind
>>> them to the appropriate data model explicitly.
>>
>> All of the templates? No, I certainly want to keep generator/
>> templates and dependency templates (those in templates/ at the moment)
>> clearly separated. The primary consideration when choosing the
>> directory should be the *role* of the files there, not their format.
>> That generator files can be json-s and ftl-s, and there can be
>> dependencies of generator files which happen to be also ftl-s is just
>> a coincidence. Looking at it from another angle, I think it's good if
>> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
>> else, then you know that you will have foo.txt and bar.txt in your
>> output directory. If now there you will also see some-dependency.ftl,
>> and it won't generate "some-dependency", that's confusing (plus how
>> will even the plugin know if that's not a generator file).
>>
>> As of the data-model, the most comment case when using FreeMarker is
>> to have a different data-model, per template, and even per execution
>> (as variables change over time). It's also normal that data-models
>> have common parts, like applications-scope variables or commonly
>> utilities. (There's even a Configuration setting for that, called
>> sharedVariables, but you might chose to make you data-model layered
>> otherwise). So, I perceive it as completely normal that there's a
>> shared part of the data-model, and some generator files add their own
>> layer over that. BTW, this is also what the current version does, only
>> the shared part of the data-model is fixed to that variable that holds
>> the Maven properties.
>>
>>> And in the case that you have a single data model, you could provide this
>>> shortcut to not needing to bind it explicitly to all of your templates
>>> through some configuration option. And in this case, there wouldn't be the
>>> need to have the templates in the generator directory.
>>
>> Ah, I see, you mean there should be a json, that doesn't specify a
>> data-model, and points to the template. That's conceptually the
>> cleanest, but that problem is that if your main use case is like in
>> FMPP, it's annoying to the level that you practically don't support
>> that use case.
>>
>>> The consistent aspect of that approach is that the templates are always in
>>> the /templates directory,
>>
>> That "rhymes", but I don't think should be a goal in itself... We just
>> low to use ftl-s for all kind of different purposes around here. :)
>>
>>> and a "generator" has a consistent definition of
>>> a configuration file that binds a data model to a template.
>>
>> Yeah, but you can see it as if that binding is sometimes implicit. You
>> can see an quick example of that in the FMPP page linked earlier...
>> where the red lines fork out.
>>
>>> The consistent aspect of the templates in the generator directory approach
>>> is that things that generate files are always in the same location (the
>>> generators directory), and we could enforce the property that one source
>>> file is generated for every file in the generators directory.
>>
>> I agree with that, but it's not against putting *generator* ftl-s into
>> generators/.
>>
>> Actually... there's a frequent use case where you want to generate
>> output files based on the content of the data-model. See this:
>> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
>> approach still remains true.
>>
>>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>>
>>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>>
>>>> > Here is my summary of the conversation and my take on it.
>>>> >
>>>> > There are two primary use cases discussed in the thread.
>>>> >
>>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>>> > models"). This was our use case.
>>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>>> > model"
>>>> >
>>>> > So how to best bring together the "data model" and the "template" to fit
>>>> > these use cases with minimal overhead?
>>>> > There is the generic way which is to list out all of the templates and
>>>> data
>>>> > models in separate locations, and then to bring together the templates
>>>> and
>>>> > data models via some configuration. In this world, a structure might be:
>>>> >
>>>> > (@daniel you seem concerend by the default location being
>>>> /src/main/freemarker,
>>>> > do you have a better idea in mind?)
>>>>
>>>> My approach is that this is a product, and products has a somewhat
>>>> unique (basically means searchable) name. Calling this just the
>>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>>> starters, it's functionality is not very much Maven specific, so it
>>>> might as well will be callable from Gradle, or directly from command
>>>> line (if you modularize it like that). Also there are a few other
>>>> FreeMarker Maven Plugins, which makes searching for related content on
>>>> the web hard. If we have a product name, then it's also obvious what
>>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>>> what that does.
>>>>
>>>> > /src/main/generated/freemarker/dataModels - data models
>>>> > /src/main/generated/freemarker/templates - freemarker templates
>>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>>
>>>> Note that it wasn't the structure I have suggested, just in case you
>>>> (or someone) have missed that. What I said that for case #2, you
>>>> simply put templates into generators/. And of course you can have both
>>>> ftl and json files inside generators/, each generating its output file
>>>> in its own way.
>>>>
>>>> As of dataModel-s, the part of the content the json files is also part
>>>> of the data-model, so it's not the best name. It's rather
>>>> "shared-dataModel", and in case you specify that directly in the
>>>> pom.xml, you don't even need that. And of course, we are talking about
>>>> a layered data-model, where there's a shared data model that's visible
>>>> from everywhere, and it the case of a json generator file it can adds
>>>> another layer on top of that.
>>>>
>>>> > The issue with this more generic structure is that in exchange for this
>>>> > flexibility, you might have a bunch of extra files. For example, in the
>>>> > special case #2, one needs twice as many files in the above structure.
>>>> >
>>>> > So instead of the above structure, the suggestion in the thread is to
>>>> embed
>>>> > both of the common use cases into the plugin in a way that they "play
>>>> nice"
>>>> > together.
>>>> > Create a generators directory and have the plugin interpret how to
>>>> generate
>>>> > the source based on the type of thing in that directory.
>>>> >
>>>> > I think that we could instead ask how we might deviate from the above
>>>> > generic structure that allows a many-to-many mapping while reusing both
>>>> > data models
>>>> > and templates in such a way that the two special cases can be naturally
>>>> > supported.
>>>> >
>>>> > The first enhancement is that a generator could optionally embed the data
>>>> > model. This handles case #1 if you do not want
>>>> > to reuse data models. It also naturally comes from enhancing the
>>>> > json structure in the way that Daniel suggested:
>>>> >
>>>> > {
>>>> > "templateName": "foo.ftl",
>>>> > "otherFutureMavenPluginKey": "something",
>>>> > "dataModel": {
>>>> > /* your application-specific stuff */
>>>> > "myString": "a string",
>>>> > "myNumber": 1,
>>>> > ...
>>>> > }
>>>> > }
>>>> >
>>>> > Here the other option would be for "dataModel" to refer to a file in the
>>>> > "dataModel" directory.
>>>>
>>>> Sure that's a more generic solution. Though usually you don't want to
>>>> use a json generator file if you don't want a data-model that's
>>>> specific to that generator file.
>>>>
>>>> > I would say that instead of overloading the "generators" directory to
>>>> also
>>>> > include templates,
>>>>
>>>> To clarify, there are templates in the templates\ directory, and then
>>>> there can be templates in the generator/ directory. They are
>>>> completely separate matters. In the 2nd case, they are just a type of
>>>> a generator files, like json-s are.
>>>>
>>>> > we allow the plugin to operate in an alternate mode,
>>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>>> In
>>>> > this mode, we generate sources for all templates in the template
>>>> directory
>>>> > from a common data model.
>>>>
>>>> My idea was that the we only ever generate output files for what's in
>>>> the generator directory. There can be files both in generators/ and
>>>> templates/, but hey have a different role. Templates in templates/ are
>>>> just dependencies of some generators/ (the jsons, in this case), or
>>>> maybe they can be #import-ed from templates in generators/.
>>>>
>>>> > In this use case, the project would only use
>>>> > this structure only:
>>>> >
>>>> > /src/main/generated/freemarker/dataModel.xml
>>>>
>>>> NYW, I think for a dataModel it's important that it can come from
>>>> various places, like even from a database. So we should keep that in
>>>> mind.
>>>>
>>>> > /src/main/generated/freemarker/templates/...
>>>> >
>>>> > Having said all of this, I think the changes we would make in the short
>>>> > term would be to update the json structure to include the dataModel as a
>>>> > subtree, and to change the default locations to use the /generated
>>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>>> >
>>>> > -Ben
>>>> >
>>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>>> wrote:
>>>> >
>>>> >> Yes, this makes sense.
>>>> >>
>>>> >> -Ben
>>>> >>
>>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>>> wrote:
>>>> >>
>>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>> >>>
>>>> >>> [snip]
>>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>>> >>> view
>>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>>> >>> with
>>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>>> >>> supports
>>>> >>> > my main use case.
>>>> >>> [snip]
>>>> >>>
>>>> >>> The problem with that is that it doesn't work if you happen to need a
>>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>>> solution
>>>> >>> is like this:
>>>> >>>
>>>> >>> {
>>>> >>> "templateName": "foo.ftl",
>>>> >>> "otherFutureMavenPluginKey": "something",
>>>> >>> "dataModel": {
>>>> >>> /* your application-specific stuff */
>>>> >>> "myString": "a string",
>>>> >>> "myNumber": 1,
>>>> >>> ...
>>>> >>> }
>>>> >>> }
>>>> >>>
>>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>>> >>> without breaking backward compatibility.
>>>> >>>
>>>> >>> --
>>>> >>> Thanks,
>>>> >>> Daniel Dekany
>>>> >>>
>>>> >>>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Benjamin Grant Jackson
>>>> >>
>>>> >
>>>> >
>>>> >
>>>>
>>>> --
>>>> Thanks,
>>>> Daniel Dekany
>>>>
>>>>
>>>
>>>
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
Sorry for top posting, but perhaps a compact summary might help share
the whole picture. Let me try to do that from the discussion so far:
-----
# Apache FreeMarker Generator (the name is probably due to change)
A generic module enabling to generate various types of files through
Apache FreeMarker templates and defined models.
## Concepts
- "templates": source FreeMarker templates used in file generating processes.
- "generators": source generator definition files to be scanned, for
each of which an output file is created.
- "output files": target output files generated.
- "dataModels": model objects passed to processing templates,
including shared dataModel and generator-specific dataModel.
## Overview
AFG (Apache FreeMarker Generator) is given "templates", "generators",
"output files" and "dataModels" somehow, depending on submodule
implementations such as Apache Maven Plugin, and generates various
output files based on those in intuitive rules.
## Maven Plugin Submodule
- Maven Plugin configurations include directory paths for "templates",
"generators", "output files", "globalDataModel" and "defaultTemplate".
For example (the default values are probably due to change),
<configuration>
<templateDirectory>src/main/freemarker</templateDirectory>
<generatorDirectory>src/main/generator</generatorDirectory>
<outputDirectory>target/generated-sources</outputDirectory>
<globalDataModel>src/main/data/shared-data-model.json</globalDataModel
> <!-- optional -->
<defaultTemplate>src/main/freemarker/default-generating-processor.ftl</defaultTemplate>
<!-- optional -->
</configuration>
- In the basic scenario, if you have generator definition files under
the generatorDirectory, like .../Foo.java.json which may specify a
template name and its optional data model, the plugin generates
.../Foo.java, under the outputDirectory, by processing the specified
template with a combined data model (the optional global data model +
generator specific data model, with the latter shadowing the global).
If you don't specify the templateName in the .json file, it would use
the defaultTemplate if configured.
- Option to find the generator template by name convention:
For example, if .../Foo.java.json doesn't define the templateName,
but if there exists .../Foo.java.ftl in the same folder in the
generatorDirectory, the template file is selected to process before
fall-backing to the optional defaultTemplate configured for the
plugin.
In this case, the template existing in the generatorDirectory is
regarded as a special "generator" even if it is in the same form of
"templates".
- Option to have only generator template without .json file:
In some cases, for example, if .../Foo.java.ftl exists in the
generatorDirectory without a corresponding .../Foo.java.json in the
same directory, .../Foo.java.ftl is used to process and generate an
output file with possibly using the optional globalDataModel.
- Option to use .xml instead of .json for the generator definition files.
- The output file name is taken after removing the generator file
extension (.json or .xml), so it can be applied to various cases. e.g,
.../foo.html.json, .../foo.js.json, or even .../foo.json.json.
## AFG Core Module
As the features can be useful to any other tools or environments, the
generic feature should be implemented in a separate core module,
without depending on Maven directly.
Maven Plugin submodule or any others depend on this core module.
-----
Perhaps I missed some details and you guys have some different tastes
or flavors on each, but I've tried to capture all the high level
features. ;-)
Please correct anything if I'm wrong in conceptual level or in detail level.
Also, if we come to a consensus in high level about the features,
perhaps we can move the feature list/descriptions to a JIRA ticket and
its description.
What do you think?
Regards,
Woonsan
On Fri, Aug 17, 2018 at 12:04 PM, Daniel Dekany <dd...@apache.org> wrote:
> Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
>
>> I think I understand your idea about templates being in both locations, and
>> I think it is a reasonable approach.
>>
>> My thought is that in the case that you have multiple data models, it would
>> probably be clearer to have all of the templates one directory and bind
>> them to the appropriate data model explicitly.
>
> All of the templates? No, I certainly want to keep generator/
> templates and dependency templates (those in templates/ at the moment)
> clearly separated. The primary consideration when choosing the
> directory should be the *role* of the files there, not their format.
> That generator files can be json-s and ftl-s, and there can be
> dependencies of generator files which happen to be also ftl-s is just
> a coincidence. Looking at it from another angle, I think it's good if
> when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
> else, then you know that you will have foo.txt and bar.txt in your
> output directory. If now there you will also see some-dependency.ftl,
> and it won't generate "some-dependency", that's confusing (plus how
> will even the plugin know if that's not a generator file).
>
> As of the data-model, the most comment case when using FreeMarker is
> to have a different data-model, per template, and even per execution
> (as variables change over time). It's also normal that data-models
> have common parts, like applications-scope variables or commonly
> utilities. (There's even a Configuration setting for that, called
> sharedVariables, but you might chose to make you data-model layered
> otherwise). So, I perceive it as completely normal that there's a
> shared part of the data-model, and some generator files add their own
> layer over that. BTW, this is also what the current version does, only
> the shared part of the data-model is fixed to that variable that holds
> the Maven properties.
>
>> And in the case that you have a single data model, you could provide this
>> shortcut to not needing to bind it explicitly to all of your templates
>> through some configuration option. And in this case, there wouldn't be the
>> need to have the templates in the generator directory.
>
> Ah, I see, you mean there should be a json, that doesn't specify a
> data-model, and points to the template. That's conceptually the
> cleanest, but that problem is that if your main use case is like in
> FMPP, it's annoying to the level that you practically don't support
> that use case.
>
>> The consistent aspect of that approach is that the templates are always in
>> the /templates directory,
>
> That "rhymes", but I don't think should be a goal in itself... We just
> low to use ftl-s for all kind of different purposes around here. :)
>
>> and a "generator" has a consistent definition of
>> a configuration file that binds a data model to a template.
>
> Yeah, but you can see it as if that binding is sometimes implicit. You
> can see an quick example of that in the FMPP page linked earlier...
> where the red lines fork out.
>
>> The consistent aspect of the templates in the generator directory approach
>> is that things that generate files are always in the same location (the
>> generators directory), and we could enforce the property that one source
>> file is generated for every file in the generators directory.
>
> I agree with that, but it's not against putting *generator* ftl-s into
> generators/.
>
> Actually... there's a frequent use case where you want to generate
> output files based on the content of the data-model. See this:
> http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
> approach still remains true.
>
>> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>>
>>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>>
>>> > Here is my summary of the conversation and my take on it.
>>> >
>>> > There are two primary use cases discussed in the thread.
>>> >
>>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>>> > models"). This was our use case.
>>> > 2. A bunch of templates being instantiated based on a single shared "data
>>> > model"
>>> >
>>> > So how to best bring together the "data model" and the "template" to fit
>>> > these use cases with minimal overhead?
>>> > There is the generic way which is to list out all of the templates and
>>> data
>>> > models in separate locations, and then to bring together the templates
>>> and
>>> > data models via some configuration. In this world, a structure might be:
>>> >
>>> > (@daniel you seem concerend by the default location being
>>> /src/main/freemarker,
>>> > do you have a better idea in mind?)
>>>
>>> My approach is that this is a product, and products has a somewhat
>>> unique (basically means searchable) name. Calling this just the
>>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>>> starters, it's functionality is not very much Maven specific, so it
>>> might as well will be callable from Gradle, or directly from command
>>> line (if you modularize it like that). Also there are a few other
>>> FreeMarker Maven Plugins, which makes searching for related content on
>>> the web hard. If we have a product name, then it's also obvious what
>>> the directory name will be. So, let's say, it's "Apache FreeMarker
>>> FGen" (maybe a stupid name, but just as an example), then, you have
>>> /src/main/fgen, and when someone sees it and Googles it, he will find
>>> what that does.
>>>
>>> > /src/main/generated/freemarker/dataModels - data models
>>> > /src/main/generated/freemarker/templates - freemarker templates
>>> > /src/main/generated/freemarker/generators - json, one per output file
>>>
>>> Note that it wasn't the structure I have suggested, just in case you
>>> (or someone) have missed that. What I said that for case #2, you
>>> simply put templates into generators/. And of course you can have both
>>> ftl and json files inside generators/, each generating its output file
>>> in its own way.
>>>
>>> As of dataModel-s, the part of the content the json files is also part
>>> of the data-model, so it's not the best name. It's rather
>>> "shared-dataModel", and in case you specify that directly in the
>>> pom.xml, you don't even need that. And of course, we are talking about
>>> a layered data-model, where there's a shared data model that's visible
>>> from everywhere, and it the case of a json generator file it can adds
>>> another layer on top of that.
>>>
>>> > The issue with this more generic structure is that in exchange for this
>>> > flexibility, you might have a bunch of extra files. For example, in the
>>> > special case #2, one needs twice as many files in the above structure.
>>> >
>>> > So instead of the above structure, the suggestion in the thread is to
>>> embed
>>> > both of the common use cases into the plugin in a way that they "play
>>> nice"
>>> > together.
>>> > Create a generators directory and have the plugin interpret how to
>>> generate
>>> > the source based on the type of thing in that directory.
>>> >
>>> > I think that we could instead ask how we might deviate from the above
>>> > generic structure that allows a many-to-many mapping while reusing both
>>> > data models
>>> > and templates in such a way that the two special cases can be naturally
>>> > supported.
>>> >
>>> > The first enhancement is that a generator could optionally embed the data
>>> > model. This handles case #1 if you do not want
>>> > to reuse data models. It also naturally comes from enhancing the
>>> > json structure in the way that Daniel suggested:
>>> >
>>> > {
>>> > "templateName": "foo.ftl",
>>> > "otherFutureMavenPluginKey": "something",
>>> > "dataModel": {
>>> > /* your application-specific stuff */
>>> > "myString": "a string",
>>> > "myNumber": 1,
>>> > ...
>>> > }
>>> > }
>>> >
>>> > Here the other option would be for "dataModel" to refer to a file in the
>>> > "dataModel" directory.
>>>
>>> Sure that's a more generic solution. Though usually you don't want to
>>> use a json generator file if you don't want a data-model that's
>>> specific to that generator file.
>>>
>>> > I would say that instead of overloading the "generators" directory to
>>> also
>>> > include templates,
>>>
>>> To clarify, there are templates in the templates\ directory, and then
>>> there can be templates in the generator/ directory. They are
>>> completely separate matters. In the 2nd case, they are just a type of
>>> a generator files, like json-s are.
>>>
>>> > we allow the plugin to operate in an alternate mode,
>>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>>> In
>>> > this mode, we generate sources for all templates in the template
>>> directory
>>> > from a common data model.
>>>
>>> My idea was that the we only ever generate output files for what's in
>>> the generator directory. There can be files both in generators/ and
>>> templates/, but hey have a different role. Templates in templates/ are
>>> just dependencies of some generators/ (the jsons, in this case), or
>>> maybe they can be #import-ed from templates in generators/.
>>>
>>> > In this use case, the project would only use
>>> > this structure only:
>>> >
>>> > /src/main/generated/freemarker/dataModel.xml
>>>
>>> NYW, I think for a dataModel it's important that it can come from
>>> various places, like even from a database. So we should keep that in
>>> mind.
>>>
>>> > /src/main/generated/freemarker/templates/...
>>> >
>>> > Having said all of this, I think the changes we would make in the short
>>> > term would be to update the json structure to include the dataModel as a
>>> > subtree, and to change the default locations to use the /generated
>>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>>> >
>>> > -Ben
>>> >
>>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>>> wrote:
>>> >
>>> >> Yes, this makes sense.
>>> >>
>>> >> -Ben
>>> >>
>>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>>> wrote:
>>> >>
>>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>> >>>
>>> >>> [snip]
>>> >>> > 3) I agree that using the well known json field 'templateName' seems
>>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>>> >>> view
>>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>>> >>> with
>>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>>> >>> supports
>>> >>> > my main use case.
>>> >>> [snip]
>>> >>>
>>> >>> The problem with that is that it doesn't work if you happen to need a
>>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>> >>> take it as a demonstration of why it's not correct. The "correct"
>>> solution
>>> >>> is like this:
>>> >>>
>>> >>> {
>>> >>> "templateName": "foo.ftl",
>>> >>> "otherFutureMavenPluginKey": "something",
>>> >>> "dataModel": {
>>> >>> /* your application-specific stuff */
>>> >>> "myString": "a string",
>>> >>> "myNumber": 1,
>>> >>> ...
>>> >>> }
>>> >>> }
>>> >>>
>>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>> >>> without breaking backward compatibility.
>>> >>>
>>> >>> --
>>> >>> Thanks,
>>> >>> Daniel Dekany
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >> --
>>> >> Benjamin Grant Jackson
>>> >>
>>> >
>>> >
>>> >
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>>
>>
>>
>
> --
> Thanks,
> Daniel Dekany
>
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Friday, August 17, 2018, 3:56:27 PM, Ben Jackson wrote:
> I think I understand your idea about templates being in both locations, and
> I think it is a reasonable approach.
>
> My thought is that in the case that you have multiple data models, it would
> probably be clearer to have all of the templates one directory and bind
> them to the appropriate data model explicitly.
All of the templates? No, I certainly want to keep generator/
templates and dependency templates (those in templates/ at the moment)
clearly separated. The primary consideration when choosing the
directory should be the *role* of the files there, not their format.
That generator files can be json-s and ftl-s, and there can be
dependencies of generator files which happen to be also ftl-s is just
a coincidence. Looking at it from another angle, I think it's good if
when in generators/ you see foo.txt.json and bar.txt.ftl and nothing
else, then you know that you will have foo.txt and bar.txt in your
output directory. If now there you will also see some-dependency.ftl,
and it won't generate "some-dependency", that's confusing (plus how
will even the plugin know if that's not a generator file).
As of the data-model, the most comment case when using FreeMarker is
to have a different data-model, per template, and even per execution
(as variables change over time). It's also normal that data-models
have common parts, like applications-scope variables or commonly
utilities. (There's even a Configuration setting for that, called
sharedVariables, but you might chose to make you data-model layered
otherwise). So, I perceive it as completely normal that there's a
shared part of the data-model, and some generator files add their own
layer over that. BTW, this is also what the current version does, only
the shared part of the data-model is fixed to that variable that holds
the Maven properties.
> And in the case that you have a single data model, you could provide this
> shortcut to not needing to bind it explicitly to all of your templates
> through some configuration option. And in this case, there wouldn't be the
> need to have the templates in the generator directory.
Ah, I see, you mean there should be a json, that doesn't specify a
data-model, and points to the template. That's conceptually the
cleanest, but that problem is that if your main use case is like in
FMPP, it's annoying to the level that you practically don't support
that use case.
> The consistent aspect of that approach is that the templates are always in
> the /templates directory,
That "rhymes", but I don't think should be a goal in itself... We just
low to use ftl-s for all kind of different purposes around here. :)
> and a "generator" has a consistent definition of
> a configuration file that binds a data model to a template.
Yeah, but you can see it as if that binding is sometimes implicit. You
can see an quick example of that in the FMPP page linked earlier...
where the red lines fork out.
> The consistent aspect of the templates in the generator directory approach
> is that things that generate files are always in the same location (the
> generators directory), and we could enforce the property that one source
> file is generated for every file in the generators directory.
I agree with that, but it's not against putting *generator* ftl-s into
generators/.
Actually... there's a frequent use case where you want to generate
output files based on the content of the data-model. See this:
http://fmpp.sourceforge.net/qtour.html#sect4. But that the basic
approach still remains true.
> On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
>
>> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>>
>> > Here is my summary of the conversation and my take on it.
>> >
>> > There are two primary use cases discussed in the thread.
>> >
>> > 1. Multiple templates instantiated in multiple ways (with multiple "data
>> > models"). This was our use case.
>> > 2. A bunch of templates being instantiated based on a single shared "data
>> > model"
>> >
>> > So how to best bring together the "data model" and the "template" to fit
>> > these use cases with minimal overhead?
>> > There is the generic way which is to list out all of the templates and
>> data
>> > models in separate locations, and then to bring together the templates
>> and
>> > data models via some configuration. In this world, a structure might be:
>> >
>> > (@daniel you seem concerend by the default location being
>> /src/main/freemarker,
>> > do you have a better idea in mind?)
>>
>> My approach is that this is a product, and products has a somewhat
>> unique (basically means searchable) name. Calling this just the
>> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
>> starters, it's functionality is not very much Maven specific, so it
>> might as well will be callable from Gradle, or directly from command
>> line (if you modularize it like that). Also there are a few other
>> FreeMarker Maven Plugins, which makes searching for related content on
>> the web hard. If we have a product name, then it's also obvious what
>> the directory name will be. So, let's say, it's "Apache FreeMarker
>> FGen" (maybe a stupid name, but just as an example), then, you have
>> /src/main/fgen, and when someone sees it and Googles it, he will find
>> what that does.
>>
>> > /src/main/generated/freemarker/dataModels - data models
>> > /src/main/generated/freemarker/templates - freemarker templates
>> > /src/main/generated/freemarker/generators - json, one per output file
>>
>> Note that it wasn't the structure I have suggested, just in case you
>> (or someone) have missed that. What I said that for case #2, you
>> simply put templates into generators/. And of course you can have both
>> ftl and json files inside generators/, each generating its output file
>> in its own way.
>>
>> As of dataModel-s, the part of the content the json files is also part
>> of the data-model, so it's not the best name. It's rather
>> "shared-dataModel", and in case you specify that directly in the
>> pom.xml, you don't even need that. And of course, we are talking about
>> a layered data-model, where there's a shared data model that's visible
>> from everywhere, and it the case of a json generator file it can adds
>> another layer on top of that.
>>
>> > The issue with this more generic structure is that in exchange for this
>> > flexibility, you might have a bunch of extra files. For example, in the
>> > special case #2, one needs twice as many files in the above structure.
>> >
>> > So instead of the above structure, the suggestion in the thread is to
>> embed
>> > both of the common use cases into the plugin in a way that they "play
>> nice"
>> > together.
>> > Create a generators directory and have the plugin interpret how to
>> generate
>> > the source based on the type of thing in that directory.
>> >
>> > I think that we could instead ask how we might deviate from the above
>> > generic structure that allows a many-to-many mapping while reusing both
>> > data models
>> > and templates in such a way that the two special cases can be naturally
>> > supported.
>> >
>> > The first enhancement is that a generator could optionally embed the data
>> > model. This handles case #1 if you do not want
>> > to reuse data models. It also naturally comes from enhancing the
>> > json structure in the way that Daniel suggested:
>> >
>> > {
>> > "templateName": "foo.ftl",
>> > "otherFutureMavenPluginKey": "something",
>> > "dataModel": {
>> > /* your application-specific stuff */
>> > "myString": "a string",
>> > "myNumber": 1,
>> > ...
>> > }
>> > }
>> >
>> > Here the other option would be for "dataModel" to refer to a file in the
>> > "dataModel" directory.
>>
>> Sure that's a more generic solution. Though usually you don't want to
>> use a json generator file if you don't want a data-model that's
>> specific to that generator file.
>>
>> > I would say that instead of overloading the "generators" directory to
>> also
>> > include templates,
>>
>> To clarify, there are templates in the templates\ directory, and then
>> there can be templates in the generator/ directory. They are
>> completely separate matters. In the 2nd case, they are just a type of
>> a generator files, like json-s are.
>>
>> > we allow the plugin to operate in an alternate mode,
>> > enabled by configuration, say by setting a "defaultDataModel" parameter.
>> In
>> > this mode, we generate sources for all templates in the template
>> directory
>> > from a common data model.
>>
>> My idea was that the we only ever generate output files for what's in
>> the generator directory. There can be files both in generators/ and
>> templates/, but hey have a different role. Templates in templates/ are
>> just dependencies of some generators/ (the jsons, in this case), or
>> maybe they can be #import-ed from templates in generators/.
>>
>> > In this use case, the project would only use
>> > this structure only:
>> >
>> > /src/main/generated/freemarker/dataModel.xml
>>
>> NYW, I think for a dataModel it's important that it can come from
>> various places, like even from a database. So we should keep that in
>> mind.
>>
>> > /src/main/generated/freemarker/templates/...
>> >
>> > Having said all of this, I think the changes we would make in the short
>> > term would be to update the json structure to include the dataModel as a
>> > subtree, and to change the default locations to use the /generated
>> > subdirectory rather than /data, and whatever suggestion is appropriate.
>> >
>> > -Ben
>> >
>> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
>> wrote:
>> >
>> >> Yes, this makes sense.
>> >>
>> >> -Ben
>> >>
>> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
>> wrote:
>> >>
>> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>> >>>
>> >>> [snip]
>> >>> > 3) I agree that using the well known json field 'templateName' seems
>> >>> > 'hacky' (from a freemarker point of view). However, from the point of
>> >>> view
>> >>> > of the maven plugin it works nice. It provides the flexibility I need
>> >>> with
>> >>> > the minimum fuss. I will entertain another mechanism as long as it
>> >>> supports
>> >>> > my main use case.
>> >>> [snip]
>> >>>
>> >>> The problem with that is that it doesn't work if you happen to need a
>> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>> >>> take it as a demonstration of why it's not correct. The "correct"
>> solution
>> >>> is like this:
>> >>>
>> >>> {
>> >>> "templateName": "foo.ftl",
>> >>> "otherFutureMavenPluginKey": "something",
>> >>> "dataModel": {
>> >>> /* your application-specific stuff */
>> >>> "myString": "a string",
>> >>> "myNumber": 1,
>> >>> ...
>> >>> }
>> >>> }
>> >>>
>> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>> >>> without breaking backward compatibility.
>> >>>
>> >>> --
>> >>> Thanks,
>> >>> Daniel Dekany
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> Benjamin Grant Jackson
>> >>
>> >
>> >
>> >
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>>
>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
I think I understand your idea about templates being in both locations, and
I think it is a reasonable approach.
My thought is that in the case that you have multiple data models, it would
probably be clearer to have all of the templates one directory and bind
them to the appropriate data model explicitly.
And in the case that you have a single data model, you could provide this
shortcut to not needing to bind it explicitly to all of your templates
through some configuration option. And in this case, there wouldn't be the
need to have the templates in the generator directory.
The consistent aspect of that approach is that the templates are always in
the /templates directory, and a "generator" has a consistent definition of
a configuration file that binds a data model to a template.
The consistent aspect of the templates in the generator directory approach
is that things that generate files are always in the same location (the
generators directory), and we could enforce the property that one source
file is generated for every file in the generators directory.
On Fri, Aug 17, 2018 at 1:32 AM, Daniel Dekany <dd...@apache.org> wrote:
> Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
>
> > Here is my summary of the conversation and my take on it.
> >
> > There are two primary use cases discussed in the thread.
> >
> > 1. Multiple templates instantiated in multiple ways (with multiple "data
> > models"). This was our use case.
> > 2. A bunch of templates being instantiated based on a single shared "data
> > model"
> >
> > So how to best bring together the "data model" and the "template" to fit
> > these use cases with minimal overhead?
> > There is the generic way which is to list out all of the templates and
> data
> > models in separate locations, and then to bring together the templates
> and
> > data models via some configuration. In this world, a structure might be:
> >
> > (@daniel you seem concerend by the default location being
> /src/main/freemarker,
> > do you have a better idea in mind?)
>
> My approach is that this is a product, and products has a somewhat
> unique (basically means searchable) name. Calling this just the
> "Apache FreeMarker Maven Plugin" is problematic for that reason. For
> starters, it's functionality is not very much Maven specific, so it
> might as well will be callable from Gradle, or directly from command
> line (if you modularize it like that). Also there are a few other
> FreeMarker Maven Plugins, which makes searching for related content on
> the web hard. If we have a product name, then it's also obvious what
> the directory name will be. So, let's say, it's "Apache FreeMarker
> FGen" (maybe a stupid name, but just as an example), then, you have
> /src/main/fgen, and when someone sees it and Googles it, he will find
> what that does.
>
> > /src/main/generated/freemarker/dataModels - data models
> > /src/main/generated/freemarker/templates - freemarker templates
> > /src/main/generated/freemarker/generators - json, one per output file
>
> Note that it wasn't the structure I have suggested, just in case you
> (or someone) have missed that. What I said that for case #2, you
> simply put templates into generators/. And of course you can have both
> ftl and json files inside generators/, each generating its output file
> in its own way.
>
> As of dataModel-s, the part of the content the json files is also part
> of the data-model, so it's not the best name. It's rather
> "shared-dataModel", and in case you specify that directly in the
> pom.xml, you don't even need that. And of course, we are talking about
> a layered data-model, where there's a shared data model that's visible
> from everywhere, and it the case of a json generator file it can adds
> another layer on top of that.
>
> > The issue with this more generic structure is that in exchange for this
> > flexibility, you might have a bunch of extra files. For example, in the
> > special case #2, one needs twice as many files in the above structure.
> >
> > So instead of the above structure, the suggestion in the thread is to
> embed
> > both of the common use cases into the plugin in a way that they "play
> nice"
> > together.
> > Create a generators directory and have the plugin interpret how to
> generate
> > the source based on the type of thing in that directory.
> >
> > I think that we could instead ask how we might deviate from the above
> > generic structure that allows a many-to-many mapping while reusing both
> > data models
> > and templates in such a way that the two special cases can be naturally
> > supported.
> >
> > The first enhancement is that a generator could optionally embed the data
> > model. This handles case #1 if you do not want
> > to reuse data models. It also naturally comes from enhancing the
> > json structure in the way that Daniel suggested:
> >
> > {
> > "templateName": "foo.ftl",
> > "otherFutureMavenPluginKey": "something",
> > "dataModel": {
> > /* your application-specific stuff */
> > "myString": "a string",
> > "myNumber": 1,
> > ...
> > }
> > }
> >
> > Here the other option would be for "dataModel" to refer to a file in the
> > "dataModel" directory.
>
> Sure that's a more generic solution. Though usually you don't want to
> use a json generator file if you don't want a data-model that's
> specific to that generator file.
>
> > I would say that instead of overloading the "generators" directory to
> also
> > include templates,
>
> To clarify, there are templates in the templates\ directory, and then
> there can be templates in the generator/ directory. They are
> completely separate matters. In the 2nd case, they are just a type of
> a generator files, like json-s are.
>
> > we allow the plugin to operate in an alternate mode,
> > enabled by configuration, say by setting a "defaultDataModel" parameter.
> In
> > this mode, we generate sources for all templates in the template
> directory
> > from a common data model.
>
> My idea was that the we only ever generate output files for what's in
> the generator directory. There can be files both in generators/ and
> templates/, but hey have a different role. Templates in templates/ are
> just dependencies of some generators/ (the jsons, in this case), or
> maybe they can be #import-ed from templates in generators/.
>
> > In this use case, the project would only use
> > this structure only:
> >
> > /src/main/generated/freemarker/dataModel.xml
>
> NYW, I think for a dataModel it's important that it can come from
> various places, like even from a database. So we should keep that in
> mind.
>
> > /src/main/generated/freemarker/templates/...
> >
> > Having said all of this, I think the changes we would make in the short
> > term would be to update the json structure to include the dataModel as a
> > subtree, and to change the default locations to use the /generated
> > subdirectory rather than /data, and whatever suggestion is appropriate.
> >
> > -Ben
> >
> > On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com>
> wrote:
> >
> >> Yes, this makes sense.
> >>
> >> -Ben
> >>
> >> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org>
> wrote:
> >>
> >>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
> >>>
> >>> [snip]
> >>> > 3) I agree that using the well known json field 'templateName' seems
> >>> > 'hacky' (from a freemarker point of view). However, from the point of
> >>> view
> >>> > of the maven plugin it works nice. It provides the flexibility I need
> >>> with
> >>> > the minimum fuss. I will entertain another mechanism as long as it
> >>> supports
> >>> > my main use case.
> >>> [snip]
> >>>
> >>> The problem with that is that it doesn't work if you happen to need a
> >>> "tempalteName" field in your actual data. Yes, that's unlikely, but
> >>> take it as a demonstration of why it's not correct. The "correct"
> solution
> >>> is like this:
> >>>
> >>> {
> >>> "templateName": "foo.ftl",
> >>> "otherFutureMavenPluginKey": "something",
> >>> "dataModel": {
> >>> /* your application-specific stuff */
> >>> "myString": "a string",
> >>> "myNumber": 1,
> >>> ...
> >>> }
> >>> }
> >>>
> >>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
> >>> without breaking backward compatibility.
> >>>
> >>> --
> >>> Thanks,
> >>> Daniel Dekany
> >>>
> >>>
> >>
> >>
> >> --
> >> Benjamin Grant Jackson
> >>
> >
> >
> >
>
> --
> Thanks,
> Daniel Dekany
>
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Friday, August 17, 2018, 12:36:51 AM, Ben Jackson wrote:
> Here is my summary of the conversation and my take on it.
>
> There are two primary use cases discussed in the thread.
>
> 1. Multiple templates instantiated in multiple ways (with multiple "data
> models"). This was our use case.
> 2. A bunch of templates being instantiated based on a single shared "data
> model"
>
> So how to best bring together the "data model" and the "template" to fit
> these use cases with minimal overhead?
> There is the generic way which is to list out all of the templates and data
> models in separate locations, and then to bring together the templates and
> data models via some configuration. In this world, a structure might be:
>
> (@daniel you seem concerend by the default location being /src/main/freemarker,
> do you have a better idea in mind?)
My approach is that this is a product, and products has a somewhat
unique (basically means searchable) name. Calling this just the
"Apache FreeMarker Maven Plugin" is problematic for that reason. For
starters, it's functionality is not very much Maven specific, so it
might as well will be callable from Gradle, or directly from command
line (if you modularize it like that). Also there are a few other
FreeMarker Maven Plugins, which makes searching for related content on
the web hard. If we have a product name, then it's also obvious what
the directory name will be. So, let's say, it's "Apache FreeMarker
FGen" (maybe a stupid name, but just as an example), then, you have
/src/main/fgen, and when someone sees it and Googles it, he will find
what that does.
> /src/main/generated/freemarker/dataModels - data models
> /src/main/generated/freemarker/templates - freemarker templates
> /src/main/generated/freemarker/generators - json, one per output file
Note that it wasn't the structure I have suggested, just in case you
(or someone) have missed that. What I said that for case #2, you
simply put templates into generators/. And of course you can have both
ftl and json files inside generators/, each generating its output file
in its own way.
As of dataModel-s, the part of the content the json files is also part
of the data-model, so it's not the best name. It's rather
"shared-dataModel", and in case you specify that directly in the
pom.xml, you don't even need that. And of course, we are talking about
a layered data-model, where there's a shared data model that's visible
from everywhere, and it the case of a json generator file it can adds
another layer on top of that.
> The issue with this more generic structure is that in exchange for this
> flexibility, you might have a bunch of extra files. For example, in the
> special case #2, one needs twice as many files in the above structure.
>
> So instead of the above structure, the suggestion in the thread is to embed
> both of the common use cases into the plugin in a way that they "play nice"
> together.
> Create a generators directory and have the plugin interpret how to generate
> the source based on the type of thing in that directory.
>
> I think that we could instead ask how we might deviate from the above
> generic structure that allows a many-to-many mapping while reusing both
> data models
> and templates in such a way that the two special cases can be naturally
> supported.
>
> The first enhancement is that a generator could optionally embed the data
> model. This handles case #1 if you do not want
> to reuse data models. It also naturally comes from enhancing the
> json structure in the way that Daniel suggested:
>
> {
> "templateName": "foo.ftl",
> "otherFutureMavenPluginKey": "something",
> "dataModel": {
> /* your application-specific stuff */
> "myString": "a string",
> "myNumber": 1,
> ...
> }
> }
>
> Here the other option would be for "dataModel" to refer to a file in the
> "dataModel" directory.
Sure that's a more generic solution. Though usually you don't want to
use a json generator file if you don't want a data-model that's
specific to that generator file.
> I would say that instead of overloading the "generators" directory to also
> include templates,
To clarify, there are templates in the templates\ directory, and then
there can be templates in the generator/ directory. They are
completely separate matters. In the 2nd case, they are just a type of
a generator files, like json-s are.
> we allow the plugin to operate in an alternate mode,
> enabled by configuration, say by setting a "defaultDataModel" parameter. In
> this mode, we generate sources for all templates in the template directory
> from a common data model.
My idea was that the we only ever generate output files for what's in
the generator directory. There can be files both in generators/ and
templates/, but hey have a different role. Templates in templates/ are
just dependencies of some generators/ (the jsons, in this case), or
maybe they can be #import-ed from templates in generators/.
> In this use case, the project would only use
> this structure only:
>
> /src/main/generated/freemarker/dataModel.xml
NYW, I think for a dataModel it's important that it can come from
various places, like even from a database. So we should keep that in
mind.
> /src/main/generated/freemarker/templates/...
>
> Having said all of this, I think the changes we would make in the short
> term would be to update the json structure to include the dataModel as a
> subtree, and to change the default locations to use the /generated
> subdirectory rather than /data, and whatever suggestion is appropriate.
>
> -Ben
>
> On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com> wrote:
>
>> Yes, this makes sense.
>>
>> -Ben
>>
>> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org> wrote:
>>
>>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>>
>>> [snip]
>>> > 3) I agree that using the well known json field 'templateName' seems
>>> > 'hacky' (from a freemarker point of view). However, from the point of
>>> view
>>> > of the maven plugin it works nice. It provides the flexibility I need
>>> with
>>> > the minimum fuss. I will entertain another mechanism as long as it
>>> supports
>>> > my main use case.
>>> [snip]
>>>
>>> The problem with that is that it doesn't work if you happen to need a
>>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>>> take it as a demonstration of why it's not correct. The "correct" solution
>>> is like this:
>>>
>>> {
>>> "templateName": "foo.ftl",
>>> "otherFutureMavenPluginKey": "something",
>>> "dataModel": {
>>> /* your application-specific stuff */
>>> "myString": "a string",
>>> "myNumber": 1,
>>> ...
>>> }
>>> }
>>>
>>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>>> without breaking backward compatibility.
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>>
>>
>>
>> --
>> Benjamin Grant Jackson
>>
>
>
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
Here is my summary of the conversation and my take on it.
There are two primary use cases discussed in the thread.
1. Multiple templates instantiated in multiple ways (with multiple "data
models"). This was our use case.
2. A bunch of templates being instantiated based on a single shared "data
model"
So how to best bring together the "data model" and the "template" to fit
these use cases with minimal overhead?
There is the generic way which is to list out all of the templates and data
models in separate locations, and then to bring together the templates and
data models via some configuration. In this world, a structure might be:
(@daniel you seem concerend by the default location being /src/main/freemarker,
do you have a better idea in mind?)
/src/main/generated/freemarker/dataModels - data models
/src/main/generated/freemarker/templates - freemarker templates
/src/main/generated/freemarker/generators - json, one per output file
The issue with this more generic structure is that in exchange for this
flexibility, you might have a bunch of extra files. For example, in the
special case #2, one needs twice as many files in the above structure.
So instead of the above structure, the suggestion in the thread is to embed
both of the common use cases into the plugin in a way that they "play nice"
together.
Create a generators directory and have the plugin interpret how to generate
the source based on the type of thing in that directory.
I think that we could instead ask how we might deviate from the above
generic structure that allows a many-to-many mapping while reusing both
data models
and templates in such a way that the two special cases can be naturally
supported.
The first enhancement is that a generator could optionally embed the data
model. This handles case #1 if you do not want
to reuse data models. It also naturally comes from enhancing the
json structure in the way that Daniel suggested:
{
"templateName": "foo.ftl",
"otherFutureMavenPluginKey": "something",
"dataModel": {
/* your application-specific stuff */
"myString": "a string",
"myNumber": 1,
...
}
}
Here the other option would be for "dataModel" to refer to a file in the
"dataModel" directory.
I would say that instead of overloading the "generators" directory to also
include templates, we allow the plugin to operate in an alternate mode,
enabled by configuration, say by setting a "defaultDataModel" parameter. In
this mode, we generate sources for all templates in the template directory
from a common data model. In this use case, the project would only use
this structure only:
/src/main/generated/freemarker/dataModel.xml
/src/main/generated/freemarker/templates/...
Having said all of this, I think the changes we would make in the short
term would be to update the json structure to include the dataModel as a
subtree, and to change the default locations to use the /generated
subdirectory rather than /data, and whatever suggestion is appropriate.
-Ben
On Thu, Aug 16, 2018 at 4:18 PM, Ben Jackson <ph...@gmail.com> wrote:
> Yes, this makes sense.
>
> -Ben
>
> On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org> wrote:
>
>> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>>
>> [snip]
>> > 3) I agree that using the well known json field 'templateName' seems
>> > 'hacky' (from a freemarker point of view). However, from the point of
>> view
>> > of the maven plugin it works nice. It provides the flexibility I need
>> with
>> > the minimum fuss. I will entertain another mechanism as long as it
>> supports
>> > my main use case.
>> [snip]
>>
>> The problem with that is that it doesn't work if you happen to need a
>> "tempalteName" field in your actual data. Yes, that's unlikely, but
>> take it as a demonstration of why it's not correct. The "correct" solution
>> is like this:
>>
>> {
>> "templateName": "foo.ftl",
>> "otherFutureMavenPluginKey": "something",
>> "dataModel": {
>> /* your application-specific stuff */
>> "myString": "a string",
>> "myNumber": 1,
>> ...
>> }
>> }
>>
>> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
>> without breaking backward compatibility.
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>>
>
>
> --
> Benjamin Grant Jackson
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Ben Jackson <ph...@gmail.com>.
Yes, this makes sense.
-Ben
On Thu, Aug 16, 2018 at 2:56 PM, Daniel Dekany <dd...@apache.org> wrote:
> Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
>
> [snip]
> > 3) I agree that using the well known json field 'templateName' seems
> > 'hacky' (from a freemarker point of view). However, from the point of
> view
> > of the maven plugin it works nice. It provides the flexibility I need
> with
> > the minimum fuss. I will entertain another mechanism as long as it
> supports
> > my main use case.
> [snip]
>
> The problem with that is that it doesn't work if you happen to need a
> "tempalteName" field in your actual data. Yes, that's unlikely, but
> take it as a demonstration of why it's not correct. The "correct" solution
> is like this:
>
> {
> "templateName": "foo.ftl",
> "otherFutureMavenPluginKey": "something",
> "dataModel": {
> /* your application-specific stuff */
> "myString": "a string",
> "myNumber": 1,
> ...
> }
> }
>
> Note how it allows adding new keys (like "otherFutureMavenPluginKey")
> without breaking backward compatibility.
>
> --
> Thanks,
> Daniel Dekany
>
>
--
Benjamin Grant Jackson
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Wednesday, August 15, 2018, 10:52:41 PM, Mark Malynn wrote:
[snip]
> 3) I agree that using the well known json field 'templateName' seems
> 'hacky' (from a freemarker point of view). However, from the point of view
> of the maven plugin it works nice. It provides the flexibility I need with
> the minimum fuss. I will entertain another mechanism as long as it supports
> my main use case.
[snip]
The problem with that is that it doesn't work if you happen to need a
"tempalteName" field in your actual data. Yes, that's unlikely, but
take it as a demonstration of why it's not correct. The "correct" solution
is like this:
{
"templateName": "foo.ftl",
"otherFutureMavenPluginKey": "something",
"dataModel": {
/* your application-specific stuff */
"myString": "a string",
"myNumber": 1,
...
}
}
Note how it allows adding new keys (like "otherFutureMavenPluginKey")
without breaking backward compatibility.
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Mark Malynn <ma...@gmail.com>.
Hi Woonsan,
Before writing our freemarker-maven-plugin, I looked for a maven templating
plugin that would meet our needs and could not find one. The basic
limitation of those existing plugins is that I could only generate one
source file per template file. I needed to be able to generate multiple
source files per template file.
With regards to your inline comments:
1) I separated template and data directories because it was easier to code
and I happen to like that organization better. I'd be willing to add
support for just one directory that contains both templates and data models
(and I'd be willing to have that be the default configuration).
2) Using a naming convention to identify the template (from the name of
the json file) prevents my main use case (to generate multiple class source
files using the same template).
3) I agree that using the well known json field 'templateName' seems
'hacky' (from a freemarker point of view). However, from the point of view
of the maven plugin it works nice. It provides the flexibility I need with
the minimum fuss. I will entertain another mechanism as long as it supports
my main use case.
-Mark
On Wed, Aug 15, 2018 at 11:02 AM, Woonsan Ko <wo...@apache.org> wrote:
> Hi Benjamin,
>
> Thanks for the proposal.
> IIUC, it looks similar to maven-velocity-plugin [1], which generates
> .java files based on Velocity template files with configured
> parameters (models).
> But, the module on your end reads models from .json file in addition.
> Am I in correct understanding? If so, the scope should not be too big.
> It could be useful to many people.
> Please see my comments inline below as well.
>
> [1] https://github.com/nativelibs4java/maven-velocity-plugin
>
>
> On Tue, Aug 14, 2018 at 12:08 PM, Ben Jackson <ph...@gmail.com> wrote:
> > Hello,
> >
> > My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
> > internal Oath (e.g. Yahoo/AOL) project that we are intending to open
> > source. This project is an Immutable Offheap Cache which is used to store
> > and access data off-heap for high-performance java server applications.
> >
> > As a part of our offering, we provide out of the box primitive
> collections
> > classes that mirror FastUtils, and we are using Freemarker to generate
> > source files needed to implement those primitive collections.
> >
> > Mark built a Maven plugin for Freemarker that we use as a part of our
> build
> > process. We built this because the Freemarker project does not provide
> one
> > natively and other plugins we found do not offer the power level we
> needed
> > (we generate sources from multiple templates during both build and test
> > phases of the pipeline).
> >
> > When working with our internal open sourcing team, they suggested that we
> > first reach out to you to gauge interest in hosting this plugin as a part
> > of the Freemarker project. This made sense to us as well.
> >
> > Please let us know if it makes sense to contribute this as a part of
> > Freemarker. We can support it as needed.
> >
> > Below the is the existing project README.md:
> > freemarker-maven-plugin Background
> >
> > This plugin is used to generate files using FreeMarker template files and
> > JSON data files.
> > FreeMarker Template Files
> >
> > FreeMarker template files must reside in the template sub-directory under
> > the sourceDirectory. For the default configuration, this is:
> > src/main/freemarker/template.
> Why not simply src/main/freemarker?
>
> >
> > By convention, file names for FreeMarker template files use the .ftl
> > extension. For details on the FreeMarker template syntax, see: Getting
> > Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
> > Template Language Reference <https://freemarker.apache.org/docs/ref.html
> >.
> > JSON Data Files
> >
> > The JSON data files must reside in the data sub-directory under
> > sourceDirectory. For the default configuration, this is:
> > src/main/freemarker/data.
> Why not simply with a different extension? e.g,
> src/main/freemarker/com/example/MyClass.ftl.data.json for
> src/main/freemarker/com/example/MyClass.ftl.
>
> >
> > For each JSON data file, freemarker-maven-plugin will generate a file
> under
> > the outputDirectory. The name of the generated file will be based on the
> > name of the JSON data file. For example, the following JSON file:
> >
> > <sourceDirectory>/data/my/package/MyClass.java.json
> >
> > will result in the following file being generated:
> >
> > <outputDirectory>/my/package/MyClass.java
> >
> > This plugin parses the JSON data file into a Map<String, Object> instance
> > (hereafter, referred
> > to as the data map). The parser allows for comments. After parsing the
> > file, the plugin will add
> > a pomProperties entry into the data map, which is itself a map containing
> > the properties defined in the pom. Thus, your template can reference the
> > pom property my_property using
> > ${pomProperties.my_property}. If you have a period or dash in the
> property
> > name, use
> > ${pomProperties["my.property"]}.
> >
> > This plugin requires one top-level field in the JSON data file:
> templateName.
> > This field
> > is used to locate the template file under <sourceDirectory>/template that
> > is used to generate
> > the file. This plugin provides the data map to FreeMarker as the data
> model
> > to process the template identified by templateName.
> >
> > This plugin currently assumes that the JSON data file encoded using
> UTF-8.
> >
> > Example JSON data file:
> >
> > {
> > // An end-of-line comment.
> > # Another end-of-line comment
> > "templateName": "my-template.ftl",
> > /* A multi-line
> > comment */
> > "myString": "a string",
> > "myNumber": 1,
> > "myListOfStrings": ["s1", "s2"],
> > "myListOfNumbers": [1, 2],
> > "myMap": {
> > "key1": "value1",
> > "key2": 2
> > }
> > }
> Isn't the json file intended for model provision to the FreeMarker
> template?
> If so, it doesn't look good to me to have "templateName" in the model
> json file. Convention might be better as mentioned above.
>
> Regards,
>
> Woonsan
>
> >
> > Installation pom.xml
> >
> > Add the following snippet within the <plugins> tag of your pom.xml:
> >
> > <plugin>
> > <groupId>com.oath</groupId>
> > <artifactId>freemarker-maven-plugin</artifactId>
> > <version>${freemarker-maven-plugin.version}</version>
> > <configuration>
> > <!-- Required. Specifies the compatibility version for
> > template processing -->
> > <freeMarkerVersion>2.3.23</freeMarkerVersion>
> > </configuration>
> > <executions>
> > <!-- If you want to generate files during other phases, just
> > add more execution
> > tags and specify appropriate phase, sourceDirectory and
> > outputDirectory values.
> > -->
> > <execution>
> > <id>freemarker</id>
> > <!-- Optional, defaults to generate-sources -->
> > <phase>generate-sources</phase>
> > <goals>
> > <!-- Required, must be generate -->
> > <goal>generate</goal>
> > </goals>
> > <configuration>
> > <!-- Optional, defaults to src/main/freemarker -->
> > <sourceDirectory>src/main/freemarker</sourceDirectory>
> > <!-- Optional, defaults to target/generated-sources/freemarker
> -->
> > <outputDirectory>target/generated-sources/freemarker</
> outputDirectory>
> > </configuration>
> > </execution>
> > </executions>
> > </plugin>
> >
> > Usage FreeMarker Configuration
> >
> > Typically, users of this plugin do not need to mess with the FreeMarker
> > configuration. This plugin explicitly sets two FreeMarker configurations:
> >
> > 1. the default encoding is set to UTF-8
> > 2. the template loader is set to be a FileTemplateLoader that reads
> from
> > <sourceDirectory>/template.
> >
> > If you need to override these configs or set your own, you can put them
> in a
> > <sourceDirectory>/freemarker.properties file. If that file exists, this
> > plugin will read it into
> > a java Properties instance and pass it to
> > freemarker.core.Configurable.setSettings() to establish
> > the FreeMarker configuration. See this javadoc
> > <https://freemarker.apache.org/docs/api/freemarker/
> template/Configuration.html#setSetting-java.lang.String-java.lang.String->
> > for configuration details.
> > Code Coverage
> >
> > By default the code coverage report is not generated. You can generate
> code
> > coverage on your dev machine with the following maven command:
> >
> > mvn clean initialize -Dclover-phase=initialize
> >
> > Bring up the coverage report by pointing your browser to
> > target/site/clover/dashboard.html
> > under the root directory of the local repository.
> > Contribute
> >
> > See Contributing.md
> > License
> >
> > Licenced under the Apache 2.0 license. See: LICENSE.txt
> >
> > —
> > Benjamin Grant Jackson
>
Re: Freemarker Maven Plugin
Posted by Daniel Dekany <dd...@apache.org>.
Wednesday, August 15, 2018, 8:02:06 PM, Woonsan Ko wrote:
[...]
> Isn't the json file intended for model provision to the FreeMarker template?
> If so, it doesn't look good to me to have "templateName" in the model
> json file. Convention might be better as mentioned above.
[...]
My understanding is that you have one json file per output file. In
that approach it's logical that the json file chooses the template.
(Multiple json files may use the same template to generate a file
based on the other data contained inside the json file.)
The more generic approach is that the json file (or whatever format it
should use) chooses both the template and the data file (other than
itself).
> Regards,
>
> Woonsan
>
>>
>> Installation pom.xml
>>
>> Add the following snippet within the <plugins> tag of your pom.xml:
>>
>> <plugin>
>> <groupId>com.oath</groupId>
>> <artifactId>freemarker-maven-plugin</artifactId>
>> <version>${freemarker-maven-plugin.version}</version>
>> <configuration>
>> <!-- Required. Specifies the compatibility version for
>> template processing -->
>> <freeMarkerVersion>2.3.23</freeMarkerVersion>
>> </configuration>
>> <executions>
>> <!-- If you want to generate files during other phases, just
>> add more execution
>> tags and specify appropriate phase, sourceDirectory and
>> outputDirectory values.
>> -->
>> <execution>
>> <id>freemarker</id>
>> <!-- Optional, defaults to generate-sources -->
>> <phase>generate-sources</phase>
>> <goals>
>> <!-- Required, must be generate -->
>> <goal>generate</goal>
>> </goals>
>> <configuration>
>> <!-- Optional, defaults to src/main/freemarker -->
>> <sourceDirectory>src/main/freemarker</sourceDirectory>
>> <!-- Optional, defaults to target/generated-sources/freemarker -->
>> <outputDirectory>target/generated-sources/freemarker</outputDirectory>
>> </configuration>
>> </execution>
>> </executions>
>> </plugin>
>>
>> Usage FreeMarker Configuration
>>
>> Typically, users of this plugin do not need to mess with the FreeMarker
>> configuration. This plugin explicitly sets two FreeMarker configurations:
>>
>> 1. the default encoding is set to UTF-8
>> 2. the template loader is set to be a FileTemplateLoader that reads from
>> <sourceDirectory>/template.
>>
>> If you need to override these configs or set your own, you can put them in a
>> <sourceDirectory>/freemarker.properties file. If that file exists, this
>> plugin will read it into
>> a java Properties instance and pass it to
>> freemarker.core.Configurable.setSettings() to establish
>> the FreeMarker configuration. See this javadoc
>> <https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
>> for configuration details.
>> Code Coverage
>>
>> By default the code coverage report is not generated. You can generate code
>> coverage on your dev machine with the following maven command:
>>
>> mvn clean initialize -Dclover-phase=initialize
>>
>> Bring up the coverage report by pointing your browser to
>> target/site/clover/dashboard.html
>> under the root directory of the local repository.
>> Contribute
>>
>> See Contributing.md
>> License
>>
>> Licenced under the Apache 2.0 license. See: LICENSE.txt
>>
>> —
>> Benjamin Grant Jackson
>
--
Thanks,
Daniel Dekany
Re: Freemarker Maven Plugin
Posted by Woonsan Ko <wo...@apache.org>.
Hi Benjamin,
Thanks for the proposal.
IIUC, it looks similar to maven-velocity-plugin [1], which generates
.java files based on Velocity template files with configured
parameters (models).
But, the module on your end reads models from .json file in addition.
Am I in correct understanding? If so, the scope should not be too big.
It could be useful to many people.
Please see my comments inline below as well.
[1] https://github.com/nativelibs4java/maven-velocity-plugin
On Tue, Aug 14, 2018 at 12:08 PM, Ben Jackson <ph...@gmail.com> wrote:
> Hello,
>
> My colleague Mark Malynn (CC’d) has been using apache Freemarker on an
> internal Oath (e.g. Yahoo/AOL) project that we are intending to open
> source. This project is an Immutable Offheap Cache which is used to store
> and access data off-heap for high-performance java server applications.
>
> As a part of our offering, we provide out of the box primitive collections
> classes that mirror FastUtils, and we are using Freemarker to generate
> source files needed to implement those primitive collections.
>
> Mark built a Maven plugin for Freemarker that we use as a part of our build
> process. We built this because the Freemarker project does not provide one
> natively and other plugins we found do not offer the power level we needed
> (we generate sources from multiple templates during both build and test
> phases of the pipeline).
>
> When working with our internal open sourcing team, they suggested that we
> first reach out to you to gauge interest in hosting this plugin as a part
> of the Freemarker project. This made sense to us as well.
>
> Please let us know if it makes sense to contribute this as a part of
> Freemarker. We can support it as needed.
>
> Below the is the existing project README.md:
> freemarker-maven-plugin Background
>
> This plugin is used to generate files using FreeMarker template files and
> JSON data files.
> FreeMarker Template Files
>
> FreeMarker template files must reside in the template sub-directory under
> the sourceDirectory. For the default configuration, this is:
> src/main/freemarker/template.
Why not simply src/main/freemarker?
>
> By convention, file names for FreeMarker template files use the .ftl
> extension. For details on the FreeMarker template syntax, see: Getting
> Started <https://freemarker.apache.org/docs/dgui_quickstart.html> and
> Template Language Reference <https://freemarker.apache.org/docs/ref.html>.
> JSON Data Files
>
> The JSON data files must reside in the data sub-directory under
> sourceDirectory. For the default configuration, this is:
> src/main/freemarker/data.
Why not simply with a different extension? e.g,
src/main/freemarker/com/example/MyClass.ftl.data.json for
src/main/freemarker/com/example/MyClass.ftl.
>
> For each JSON data file, freemarker-maven-plugin will generate a file under
> the outputDirectory. The name of the generated file will be based on the
> name of the JSON data file. For example, the following JSON file:
>
> <sourceDirectory>/data/my/package/MyClass.java.json
>
> will result in the following file being generated:
>
> <outputDirectory>/my/package/MyClass.java
>
> This plugin parses the JSON data file into a Map<String, Object> instance
> (hereafter, referred
> to as the data map). The parser allows for comments. After parsing the
> file, the plugin will add
> a pomProperties entry into the data map, which is itself a map containing
> the properties defined in the pom. Thus, your template can reference the
> pom property my_property using
> ${pomProperties.my_property}. If you have a period or dash in the property
> name, use
> ${pomProperties["my.property"]}.
>
> This plugin requires one top-level field in the JSON data file: templateName.
> This field
> is used to locate the template file under <sourceDirectory>/template that
> is used to generate
> the file. This plugin provides the data map to FreeMarker as the data model
> to process the template identified by templateName.
>
> This plugin currently assumes that the JSON data file encoded using UTF-8.
>
> Example JSON data file:
>
> {
> // An end-of-line comment.
> # Another end-of-line comment
> "templateName": "my-template.ftl",
> /* A multi-line
> comment */
> "myString": "a string",
> "myNumber": 1,
> "myListOfStrings": ["s1", "s2"],
> "myListOfNumbers": [1, 2],
> "myMap": {
> "key1": "value1",
> "key2": 2
> }
> }
Isn't the json file intended for model provision to the FreeMarker template?
If so, it doesn't look good to me to have "templateName" in the model
json file. Convention might be better as mentioned above.
Regards,
Woonsan
>
> Installation pom.xml
>
> Add the following snippet within the <plugins> tag of your pom.xml:
>
> <plugin>
> <groupId>com.oath</groupId>
> <artifactId>freemarker-maven-plugin</artifactId>
> <version>${freemarker-maven-plugin.version}</version>
> <configuration>
> <!-- Required. Specifies the compatibility version for
> template processing -->
> <freeMarkerVersion>2.3.23</freeMarkerVersion>
> </configuration>
> <executions>
> <!-- If you want to generate files during other phases, just
> add more execution
> tags and specify appropriate phase, sourceDirectory and
> outputDirectory values.
> -->
> <execution>
> <id>freemarker</id>
> <!-- Optional, defaults to generate-sources -->
> <phase>generate-sources</phase>
> <goals>
> <!-- Required, must be generate -->
> <goal>generate</goal>
> </goals>
> <configuration>
> <!-- Optional, defaults to src/main/freemarker -->
> <sourceDirectory>src/main/freemarker</sourceDirectory>
> <!-- Optional, defaults to target/generated-sources/freemarker -->
> <outputDirectory>target/generated-sources/freemarker</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> Usage FreeMarker Configuration
>
> Typically, users of this plugin do not need to mess with the FreeMarker
> configuration. This plugin explicitly sets two FreeMarker configurations:
>
> 1. the default encoding is set to UTF-8
> 2. the template loader is set to be a FileTemplateLoader that reads from
> <sourceDirectory>/template.
>
> If you need to override these configs or set your own, you can put them in a
> <sourceDirectory>/freemarker.properties file. If that file exists, this
> plugin will read it into
> a java Properties instance and pass it to
> freemarker.core.Configurable.setSettings() to establish
> the FreeMarker configuration. See this javadoc
> <https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#setSetting-java.lang.String-java.lang.String->
> for configuration details.
> Code Coverage
>
> By default the code coverage report is not generated. You can generate code
> coverage on your dev machine with the following maven command:
>
> mvn clean initialize -Dclover-phase=initialize
>
> Bring up the coverage report by pointing your browser to
> target/site/clover/dashboard.html
> under the root directory of the local repository.
> Contribute
>
> See Contributing.md
> License
>
> Licenced under the Apache 2.0 license. See: LICENSE.txt
>
> —
> Benjamin Grant Jackson