Skip to content

Commit

Permalink
2021.9.371
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Oct 3, 2021
1 parent 7d2b135 commit 7c8185a
Show file tree
Hide file tree
Showing 22 changed files with 391 additions and 124 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ while test ! -z "$1" ; do
;;
-install*)
(cd $bDIR && mvn clean install $OPTS) || exit 1
(test -e ~/bin/template-cli.sh && cd $bDIR && cp template-cli/target/bin/template-cli*.sh.bin ~/bin/template-cli.sh)
(test -e ~/bin/template-cli.sh && cd $bDIR && cp template-cli/target/bin/template-cli*.bin ~/bin/template-cli.sh)
;;
-deps)
(cd $bDIR && mvn org.apache.maven.plugins:maven-dependency-plugin:tree) || exit 1
Expand Down
7 changes: 0 additions & 7 deletions examples/script.py

This file was deleted.

8 changes: 8 additions & 0 deletions examples/with_args.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$_log.info("test info log")


$_log.info("#{$ARGV}")

puts($_id)

return true;
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.terefang.template</groupId>
<artifactId>template</artifactId>
<version>2021.5.361</version>
<version>2021.9.371</version>
<modules>
<module>template-cli</module>
<module>template-maven-plugin</module>
Expand All @@ -29,7 +29,8 @@
<maven.version>3.6.3</maven.version>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMdd'.'HHmm</maven.build.timestamp.format>
<version.jmelange>2021.7.147</version.jmelange>
<version.jmelange>2021.9.153</version.jmelange>
<version.slf4j>1.7.30</version.slf4j>
</properties>

<scm>
Expand Down
4 changes: 2 additions & 2 deletions template-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>template</artifactId>
<groupId>com.github.terefang.template</groupId>
<version>2021.5.361</version>
<version>2021.9.371</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>com.google.code.sqlsheet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import com.github.terefang.template_maven_plugin.groovy.*;
import com.github.terefang.template_maven_plugin.jexl.*;
import com.github.terefang.template_maven_plugin.jinjava.*;
import com.github.terefang.template_maven_plugin.jruby.JRubyEspStandardMojo;
import com.github.terefang.template_maven_plugin.jruby.JRubyEspTemplateMojo;
import com.github.terefang.template_maven_plugin.jruby.JRubyStandardMojo;
import com.github.terefang.template_maven_plugin.jruby.JRubyTemplateMojo;
import com.github.terefang.template_maven_plugin.rhino.RhinoEspStandardMojo;
import com.github.terefang.template_maven_plugin.rhino.RhinoEspTemplateMojo;
import com.github.terefang.template_maven_plugin.rhino.RhinoStandardMojo;
import com.github.terefang.template_maven_plugin.rhino.RhinoTemplateMojo;
import com.github.terefang.template_maven_plugin.thymeleaf.*;
Expand All @@ -19,6 +25,7 @@
import org.codehaus.plexus.util.StringUtils;
import picocli.CommandLine;
import java.io.File;
import java.util.Collections;

public class TemplateCliMain
{
Expand Down Expand Up @@ -127,6 +134,19 @@ public static void main(String[] _args)
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.JRUBY))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
|| _opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STD))
{
_smojo = new JRubyStandardMojo();
}
else
{
_tmojo = new JRubyTemplateMojo();
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.GSIMPLE))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
Expand All @@ -153,7 +173,8 @@ public static void main(String[] _args)
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.ECMA))
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.ECMA)
||_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.RHINO))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
|| _opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STD))
Expand All @@ -166,6 +187,45 @@ public static void main(String[] _args)
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.RHINO_ESP))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
|| _opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STD))
{
_smojo = new RhinoEspStandardMojo();
}
else
{
_tmojo = new RhinoEspTemplateMojo();
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.JRUBY_ESP))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
|| _opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STD))
{
_smojo = new JRubyEspStandardMojo();
}
else
{
_tmojo = new JRubyEspTemplateMojo();
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.JEXL_ESP))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
|| _opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STD))
{
_smojo = new JexlEspStandardMojo();
}
else
{
_tmojo = new JexlEspTemplateMojo();
}
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.THYMELEAF))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
Expand Down Expand Up @@ -243,12 +303,15 @@ public static void executeScript(TemplateCliLogger _log, TemplateCliOptions _opt
try
{
ScriptMojo _sm = new ScriptMojo();

_sm.setLog(_log);
_sm.setScriptFile(_opts.getResourcesDirectory());
_sm.setDataFile(_opts.getAdditionalContext());
_sm.setDataContextRoot(_opts.getAdditionalContextRoot());
_sm.setOutputDirectory(_opts.getResourcesOutput());
_sm.setAdditionalVariables(_opts.getAdditionalVariables());
_sm.setArguments(_opts.getArguments()!=null ? _opts.getArguments() : Collections.EMPTY_LIST);

_sm.execute();
}
catch (MojoExecutionException _me)
Expand Down Expand Up @@ -363,10 +426,13 @@ public static void setSharedMojoParameters(AbstractTmpMojo _mojo, TemplateCliOpt
{
_mojo.setIncludePath(_opts.getIncludePath());
_mojo.setOutputType(_opts.getOutputType().toString());

_mojo.setAdditionalContext(_opts.getAdditionalContext());
_mojo.setAdditionalContextRoot(_opts.getAdditionalContextRoot());
_mojo.setAdditionalVariables(_opts.getAdditionalVariables());

_mojo.setArguments(_opts.getArguments()!=null ? _opts.getArguments() : Collections.EMPTY_LIST);

if(StringUtils.isNotEmpty(_opts.getJdbcUrl()))
{
_mojo.setJdbcUrl(_opts.getJdbcUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Data
public class TemplateCliOptions
{
public static enum TemplateEngineName { THYMELEAF, JINJAVA, ECMA, JXLT, JEXL, GSIMPLE, GROOVY, FREEMARKER, TRIMOU, PREPROCESSOR, CONCAT, ToJSON, ToHSON, ToPDATA, SCRIPT}
public static enum TemplateEngineName { THYMELEAF, JINJAVA, ECMA, RHINO, JXLT, JEXL, GSIMPLE, GROOVY, JRUBY, JEXL_ESP, JRUBY_ESP, RHINO_ESP, FREEMARKER, TRIMOU, PREPROCESSOR, CONCAT, ToJSON, ToHSON, ToPDATA, SCRIPT}

@CommandLine.Option(order = 10, names = {"-T", "--template-engine"}, paramLabel = "ENGINE", description = "name of the templating engine, ${COMPLETION-CANDIDATES}", required = true)
public TemplateEngineName doEngine;
Expand Down Expand Up @@ -42,7 +42,7 @@ public static enum OutputType { TEXT, XML, HTML, JAVASCRIPT, SVG, PNG, PDF, XLS,
@CommandLine.Option(order = 65, names = {"--jdbc-pass"}, paramLabel = "PASS", defaultValue = "", required = false)
public String jdbcPassWord;

@CommandLine.Option(order = 65, names = {"--jdbc-driver"}, paramLabel = "PASS", defaultValue = "", required = false)
@CommandLine.Option(order = 65, names = {"--jdbc-driver"}, paramLabel = "DRIVER", defaultValue = "", required = false)
public String jdbcDriver;

/* shared Variables */
Expand Down Expand Up @@ -102,4 +102,7 @@ public static enum OutputType { TEXT, XML, HTML, JAVASCRIPT, SVG, PNG, PDF, XLS,

@CommandLine.Option(order = 150, names = {"--inc-path", "--include-path"}, description = "include paths for groovy/luaj script (default: ${DEFAULT-VALUE})", required = false, defaultValue = ".")
protected List<String> includePath;

@CommandLine.Unmatched
protected List<String> arguments;
}
19 changes: 19 additions & 0 deletions template-cli/src/test/java/TestScriptingWithArgs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import com.github.terefang.template_cli.TemplateCliMain;

public class TestScriptingWithArgs {
static String[] ARGS = {
"-T", "SCRIPT", "-M", "SCRIPT",
"-D", "examples/",
"-S", "examples/with_args.rb",
"--additional-context-file", "examples/data.pdx",
"--additional-variables", "_out_dir=examples",
"--",
"this",
"are",
"additional",
"args",
};
public static void main(String[] args) {
TemplateCliMain.main(ARGS);
}
}
Loading

0 comments on commit 7c8185a

Please sign in to comment.