Skip to content

Commit

Permalink
2021.5.351
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Apr 28, 2021
1 parent 3e7bc10 commit 1e77032
Show file tree
Hide file tree
Showing 21 changed files with 409 additions and 703 deletions.
13 changes: 0 additions & 13 deletions .idea/libraries/Maven__com_google_code_gson_gson_2_8_1.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__com_moandjiezana_toml_toml4j_0_7_2.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__commons_logging_commons_logging_1_2.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__org_hjson_hjson_3_0_0.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__org_jsoup_jsoup_1_10_3.xml

This file was deleted.

7 changes: 7 additions & 0 deletions examples/script.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
println(_out_dir);

println(_ctx);

println(__.randomGUID());

return 1;
7 changes: 7 additions & 0 deletions examples/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
print(_out_dir)

print(_ctx)

print(__.randomGUID())

_result = 1
1 change: 1 addition & 0 deletions examples/test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ println(_out_dir);

println(_ctx);

return 1;
4 changes: 2 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.4.349</version>
<version>2021.5.351</version>
<modules>
<module>template-cli</module>
<module>template-maven-plugin</module>
Expand All @@ -29,7 +29,7 @@
<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.4.115</version.jmelange>
<version.jmelange>2021.5.125</version.jmelange>
</properties>

<scm>
Expand Down
27 changes: 2 additions & 25 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.4.349</version>
<version>2021.5.351</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -136,22 +136,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.ntcomputer</groupId>
<artifactId>executable-packer-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>pack-executable-jar</goal>
</goals>
<configuration>
<mainClass>com.github.terefang.template_cli.TemplateCliMain</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand Down Expand Up @@ -183,20 +167,13 @@
<concat destfile="${project.build.directory}/bin/${project.artifactId}-${project.version}.sh.bin"
binary="true">
<fileset file="${project.basedir}/src/main/dist/stub.sh"/>
<fileset
file="${project.build.directory}/${project.artifactId}-${project.version}-pkg.jar"/>
</concat>

<concat destfile="${project.build.directory}/bin/${project.artifactId}-${project.version}.shaded.sh.bin"
binary="true">
<fileset file="${project.basedir}/src/main/dist/stub.sh"/>
<fileset
file="${project.build.directory}/${project.artifactId}-shaded.jar"/>
</concat>

<chmod perm="ugo+rx">
<fileset dir="${project.build.directory}/bin/"
includes="${project.artifactId}.*.bin"/>
includes="${project.artifactId}*.bin"/>
</chmod>
</target>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.terefang.concat_maven_plugin.ConcatMojo;
import com.github.terefang.convert_maven_plugin.*;
import com.github.terefang.preproc_maven_plugin.PreProcessorMojo;
import com.github.terefang.script_maven_plugin.ScriptMojo;
import com.github.terefang.template_maven_plugin.*;
import com.github.terefang.template_maven_plugin.freemarker.*;
import com.github.terefang.template_maven_plugin.groovy.*;
Expand Down Expand Up @@ -75,6 +76,12 @@ public static void main(String[] _args)
AbstractStandardMojo _smojo = null;
AbstractTemplateMojo _tmojo = null;

if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.SCRIPT))
{
executeScript(_log, _opts);
return;
}
else
if(_opts.getDoEngine().equals(TemplateCliOptions.TemplateEngineName.JINJAVA))
{
if(_opts.getDoMode().equals(TemplateCliOptions.TemplateEngineMode.STANDARD)
Expand Down Expand Up @@ -225,6 +232,25 @@ public static void main(String[] _args)
}
}

public static void executeScript(TemplateCliLogger _log, TemplateCliOptions _opts)
{
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.execute();
}
catch (MojoExecutionException _me)
{
_log.error(_me.getMessage(), _me);
}
}

public static void executePreProcessor(TemplateCliLogger _log, TemplateCliOptions _opts)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
@Data
public class TemplateCliOptions
{
public static enum TemplateEngineName { THYMELEAF, JINJAVA, ECMA, JXLT, JEXL, GSIMPLE, GROOVY, FREEMARKER, TRIMOU, PREPROCESSOR, CONCAT, ToJSON, ToHSON, ToPDATA}
public static enum TemplateEngineName { THYMELEAF, JINJAVA, ECMA, JXLT, JEXL, GSIMPLE, GROOVY, 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;

public static enum TemplateEngineMode { STD, STANDARD, TEMPLATE }
public static enum TemplateEngineMode { STD, STANDARD, TEMPLATE, SCRIPT }
@CommandLine.Option(order = 20, names = {"-M", "--engine-mode"}, paramLabel = "MODE", description = "mode of engine operation, ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE})", required = false, defaultValue = "STD")
public TemplateEngineMode doMode;

Expand Down Expand Up @@ -53,7 +53,7 @@ public static enum OutputType { TEXT, XML, HTML, JAVASCRIPT, SVG, PNG, PDF, XLS,
@CommandLine.Option(order = 80, names = {"-X", "--exclude"}, paramLabel = "ANTPATH", description = "exclude specification", required = false)
private String excludes;

@CommandLine.Option(order = 90, names = {"-S", "--src-dir", "--source-directory"}, paramLabel = "DIR", description = "source directory", required = false)
@CommandLine.Option(order = 90, names = {"-S", "--src-dir", "--source-directory", "--script", "--script-file"}, paramLabel = "DIR/SCRIPT", description = "source directory/script", required = false)
private File resourcesDirectory;

@CommandLine.Option(order = 100, names = {"-D", "--dest-dir", "--destination-directory", "--destination"}, paramLabel = "DIR", description = "destination directory/file", required = false)
Expand Down
22 changes: 22 additions & 0 deletions template-cli/src/test/java/TestScripting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import com.github.terefang.template_cli.TemplateCliMain;

public class TestScripting {
static String[] ARGS = {
"-T", "SCRIPT", "-M", "SCRIPT",
"-D", "examples/",
"-S", "examples/script.py",
"--additional-context-file", "examples/data.pdx",
"--additional-variables", "_out_dir=examples" };
public static void main(String[] args) {
TemplateCliMain.main(ARGS);
}
static String[] ARGS2 = {
"-T", "SCRIPT", "-M", "SCRIPT",
"-D", "examples/",
"-S", "examples/script.groovy",
"--additional-context-file", "examples/data.pdx",
"--additional-variables", "_out_dir=examples" };
public static void main2(String[] args) {
TemplateCliMain.main(ARGS);
}
}
Loading

0 comments on commit 1e77032

Please sign in to comment.