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
    {
868 mhunt 70
      rippleEngine.collectMetaData();
814 mhunt 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
}