001: package org.eclipse.pde.build.tests;
002:
003: import java.io.*;
004: import java.net.URL;
005: import java.util.Enumeration;
006: import java.util.Properties;
007:
008: import org.eclipse.core.resources.IFolder;
009: import org.eclipse.core.runtime.*;
010:
011: public class BuildConfiguration {
012: public static final String TRUE = "true";
013: public static final String FALSE = "false";
014:
015: private static Properties defaultBuildConfig = new Properties();
016: private static Properties defaultScriptConfig = new Properties();
017: static {
018: // use the template build.properties from pde.build
019: URL resource = FileLocator.find(Platform
020: .getBundle("org.eclipse.pde.build"), new Path(
021: "/templates/headless-build/build.properties"), null);
022: try {
023: String buildPropertiesPath = FileLocator
024: .toFileURL(resource).getPath();
025: defaultBuildConfig.load(new BufferedInputStream(
026: new FileInputStream(buildPropertiesPath)));
027: } catch (IOException e) {
028: }
029:
030: // just a few changes from the template
031: defaultBuildConfig.put("archiveNamePrefix", "eclipse");
032: String baseLocation = Platform.getInstallLocation().getURL()
033: .getPath();
034: defaultBuildConfig.put("base", new File(baseLocation)
035: .getParent());
036: defaultBuildConfig.put("baseLocation", baseLocation);
037: defaultBuildConfig.put("baseos", Platform.getOS());
038: defaultBuildConfig.put("basews", Platform.getWS());
039: defaultBuildConfig.put("basearch", Platform.getOSArch());
040:
041: defaultScriptConfig = (Properties) defaultBuildConfig.clone();
042: if (!defaultBuildConfig.containsKey("configs"))
043: defaultScriptConfig.put("configs", "*,*,*");
044: if (!defaultBuildConfig.containsKey("buildingOSGi"))
045: defaultScriptConfig.put("buildingOSGi", TRUE);
046: if (!defaultBuildConfig.containsKey("signJars"))
047: defaultScriptConfig.put("signJars", FALSE);
048: if (!defaultBuildConfig
049: .containsKey("generateFeatureVersionSuffix"))
050: defaultScriptConfig.put("generateFeatureVersionSuffix",
051: FALSE);
052: if (!defaultBuildConfig.containsKey("generateVersionsLists"))
053: defaultScriptConfig.put("generateVersionsLists", TRUE);
054: if (!defaultBuildConfig.containsKey("groupConfigurations"))
055: defaultScriptConfig.put("groupConfigurations", FALSE);
056: if (!defaultBuildConfig.containsKey("pluginPath"))
057: defaultScriptConfig.put("pluginPath", "");
058: if (!defaultBuildConfig.containsKey("filteredDependencyCheck"))
059: defaultScriptConfig.put("filteredDependencyCheck", FALSE);
060: }
061:
062: private static Properties getBuildConfig() {
063: Properties properties = new Properties();
064: Enumeration e = defaultBuildConfig.keys();
065: while (e.hasMoreElements()) {
066: String key = (String) e.nextElement();
067: properties.put(key, defaultBuildConfig.get(key));
068: }
069:
070: return properties;
071: }
072:
073: /**
074: * Get a default build configuration build.properties based on the template from pde.build
075: * @param buildFolder
076: * @return
077: */
078: public static Properties getBuilderProperties(IFolder buildFolder) {
079: String builder = buildFolder.getLocation().toOSString();
080: Properties builderProperties = getBuildConfig();
081: builderProperties.put("buildDirectory", builder);
082: builderProperties.put("builder", builder);
083: return builderProperties;
084: }
085:
086: /**
087: * Get a default set of properties used for invoking the genericTargets/generateScript task
088: * (which invokes the eclipse.buildScript target)
089: * @param buildFolder
090: * @param type
091: * @param id
092: * @return
093: */
094: public static Properties getScriptGenerationProperties(
095: IFolder buildFolder, String type, String id) {
096: Properties properties = (Properties) defaultScriptConfig
097: .clone();
098: properties.put("type", type);
099: properties.put("id", id);
100: properties.put("buildDirectory", buildFolder.getLocation()
101: .toOSString());
102: return properties;
103: }
104: }
|