| 6914 |
dpurdie |
1 |
package com.erggroup.buildtool.escrow;
|
|
|
2 |
|
|
|
3 |
import com.erggroup.buildtool.ripple.BuildFile;
|
|
|
4 |
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
|
|
|
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 |
public class ESCROWBuild
|
|
|
13 |
{
|
|
|
14 |
/**
|
|
|
15 |
* @aggregation shared
|
|
|
16 |
*/
|
|
|
17 |
protected ReleaseManager mReleaseManager;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* @aggregation shared
|
|
|
21 |
*/
|
|
|
22 |
protected RippleEngine mRippleEngine;
|
|
|
23 |
|
|
|
24 |
public static void main(String[] args)
|
|
|
25 |
{
|
|
|
26 |
String usage =
|
|
|
27 |
new String("Usage: java -jar escrowD.jar -c connectionString -u username -p password -b BOM id");
|
|
|
28 |
String connectionString = new String();
|
|
|
29 |
String username = new String();
|
|
|
30 |
String password = new String();
|
|
|
31 |
String bomID = new String();
|
|
|
32 |
|
|
|
33 |
for (int optind = 0; optind < args.length; optind++)
|
|
|
34 |
{
|
|
|
35 |
if (args[optind].equals("-c") && optind < (args.length - 1))
|
|
|
36 |
{
|
|
|
37 |
connectionString = args[++optind];
|
|
|
38 |
}
|
|
|
39 |
else if (args[optind].equals("-u") && optind < (args.length - 1))
|
|
|
40 |
{
|
|
|
41 |
username = args[++optind];
|
|
|
42 |
}
|
|
|
43 |
else if (args[optind].equals("-p") && optind < (args.length - 1))
|
|
|
44 |
{
|
|
|
45 |
password = args[++optind];
|
|
|
46 |
}
|
|
|
47 |
else if (args[optind].equals("-b") && optind < (args.length - 1))
|
|
|
48 |
{
|
|
|
49 |
bomID = args[++optind];
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
if (connectionString.compareTo("") == 0 ||
|
|
|
54 |
username.compareTo("") == 0 || password.compareTo("") == 0 ||
|
|
|
55 |
bomID.compareTo("") == 0)
|
|
|
56 |
{
|
|
|
57 |
System.out.println(usage);
|
|
|
58 |
System.exit(1);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
ReleaseManager releaseManager = new ReleaseManager(connectionString, username, password);
|
|
|
62 |
RippleEngine rippleEngine = new RippleEngine(releaseManager, Integer.parseInt(bomID), false);
|
|
|
63 |
|
|
|
64 |
generateEscrowFiles(rippleEngine, ".");
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/** Generate the Escrow Files
|
|
|
68 |
* Factored out to improve testability
|
|
|
69 |
*/
|
|
|
70 |
public static void generateEscrowFiles(RippleEngine rippleEngine, String basePath)
|
|
|
71 |
{
|
|
|
72 |
try
|
|
|
73 |
{
|
|
|
74 |
rippleEngine.collectMetaData();
|
|
|
75 |
rippleEngine.planRelease(false);
|
|
|
76 |
}
|
|
|
77 |
catch( Exception e )
|
|
|
78 |
{
|
|
|
79 |
System.out.println("ESCROWBuild::main caught Exception " + e.getMessage());
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
File cwd = new File( basePath );
|
|
|
83 |
String buildFileName = new String();
|
|
|
84 |
int buildFileNumber = 1;
|
|
|
85 |
BuildFile buildFile;
|
|
|
86 |
|
|
|
87 |
try
|
|
|
88 |
{
|
|
|
89 |
// Write out all the Escrow build<n>.xml files
|
|
|
90 |
buildFile = rippleEngine.getFirstBuildFileContent();
|
|
|
91 |
while (buildFile.state != BuildFileState.Empty)
|
|
|
92 |
{
|
|
|
93 |
buildFileName = "build";
|
|
|
94 |
buildFileName += buildFileNumber;
|
|
|
95 |
buildFileName += ".xml";
|
|
|
96 |
FileWriter buildFileWriter = new FileWriter(new File(cwd, buildFileName));
|
|
|
97 |
buildFileWriter.write(buildFile.content);
|
|
|
98 |
buildFileWriter.close();
|
|
|
99 |
buildFileNumber++;
|
|
|
100 |
buildFile = rippleEngine.getNextBuildFileContent();
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
// Write out the Escrow Set Up file
|
|
|
104 |
{
|
|
|
105 |
File f = new File(cwd, "escrow_set_up");
|
|
|
106 |
FileWriter fw = new FileWriter(f);
|
|
|
107 |
fw.write(rippleEngine.getEscrowSetUp());
|
|
|
108 |
fw.close();
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
// Write out the Escrow Raw data as a CSV file
|
|
|
112 |
{
|
|
|
113 |
File f = new File(cwd, "raw_data.csv");
|
|
|
114 |
FileWriter fw = new FileWriter(f);
|
|
|
115 |
fw.write(rippleEngine.getRawData());
|
|
|
116 |
fw.close();
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
catch( IOException e )
|
|
|
120 |
{
|
|
|
121 |
System.out.println("ESCROWBuild::main caught IOException");
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
}
|
|
|
125 |
}
|