Subversion Repositories DevTools

Rev

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