From db3108622ce7e6a10965e200dd79da8c0cf62122 Mon Sep 17 00:00:00 2001 From: Richard Perrott <52632091+rwperrott@users.noreply.github.com> Date: Sat, 12 Dec 2020 08:22:25 +0000 Subject: [PATCH] Check in with coordinates: rwperrott.maven.plugins rwperrott-string-template-plugin 2.2.1 --- .gitignore | 8 + README.md | 31 +- Usage.md | 67 +++ pom.xml | 504 ++++++++++++++++++ .../java/rwperrott/maven/plugin/st/Group.java | 288 ++++++++++ .../maven/plugin/st/RenderContext.java | 101 ++++ .../rwperrott/maven/plugin/st/RenderMojo.java | 281 ++++++++++ .../rwperrott/maven/plugin/st/Template.java | 297 +++++++++++ .../rwperrott/maven/plugin/st/UnicodeBOM.java | 51 ++ .../java/rwperrott/maven/plugin/st/Utils.java | 73 +++ 10 files changed, 1700 insertions(+), 1 deletion(-) create mode 100644 Usage.md create mode 100644 pom.xml create mode 100644 src/main/java/rwperrott/maven/plugin/st/Group.java create mode 100644 src/main/java/rwperrott/maven/plugin/st/RenderContext.java create mode 100644 src/main/java/rwperrott/maven/plugin/st/RenderMojo.java create mode 100644 src/main/java/rwperrott/maven/plugin/st/Template.java create mode 100644 src/main/java/rwperrott/maven/plugin/st/UnicodeBOM.java create mode 100644 src/main/java/rwperrott/maven/plugin/st/Utils.java diff --git a/.gitignore b/.gitignore index a1c2a23..18009fd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ # Mobile Tools for Java (J2ME) .mtj.tmp/ +# Maven +/**/target/ + # Package Files # *.jar *.war @@ -21,3 +24,8 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + + +# JetBrains IntelliJ IDEA +/**/.idea/ +/**/*.iml diff --git a/README.md b/README.md index 504b380..1d05d68 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # rwperrott-string-template-plugin -A Maven plugin for running String Template on strings, files or directories. +A Maven plugin for running [StringTemplate](http://www.stringtemplate.org/) on strings, files, or directories of files. + +The plugin is built for Java 1.8, because this is the minimum updated version, because +I need the functional features in it, and Jackson library requires it too. + +## Base options +- The "templateSrcDir" can optionally be specified, with the default being "/src/main/string-template". +## Group options +- Encoding of input files, for STGroupFile and STGroupDir, defaults to Maven source encoding, with optional override. +- Groups all have unique ids, for reference by templates, and to simplify logging messages. +- STGroupString (this needs a CData wrapper), STGroupFile and STGroup files are all supported. +- Registration of AttributeRenders and ModelAdapters on STGroups is supported. +- The plugin optionally allows concurrent running of groups, with optional timeout. +## Template options +- Templates all have ids to simplify logging messages. +- Attributes can optionally be provided via a "jsonAttributes" JSON Map property on templates. +- AutoIndenting can be disabled for template rendering. +- Unicode BOMs can optionally be written at the start of rendered files. +- Encoding of rendered files defaults to Maven source encoding, with override for optional output. +- If any Java files is written in "target/generated-sources" directory, the "target/generated-sources" directory + is automatically added to the compiler sources list +- Template supports optional timeout, but no concurrency, due to lack of action on reported Thread-safety bug, + in STGroup and ST, for about 6 years ago! +## StringTemplate Patches +- I also consider relative template line numbers in rendering error messages a stupid and annoying bug, + so convert these to absolute line number via my "rwperrott-string-template-utils" library. + +See [Usage](Usage.md) for a template POM. + +I doubt that I'll provide "site" code because it's ra \ No newline at end of file diff --git a/Usage.md b/Usage.md new file mode 100644 index 0000000..f148fdc --- /dev/null +++ b/Usage.md @@ -0,0 +1,67 @@ +# Usage + +The configuration template is as follows: + +```xml + + + + rwperrott + string-template-maven-plugin + 2.2.0 + + + + + + + render + + + + + Optional: a relative or absolute base directory for STGroupFiles and STGroupDirs + Optional: if true, stop rendering Groups when the first Group fails or timeouts + Optional: if true, render groups concurrently, using all the CPU cores + + + Required: unique id of group + Required: A string expression, in CDATA section, url/path for a directory, or url/path for a .stg file + Optional: override default source encoding charset name + + class name of an AttributeRenderer implementation + + org.stringtemplate.v4.StringRenderer + + + class name of an ModelAdaptor implementation + + rwperrott.stringtemplate.v4.StringInvokeAdaptor + + Optional: if true, stop rendering Templates when the first fails or timeouts. + Optional: A java.util.concurrent.TimeUnit for timeout of this.call(). + Optional: The duration for timeout of this.call() + + +