diff -r 000000000000 -r 38775db5fdf5 src/main/java/de/unixwork/uwproj/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/unixwork/uwproj/Main.java Mon Feb 04 15:09:39 2019 +0100 @@ -0,0 +1,67 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.unixwork.uwproj; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.xml.sax.SAXException; + +/** + * + * @author olaf + */ +public class Main { + public static void main(String[] args){ + File f = new File("make/project.xml"); + Project p = null; + try { + p = new Project(f); + } catch (SAXException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } catch (IOException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } catch (Exception ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + if(p == null) { + System.exit(1); + } + + VelocityEngine ve = new VelocityEngine(); + Template t = ve.getTemplate("make/configure.vm"); + VelocityContext context = new VelocityContext(); + context.put("targets", p.getTargets()); + context.put("namedDependencies", p.getNamedDependencies()); + context.put("dependencies", p.getDependencies()); + context.put("options", p.getOptions()); + context.put("features", p.getFeatures()); + + int ret = 1; + try { + FileOutputStream fout = new FileOutputStream(new File("configure")); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fout)); + t.merge(context, out); + out.close(); + ret = 0; + System.out.println("Out: configure"); + } catch (FileNotFoundException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } catch (IOException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + System.exit(ret); + } +}