Sun, 10 Sep 2023 12:59:04 +0200
add simple SLF4J provider - fixes #292
package de.unixwork.uwproj; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import org.slf4j.LoggerFactory; import java.io.*; public class Main { static Project loadProjectFile(String fileName) { try { return new Project(new File(fileName)); } catch (Exception e) { throw new RuntimeException(e); } } static void writeConfigureScript(Writer out, String tplFileName, Project project) { var context = new VelocityContext(); context.put("targets", project.getTargets()); context.put("namedDependencies", project.getNamedDependencies()); context.put("dependencies", project.getDependencies()); context.put("options", project.getOptions()); context.put("features", project.getFeatures()); context.put("project", project); context.put("vars", project.getVars()); new VelocityEngine().getTemplate(tplFileName).merge(context, out); } public static void main(String[] args) { final var inFileName = "make/project.xml"; final var tplFileName = "make/configure.vm"; final var outFileName = "configure"; try (var out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFileName)))) { writeConfigureScript(out, tplFileName, loadProjectFile(inFileName)); } catch (Exception ex) { LoggerFactory.getLogger(Main.class).error( "Uncaught Exception", ex ); } System.out.println("Out: " + outFileName); } }