| 6914 |
dpurdie |
1 |
package com.erggroup.buildtool.ripple;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
|
|
|
5 |
import org.apache.log4j.Logger;
|
|
|
6 |
|
|
|
7 |
import com.erggroup.buildtool.utilities.XmlBuilder;
|
|
|
8 |
|
|
|
9 |
/**
|
|
|
10 |
* entity class representing how derived files are produced on a platform
|
|
|
11 |
* Recognizes that a package may have different build standards on different platforms
|
|
|
12 |
* for example, Jats may be used to build production code on a win32 build machine and debug code on a solaris build
|
|
|
13 |
* machine
|
|
|
14 |
* potentially supports mixing build standards
|
|
|
15 |
* for example, Jats may be used to build code on one build machine, and ERG ant on another
|
|
|
16 |
* this is not supported in the release manager
|
|
|
17 |
*
|
|
|
18 |
* This package maps the BuildStandard Family (Windows,Linux,Solaris) to the underlying
|
|
|
19 |
* Machine Types based on information provided by the Release Manager Database
|
|
|
20 |
*
|
|
|
21 |
*/
|
|
|
22 |
public class BuildStandard
|
|
|
23 |
{
|
|
|
24 |
/**
|
|
|
25 |
* Logger
|
|
|
26 |
*
|
|
|
27 |
* @attribute
|
|
|
28 |
*/
|
|
|
29 |
private static final Logger mLogger = Logger.getLogger(BuildStandard.class);
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* engine associated with the baseline in which this packages build standard is owned
|
|
|
33 |
*
|
|
|
34 |
* @aggregation composite
|
|
|
35 |
*/
|
|
|
36 |
private RippleEngine mRippleEngine;
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
*
|
|
|
40 |
* @attribute
|
|
|
41 |
*/
|
|
|
42 |
private boolean mGeneric = false;
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* When true the package can be built using one of the known standards
|
|
|
46 |
*
|
|
|
47 |
*/
|
|
|
48 |
private boolean mSupported = true;
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* build Family: Linux, Win32, Solaris, ...
|
|
|
52 |
*/
|
|
|
53 |
public String mMachClass = null;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Array of build machine types: win32, solaris, solaris10_x86 ....
|
|
|
57 |
*/
|
|
|
58 |
public ArrayList<String> mMachTypes = null;
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Items to assist in creating platform and standard descriptions
|
|
|
62 |
*/
|
|
|
63 |
String mType = null;
|
|
|
64 |
String mData = null;
|
|
|
65 |
String mFriendly = null;
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Constructor
|
|
|
70 |
* The only method to create and modify the Build Standard Information
|
|
|
71 |
* Once set it cannot be modified - this greatly simplifies its implementation
|
|
|
72 |
*
|
|
|
73 |
* Since the class captures data from the Ripple Engine the data is only valid for the duration of a
|
|
|
74 |
* build cycle. When the machine information is refreshed from database the data in this class
|
|
|
75 |
* will be stale. This is not an issue as the package data is discarded on every planning cycle.
|
|
|
76 |
*/
|
|
|
77 |
public BuildStandard(RippleEngine rippleEngine, String buildMachineFamily, String buildStandardAddendum)
|
|
|
78 |
{
|
|
|
79 |
mLogger.debug("BuildStandard");
|
|
|
80 |
mRippleEngine = rippleEngine;
|
|
|
81 |
mMachClass = buildMachineFamily;
|
|
|
82 |
|
|
|
83 |
//
|
|
|
84 |
// Convert the provided Machine Class into an array of Machine Types
|
|
|
85 |
// Generic is special
|
|
|
86 |
// EscrowMode: Generic is treated as all known (in the buildset) platforms
|
|
|
87 |
// DeaemonMode: Generic is treated as the master machine type
|
|
|
88 |
//
|
|
|
89 |
if (buildMachineFamily.compareTo("Generic") == 0)
|
|
|
90 |
{
|
|
|
91 |
mGeneric = true;
|
|
|
92 |
|
|
|
93 |
if(mRippleEngine.mDaemon)
|
|
|
94 |
{
|
|
|
95 |
mMachTypes = new ArrayList<String>();
|
|
|
96 |
mMachTypes.add(Package.mGenericMachtype);
|
|
|
97 |
}
|
|
|
98 |
else
|
|
|
99 |
{
|
|
|
100 |
mMachTypes = mRippleEngine.mReleaseManager.mReleaseConfigCollection.mMachineTypes;
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
else
|
|
|
104 |
{
|
|
|
105 |
// Not Generic
|
|
|
106 |
// Create a list of machine types based on the conversion from machClass to the machTypes in
|
|
|
107 |
// the current build set
|
|
|
108 |
//
|
|
|
109 |
mMachTypes = mRippleEngine.mReleaseManager.mReleaseConfigCollection.mMachineHash.get(mMachClass);
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
if (mMachTypes == null || mMachTypes.size() == 0)
|
|
|
113 |
{
|
|
|
114 |
mSupported = false;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
if (buildStandardAddendum.compareTo("Production") == 0)
|
|
|
118 |
{
|
|
|
119 |
mType = "jats";
|
|
|
120 |
mData = "production";
|
|
|
121 |
mFriendly = "Jats Production";
|
|
|
122 |
}
|
|
|
123 |
else if (buildStandardAddendum.compareTo("Debug") == 0)
|
|
|
124 |
{
|
|
|
125 |
mType = "jats";
|
|
|
126 |
mData = "debug";
|
|
|
127 |
mFriendly = "Jats Debug";
|
|
|
128 |
}
|
|
|
129 |
else if (buildStandardAddendum.compareTo("Production and Debug") == 0)
|
|
|
130 |
{
|
|
|
131 |
mType = "jats";
|
|
|
132 |
mData = "all";
|
|
|
133 |
mFriendly = "Jats All";
|
|
|
134 |
}
|
|
|
135 |
else if (buildStandardAddendum.startsWith("Java "))
|
|
|
136 |
{
|
|
|
137 |
mType = "ant";
|
|
|
138 |
mData = buildStandardAddendum.substring(5);
|
|
|
139 |
mFriendly = "Ant Java " + mData;
|
|
|
140 |
}
|
|
|
141 |
else
|
|
|
142 |
{
|
|
|
143 |
mSupported = false;
|
|
|
144 |
mType = "jats";
|
|
|
145 |
mData = "unknown";
|
|
|
146 |
mFriendly = "Jats Unknown";
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
/**
|
|
|
152 |
* returns for xml purposes
|
|
|
153 |
* "<platform machtype="win32" method="jats" arg="all"/>",
|
|
|
154 |
* "<platform machtype="solaris10_sparc32" method="ant" arg="java 1.6"/>"
|
|
|
155 |
* "<platform machtype="solaris10_x86" method="ant" arg="java 1.6"/>"
|
|
|
156 |
* "<platform machtype="sparc" method="ant" arg="java 1.6"/>"
|
|
|
157 |
* "<platform machtype="linux_i386" method="jats" arg="prod"/>"
|
|
|
158 |
*
|
|
|
159 |
* May return multiple lines
|
|
|
160 |
*/
|
|
|
161 |
|
|
|
162 |
public void getBuildStandardXml(XmlBuilder xml)
|
|
|
163 |
{
|
|
|
164 |
mLogger.debug("getBuildStandardXml");
|
|
|
165 |
if (mMachTypes != null && mSupported)
|
|
|
166 |
{
|
|
|
167 |
for (String item : mMachTypes)
|
|
|
168 |
{
|
|
|
169 |
XmlBuilder entry = xml.addNewElement("buildinfo");
|
|
|
170 |
entry.addAttribute("machtype", item);
|
|
|
171 |
entry.addAttribute("method", mType);
|
|
|
172 |
if (mData != null)
|
|
|
173 |
{
|
|
|
174 |
entry.addAttribute("arg", mData);
|
|
|
175 |
}
|
|
|
176 |
}
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
mLogger.info("getBuildStandardXml returned " + xml.toString());
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
/**
|
|
|
183 |
* returns for text (email) purposes
|
|
|
184 |
* win32: jats all
|
|
|
185 |
* solaris10_sparc32: ant java 1.6
|
|
|
186 |
* solaris10_x86: ant java 1.6
|
|
|
187 |
* sparc: ant java 1.6
|
|
|
188 |
* linux_i386: jats prod
|
|
|
189 |
*
|
|
|
190 |
* May return multiple lines, separated by <br> as the string is intended for use in email
|
|
|
191 |
*/
|
|
|
192 |
|
|
|
193 |
public String getBuildStandard()
|
|
|
194 |
{
|
|
|
195 |
mLogger.debug("getBuildStandard");
|
|
|
196 |
String retVal = new String();
|
|
|
197 |
if (mMachTypes != null && mSupported)
|
|
|
198 |
{
|
|
|
199 |
String joiner1 = "";
|
|
|
200 |
for (String item : mMachTypes)
|
|
|
201 |
{
|
|
|
202 |
retVal += joiner1 + item + ":" + mFriendly;
|
|
|
203 |
joiner1 = "<br>";
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
mLogger.info("getBuildStandard returned " + retVal);
|
|
|
208 |
return retVal;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
* Get a string that describes the Build Standard
|
|
|
213 |
* It will be used within emails and info within XML files.
|
|
|
214 |
*
|
|
|
215 |
* Expected format:
|
|
|
216 |
* machineClass:standard
|
|
|
217 |
*
|
|
|
218 |
* May be an empty string - if there is no build standard.
|
|
|
219 |
*/
|
|
|
220 |
public String getBuildStandardText()
|
|
|
221 |
{
|
|
|
222 |
String rv = "";
|
|
|
223 |
|
|
|
224 |
// No build standard
|
|
|
225 |
if (!mSupported)
|
|
|
226 |
{
|
|
|
227 |
return rv;
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
rv += mMachClass + ":" + mFriendly;
|
|
|
231 |
return rv;
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
/**
|
|
|
235 |
* accessor method
|
|
|
236 |
*/
|
|
|
237 |
public boolean isGeneric()
|
|
|
238 |
{
|
|
|
239 |
mLogger.info("getGeneric returned " + mGeneric);
|
|
|
240 |
return mGeneric;
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
/**
|
|
|
244 |
* accessor method
|
|
|
245 |
*/
|
|
|
246 |
public boolean supportedBuildStandard()
|
|
|
247 |
{
|
|
|
248 |
mLogger.info("supportedBuildStandard returned " + mSupported);
|
|
|
249 |
return mSupported;
|
|
|
250 |
}
|
|
|
251 |
/**
|
|
|
252 |
*
|
|
|
253 |
* @return true if the Build Standard is active
|
|
|
254 |
* ie: This build standard will participate in the building of the package
|
|
|
255 |
*
|
|
|
256 |
*/
|
|
|
257 |
public boolean isActive()
|
|
|
258 |
{
|
|
|
259 |
return (mSupported);
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
}
|