| 7333 |
dpurdie |
1 |
package com.erggroup.buildtool.daemon;
|
|
|
2 |
|
|
|
3 |
import java.io.File;
|
|
|
4 |
import java.io.FileInputStream;
|
|
|
5 |
import java.io.IOException;
|
|
|
6 |
import java.util.ArrayList;
|
|
|
7 |
import java.util.Arrays;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
import java.util.Properties;
|
|
|
10 |
import com.erggroup.buildtool.ripple.ReportingData;
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* This class is populated from data provided by JATS and ANT about the build that is to be performed
|
|
|
14 |
* It will contain information about the platforms that the package is to be built for
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
public class BuildInfo {
|
|
|
18 |
|
|
|
19 |
public String mStyle = null; // ANT or JATS
|
|
|
20 |
public boolean mGeneric = false; // Package is GENERIC
|
|
|
21 |
public String mJavaVersion = null; // Optional java version to be used
|
|
|
22 |
public List<String> mPlatforms; // Platforms the package can be built for
|
|
|
23 |
public List<String> mBuildPlatforms; // Platforms the package will be built for
|
|
|
24 |
public List<String> mToolsetPlatforms; // Platforms for which tools will be built
|
|
|
25 |
public List<String> mProdPlatforms; // Platforms that only build for production
|
|
|
26 |
public List<String> mDebugPlatforms; // Platforms that only build for debug
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Read properties from a file
|
|
|
30 |
* @param srcFile
|
|
|
31 |
* @throws IOException
|
|
|
32 |
*/
|
|
|
33 |
public BuildInfo (File srcFile) throws IOException
|
|
|
34 |
{
|
|
|
35 |
Properties prop = new Properties();
|
|
|
36 |
FileInputStream input = new FileInputStream(srcFile);
|
|
|
37 |
|
|
|
38 |
// load the file as a properties file
|
|
|
39 |
prop.load(input);
|
|
|
40 |
|
|
|
41 |
// Display the properties read
|
|
|
42 |
// Set<String> keys = prop.stringPropertyNames();
|
|
|
43 |
// for (String key : keys) {
|
|
|
44 |
// System.out.println(key + " : " + prop.getProperty(key));
|
|
|
45 |
// }
|
|
|
46 |
|
|
|
47 |
// Extract required properties into the class
|
|
|
48 |
mStyle = prop.getProperty("buildstyle", "JATS");
|
|
|
49 |
mGeneric = ReportingData.toBool(prop.getProperty("generic.build", "0"));
|
|
|
50 |
mJavaVersion = prop.getProperty("java.version", null);
|
|
|
51 |
mPlatforms = toList( prop.getProperty("platforms"));
|
|
|
52 |
mBuildPlatforms = toList( prop.getProperty("build.platforms"));
|
|
|
53 |
mToolsetPlatforms = toList( prop.getProperty("toolset.platforms"));
|
|
|
54 |
mProdPlatforms = toList( prop.getProperty("prod.platforms"));
|
|
|
55 |
mDebugPlatforms = toList( prop.getProperty("debug.platforms"));
|
|
|
56 |
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Convert a comma separated string into List<String>
|
|
|
61 |
* Special handling for null Strings
|
|
|
62 |
*
|
|
|
63 |
* @param string - A comma separated string. Can have spaces around the commas
|
|
|
64 |
* @return A List<String>
|
|
|
65 |
*
|
|
|
66 |
*/
|
|
|
67 |
private List<String> toList(String string)
|
|
|
68 |
{
|
|
|
69 |
if (string == null) {
|
|
|
70 |
return new ArrayList<String>();
|
|
|
71 |
}
|
|
|
72 |
return Arrays.asList( string.trim().split("\\s*,\\s*") );
|
|
|
73 |
}
|
|
|
74 |
}
|