diff --git a/build.sh b/build.sh
index 86f8e37..5fa3dab 100755
--- a/build.sh
+++ b/build.sh
@@ -1,13 +1,18 @@
#!/usr/bin/env bash
bDATE=$(date '+%Y%m%d%H%M%S')
-bDIR=$(dirname $0)
-bDIR=$(cd $bDIR && pwd)
+yDATE=$(date '+%Y')
+mDATE=$(date '+%-m')
+bDIR=$(cd $(dirname $0) && pwd)
#OPTS="-DskipTests=true -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=3128 -Dhttps.nonProxyHosts=127.0.0.1"
OPTS="-DskipTests=true"
while test ! -z "$1" ; do
case "$1" in
+ -drel*)
+ (cd $bDIR && mvn -X build-helper:parse-version versions:set \
+ -DnewVersion="${yDATE}.${mDATE}.\${parsedVersion.nextIncrementalVersion}" ) || exit 1
+ ;;
-setversion*)
VALUE="${2}"
(cd $bDIR && mvn build-helper:parse-version versions:set \
diff --git a/pom.xml b/pom.xml
index 2ab3fb6..5f207fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,10 +6,11 @@
com.github.terefang.template
template
- 2022.8.377
+ 2023.11.378
template-cli
template-maven-plugin
+ preproc-maven-plugin
pom
diff --git a/preproc-maven-plugin/pom.xml b/preproc-maven-plugin/pom.xml
new file mode 100644
index 0000000..cadad38
--- /dev/null
+++ b/preproc-maven-plugin/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ template
+ com.github.terefang.template
+ 2023.11.378
+
+ 4.0.0
+
+ preproc-maven-plugin
+
+ maven-plugin
+
+
+
+ commons-codec
+ commons-codec
+ 1.14
+
+
+ org.projectlombok
+ lombok
+ RELEASE
+ provided
+
+
+ org.apache.maven
+ maven-plugin-api
+ ${maven.version}
+ provided
+
+
+ org.apache.maven
+ maven-core
+ ${maven.version}
+ provided
+
+
+ org.apache.maven
+ maven-artifact
+ ${maven.version}
+ provided
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.5.1
+ provided
+
+
+ org.apache.maven
+ maven-compat
+ ${maven.version}
+ test
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.3.0
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 3.5.1
+
+
+ true
+
+
+
+ mojo-descriptor
+ prepare-package
+
+ descriptor
+
+
+
+ help-goal
+ prepare-package
+
+ helpmojo
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/preproc-maven-plugin/src/main/java/com/github/terefang/preproc_maven_plugin/PreProcessorMojo.java b/preproc-maven-plugin/src/main/java/com/github/terefang/preproc_maven_plugin/PreProcessorMojo.java
new file mode 100644
index 0000000..c2828dd
--- /dev/null
+++ b/preproc-maven-plugin/src/main/java/com/github/terefang/preproc_maven_plugin/PreProcessorMojo.java
@@ -0,0 +1,198 @@
+package com.github.terefang.preproc_maven_plugin;
+
+import lombok.Data;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.*;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+
+@Mojo(name = "pre-processor", defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
+@Data
+public class PreProcessorMojo extends AbstractMojo
+{
+ @Parameter(defaultValue = "${project.build.scriptSourceDirectory}")
+ protected File resourcesDirectory;
+
+ @Parameter(defaultValue = "${project.build.directory}/generated-resources")
+ protected File resourcesOutput;
+
+ @Parameter(defaultValue = "false")
+ private boolean singleFileOutput;
+
+ @Parameter(defaultValue = "false")
+ private boolean flattenOutput;
+
+ @Parameter(defaultValue = ".txt")
+ private String destinationExtension;
+
+ @Parameter(defaultValue = "false")
+ private boolean processSingleLineMarker;
+
+ @Parameter(defaultValue = "false")
+ private boolean processIncludes;
+
+ @Parameter(defaultValue = "MARK")
+ private String marker;
+
+ @Parameter
+ private String includes;
+
+ @Parameter
+ private String excludes;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ DirectoryScanner scanner = new DirectoryScanner();
+
+ if( resourcesDirectory.isDirectory())
+ {
+ scanner.setBasedir(resourcesDirectory);
+ if (StringUtils.isNotEmpty(includes)) {
+ scanner.setIncludes(StringUtils.split(includes));
+ } else {
+ scanner.setIncludes(new String[]{"**/*"});
+ }
+
+ if (StringUtils.isNotEmpty(excludes)) {
+ scanner.setExcludes(StringUtils.split(excludes));
+ }
+
+ scanner.addDefaultExcludes();
+ scanner.scan();
+
+ process(scanner.getIncludedFiles());
+ }
+ else
+ if( resourcesDirectory.isFile())
+ {
+ process(new String[]{ resourcesDirectory.getPath() });
+ }
+ }
+
+ public void process(String[] includedFiles)
+ {
+ includedFiles = Arrays.stream(includedFiles)
+ .sorted((x,y) -> { return x.compareToIgnoreCase(y); })
+ .toArray((x) -> { return new String[x]; });
+ File file = null;
+ PrintWriter out = null;
+ String _current = null;
+ try
+ {
+ if(singleFileOutput)
+ {
+ file = resourcesOutput;
+ file.getParentFile().mkdirs();
+ out = new PrintWriter(file);
+ }
+
+ for (String key : includedFiles)
+ {
+ this.getLog().info("processing: "+key);
+ _current = key;
+ String keybase = key.substring(0, key.lastIndexOf("."));
+ if(!singleFileOutput)
+ {
+ file = new File(resourcesOutput, keybase.concat(destinationExtension));
+ if(flattenOutput)
+ {
+ file = new File(resourcesOutput, file.getName());
+ }
+ file.getParentFile().mkdirs();
+ out = new PrintWriter(file);
+ }
+
+ File localFile = new File(resourcesDirectory, key);
+
+ resolveAndWrite(localFile.getParentFile(), localFile, out);
+
+ if(!singleFileOutput)
+ {
+ out.close();
+ }
+ }
+
+ if(singleFileOutput)
+ {
+ out.close();
+ }
+ }
+ catch (Exception _xe)
+ {
+ this.getLog().error((_current!=null ? _current+": " : "")+_xe.getMessage(), _xe);
+ }
+ }
+
+ public void resolveAndWrite(File _parent, File _file, PrintWriter _out) throws IOException
+ {
+ ArrayDeque _queue = new ArrayDeque<>();
+ _queue.add(new BufferedReader(new FileReader(_file)));
+ ArrayDeque _dirs = new ArrayDeque<>();
+ _dirs.add(_parent);
+
+ while(_queue.size()>0)
+ {
+ BufferedReader _lr = _queue.poll();
+ File _bd = _dirs.poll();
+
+ String _line = "";
+ boolean _in=false;
+ while((_line = _lr.readLine()) != null)
+ {
+ if(_line.startsWith("%!end "))
+ {
+ if(this.marker.equalsIgnoreCase(_line.substring(6).trim()))
+ {
+ _in=false;
+ }
+ }
+ else
+ if(_in)
+ {
+ _out.println(_line);
+ }
+ else
+ if(_line.startsWith("%!begin "))
+ {
+ if(this.marker.equalsIgnoreCase(_line.substring(8).trim()))
+ {
+ _in=true;
+ }
+ }
+ else
+ if(_line.startsWith("%!include ") && processIncludes)
+ {
+ _queue.push(_lr);
+ _dirs.push(_bd);
+ File _next = new File(_bd, _line.substring(10).trim());
+ this.getLog().info("including: "+_next.getName());
+ _bd = _next.getParentFile();
+ _lr = new BufferedReader(new FileReader(_next));
+ }
+ else
+ if(_line.startsWith("%% ") && processSingleLineMarker)
+ {
+ _out.println(_line.substring(3));
+ }
+ else
+ if(_line.equalsIgnoreCase("%%") && processSingleLineMarker)
+ {
+ _out.println();
+ }
+
+ }
+ _out.flush();
+ IOUtil.close(_lr);
+ }
+ }
+}
diff --git a/template-cli/pom.xml b/template-cli/pom.xml
index 39f175f..fea6c2e 100644
--- a/template-cli/pom.xml
+++ b/template-cli/pom.xml
@@ -5,7 +5,7 @@
template
com.github.terefang.template
- 2022.8.377
+ 2023.11.378
4.0.0
diff --git a/template-maven-plugin/pom.xml b/template-maven-plugin/pom.xml
index fc15794..ba860ca 100644
--- a/template-maven-plugin/pom.xml
+++ b/template-maven-plugin/pom.xml
@@ -5,7 +5,7 @@
template
com.github.terefang.template
- 2022.8.377
+ 2023.11.378
4.0.0