|
1 /* |
|
2 * To change this license header, choose License Headers in Project Properties. |
|
3 * To change this template file, choose Tools | Templates |
|
4 * and open the template in the editor. |
|
5 */ |
|
6 package de.unixwork.uwproj; |
|
7 |
|
8 import java.io.BufferedWriter; |
|
9 import java.io.File; |
|
10 import java.io.FileNotFoundException; |
|
11 import java.io.FileOutputStream; |
|
12 import java.io.IOException; |
|
13 import java.io.OutputStreamWriter; |
|
14 import java.io.StringWriter; |
|
15 import java.util.logging.Level; |
|
16 import java.util.logging.Logger; |
|
17 import org.apache.velocity.Template; |
|
18 import org.apache.velocity.VelocityContext; |
|
19 import org.apache.velocity.app.VelocityEngine; |
|
20 import org.xml.sax.SAXException; |
|
21 |
|
22 /** |
|
23 * |
|
24 * @author olaf |
|
25 */ |
|
26 public class Main { |
|
27 public static void main(String[] args){ |
|
28 File f = new File("make/project.xml"); |
|
29 Project p = null; |
|
30 try { |
|
31 p = new Project(f); |
|
32 } catch (SAXException ex) { |
|
33 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
|
34 } catch (IOException ex) { |
|
35 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
|
36 } catch (Exception ex) { |
|
37 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
|
38 } |
|
39 if(p == null) { |
|
40 System.exit(1); |
|
41 } |
|
42 |
|
43 VelocityEngine ve = new VelocityEngine(); |
|
44 Template t = ve.getTemplate("make/configure.vm"); |
|
45 VelocityContext context = new VelocityContext(); |
|
46 context.put("targets", p.getTargets()); |
|
47 context.put("namedDependencies", p.getNamedDependencies()); |
|
48 context.put("dependencies", p.getDependencies()); |
|
49 context.put("options", p.getOptions()); |
|
50 context.put("features", p.getFeatures()); |
|
51 |
|
52 int ret = 1; |
|
53 try { |
|
54 FileOutputStream fout = new FileOutputStream(new File("configure")); |
|
55 BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fout)); |
|
56 t.merge(context, out); |
|
57 out.close(); |
|
58 ret = 0; |
|
59 System.out.println("Out: configure"); |
|
60 } catch (FileNotFoundException ex) { |
|
61 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
|
62 } catch (IOException ex) { |
|
63 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
|
64 } |
|
65 System.exit(ret); |
|
66 } |
|
67 } |