| 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 |
{
|
|
|
103 |
File f = new File(cwd, "win32_set_up.bat");
|
|
|
104 |
FileWriter fw = new FileWriter(f);
|
|
|
105 |
fw.write(rippleEngine.getWin32SetUp());
|
|
|
106 |
fw.close();
|
|
|
107 |
}
|
|
|
108 |
{
|
|
|
109 |
File f = new File(cwd, "win32_tear_down.bat");
|
|
|
110 |
FileWriter fw = new FileWriter(f);
|
|
|
111 |
fw.write(rippleEngine.getWin32TearDown());
|
|
|
112 |
fw.close();
|
|
|
113 |
}
|
|
|
114 |
{
|
|
|
115 |
File f = new File(cwd, "unix_set_up");
|
|
|
116 |
FileWriter fw = new FileWriter(f);
|
|
|
117 |
fw.write(rippleEngine.getUnixSetUp());
|
|
|
118 |
fw.close();
|
|
|
119 |
}
|
|
|
120 |
{
|
|
|
121 |
File f = new File(cwd, "unix_tear_down");
|
|
|
122 |
FileWriter fw = new FileWriter(f);
|
|
|
123 |
fw.write(rippleEngine.getUnixTearDown());
|
|
|
124 |
fw.close();
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
}
|
|
|
128 |
catch( IOException e )
|
|
|
129 |
{
|
|
|
130 |
System.out.println("ESCROWBuild::main caught IOException");
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
}
|
|
|
134 |
}
|