Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.escrow;
2
 
3
import com.erggroup.buildtool.ripple.MutableString;
4
import com.erggroup.buildtool.ripple.ReleaseManager;
5
import com.erggroup.buildtool.ripple.RippleEngine;
6
 
7
import java.io.File;
8
import java.io.FileWriter;
9
import java.io.IOException;
10
 
11
import org.apache.log4j.xml.DOMConfigurator;
12
 
13
public class ESCROWBuild
14
{
15
  /**
16
   * @aggregation shared
17
   */
18
  protected ReleaseManager mReleaseManager;
19
 
20
  /**
21
   * @aggregation shared
22
   */
23
  protected RippleEngine mRippleEngine;
24
 
25
  public static void main(String[] args)
26
  {
27
    String usage = 
28
      new String("Usage: java -jar escrowD.jar -c connectionString -u username -p password -b BOM id");
29
    String connectionString = new String();
30
    String username = new String();
31
    String password = new String();
32
    String bomID = new String();
33
 
34
    for (int optind = 0; optind < args.length; optind++)
35
    {
36
      if (args[optind].equals("-c") && optind < (args.length - 1))
37
      {
38
        connectionString = args[++optind];
39
      }
40
      else if (args[optind].equals("-u") && optind < (args.length - 1))
41
      {
42
        username = args[++optind];
43
      }
44
      else if (args[optind].equals("-p") && optind < (args.length - 1))
45
      {
46
        password = args[++optind];
47
      }
48
      else if (args[optind].equals("-b") && optind < (args.length - 1))
49
      {
50
        bomID = args[++optind];
51
      }
52
    }
53
 
54
    if (connectionString.compareTo("") == 0 || 
55
        username.compareTo("") == 0 || password.compareTo("") == 0 || 
56
        bomID.compareTo("") == 0)
57
    {
58
      System.out.println(usage);
59
      System.exit(1);
60
    }
61
 
62
    DOMConfigurator.configure("abtd.xml");
63
 
64
    ReleaseManager releaseManager = 
65
      new ReleaseManager(connectionString, username, password);
66
 
67
    RippleEngine rippleEngine = new RippleEngine(releaseManager, Integer.parseInt(bomID), false);
68
    try
69
    {
868 mhunt 70
      rippleEngine.collectMetaData();
814 mhunt 71
      rippleEngine.planRelease();
72
    }
73
    catch( Exception e )
74
    {
906 mhunt 75
      System.out.println("ESCROWBuild::main caught Exception " + e.getMessage());
814 mhunt 76
    }
77
 
78
    File cwd = new File( "." );
79
    String buildFileName = new String();
80
    int buildFileNumber = 1;
81
    MutableString buildFileContent = new MutableString();
82
    try
83
    {
84
      boolean moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
85
 
86
      do
87
      {
88
        if (moreBuildFiles)
89
        {
90
            buildFileName = "build";
91
            buildFileName += buildFileNumber;
92
            buildFileName += ".xml";
93
            File buildFile = new File(cwd, buildFileName);
94
            FileWriter buildFileWriter = new FileWriter(buildFile);
95
            buildFileWriter.write(buildFileContent.value);
96
            buildFileWriter.close();
97
            buildFileNumber++;
98
            moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
99
        }
100
      }
101
      while (moreBuildFiles);
102
 
103
      {
830 mhunt 104
        File f = new File(cwd, "escrow_set_up");
814 mhunt 105
        FileWriter fw = new FileWriter(f);
830 mhunt 106
        fw.write(rippleEngine.getESCROWSetUp());
814 mhunt 107
        fw.close();
108
      }
830 mhunt 109
 
814 mhunt 110
      {
830 mhunt 111
        File f = new File(cwd, "raw_data.csv");
814 mhunt 112
        FileWriter fw = new FileWriter(f);
830 mhunt 113
        fw.write(rippleEngine.getRawData());
814 mhunt 114
        fw.close();
115
      }
116
    }
117
    catch( IOException e )
118
    {
119
      System.out.println("ESCROWBuild::main caught IOException");
120
    }
121
 
122
  }
123
}