// nothing to package
System.exit(NO_ERROR_RETURN_CODE);
}
// create SessionManager
SessionManager sessionManager = cmd.createSession();
// create bbwp.properties
Logger.logMessage(LogType.INFO, "PROGRESS_SESSION_BBWP_PROPERTIES");
String propertiesFile = sessionManager.getBBWPJarFolder() + WidgetPackager.PROPERTIES_FILE;
BBWPProperties bbwpProperties = new BBWPProperties(propertiesFile, sessionManager.getSessionHome());
// validate widget archive
Logger.logMessage(LogType.INFO, "PROGRESS_VALIDATING_WIDGET_ARCHIVE");
WidgetArchive wa = new WidgetArchive(sessionManager.getWidgetArchive());
wa.validate();
// parse/validate config.xml
Logger.logMessage(LogType.INFO, "PROGRESS_SESSION_CONFIGXML");
XMLParser xmlparser = new ConfigXMLParser();
WidgetConfig config = xmlparser.parseXML(wa); // raw data, without \
// create/clean outputs/source
// Logger.printInfoMessage("Widget packaging starts...");
FileManager fileManager = new FileManager(bbwpProperties);
Logger.logMessage(LogType.INFO, "PROGRESS_FILE_POPULATING_SOURCE");
fileManager.prepare();
//
// Copy the JS extensions.
//
Map<String, Vector<String>> entryClassTable = null;
if (SessionManager.getInstance().isPlayBook()) {
entryClassTable = copyExtensions(bbwpProperties, config);
}
// Set 3rd party extension classes
if (!SessionManager.getInstance().isPlayBook()) {
config.setExtensionClasses(fileManager.getExtensionClasses());
}
// create autogen file
WidgetConfigSerializer wcs = new WidgetConfig_v1Serializer(config, entryClassTable);
byte[] autogenFile = wcs.serialize();
fileManager.writeToSource(autogenFile, AUTOGEN_FILE);
// create jdw/jdp files
if (!SessionManager.getInstance().isPlayBook()) {
fileManager.generateProjectFiles(sessionManager.getSourceFolder(),
sessionManager.getArchiveName(), config.getName(), config
.getVersion(), config.getAuthor(),config.getContent(),config.getBackgroundSource(),config.isStartupEnabled(), config
.getIconSrc(), config.getHoverIconSrc(),
fileManager.getFiles(), bbwpProperties.getImports());
}
// run mxmlc to compile ActionScript into SWF
Logger.logMessage(LogType.INFO, "PROGRESS_COMPILING");
if (SessionManager.getInstance().isPlayBook()) {
Mxmlc mxmlc = new Mxmlc(bbwpProperties, config);
// just for demo purposes, we hard code the source file path
mxmlc.run();
// *** just for demo purposes, we HARD CODE THE SOURCE PATH ***
Logger.logMessage(LogType.INFO, "PROGRESS_PACKAGING");
AirPackager packager = new AirPackager(bbwpProperties, config);
int ret = packager.run();
if (ret==0)
{
Logger.logMessage(LogType.INFO, "PACKAGING_COMPLETE");
}
else
{
System.exit(ret);
}
}
// generate ALX
if (!SessionManager.getInstance().isPlayBook()) {
generateAlxFile(config);
}
// Sign the cod if required
if (ENABLE_SIGNING && sessionManager.requireSigning()) {
Logger.logMessage(LogType.INFO, "PROGRESS_SIGNING");
if (SessionManager.getInstance().isPlayBook()) {
try {
SigningSupport.signBar(bbwpProperties);
} catch (Exception e) {
File barFile = new File(sessionManager.getOutputFilepath());
if (barFile.isFile()) {
barFile.delete();
}
throw e;
}
} else {
signCod(sessionManager);
}
Logger.logMessage(LogType.INFO, "PROGRESS_SIGNING_COMPLETE");
}
// clean/prep output folders
fileManager.cleanOutput();
// copy output files
if (!SessionManager.getInstance().isPlayBook()) {
Logger.logMessage(LogType.INFO, "PROGRESS_GEN_OUTPUT");
fileManager.copyOutputsFromSource(STANDARD_OUTPUTS, OTA_OUTPUTS);
}
// clean source (if necessary)
if (!sessionManager.requireSource()) {
fileManager.cleanSource();
}
Logger.logMessage(LogType.INFO, "PROGRESS_COMPLETE");
} catch (CommandLineException cle) {