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.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
    {
70
      rippleEngine.planRelease();
71
    }
72
    catch( Exception e )
73
    {
74
    }
75
 
76
    File cwd = new File( "." );
77
    String buildFileName = new String();
78
    int buildFileNumber = 1;
79
    MutableString buildFileContent = new MutableString();
80
    try
81
    {
82
      boolean moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
83
 
84
      do
85
      {
86
        if (moreBuildFiles)
87
        {
88
            buildFileName = "build";
89
            buildFileName += buildFileNumber;
90
            buildFileName += ".xml";
91
            File buildFile = new File(cwd, buildFileName);
92
            FileWriter buildFileWriter = new FileWriter(buildFile);
93
            buildFileWriter.write(buildFileContent.value);
94
            buildFileWriter.close();
95
            buildFileNumber++;
96
            moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
97
        }
98
      }
99
      while (moreBuildFiles);
100
 
101
      {
830 mhunt 102
        File f = new File(cwd, "escrow_set_up");
814 mhunt 103
        FileWriter fw = new FileWriter(f);
830 mhunt 104
        fw.write(rippleEngine.getESCROWSetUp());
814 mhunt 105
        fw.close();
106
      }
830 mhunt 107
 
814 mhunt 108
      {
830 mhunt 109
        File f = new File(cwd, "raw_data.csv");
814 mhunt 110
        FileWriter fw = new FileWriter(f);
830 mhunt 111
        fw.write(rippleEngine.getRawData());
814 mhunt 112
        fw.close();
113
      }
114
    }
115
    catch( IOException e )
116
    {
117
      System.out.println("ESCROWBuild::main caught IOException");
118
    }
119
 
120
  }
121
}