String installDesc = null;
String pearFile = null;
try {
// create command line parser
CommandLineParser clp = createCmdLineParser();
// parse command line parameters and check syntax
clp.parseCmdLine(args);
if (!checkCmdLineSyntax(clp)) {
printUsage();
System.exit(2);
}
// check what we have to do
boolean doInstallAction = false;
boolean doPackageAction = false;
// if install action is set, we have to create the installation descriptor
if (clp.isInArgsList(INSTALL_ACTION_PARAM)) {
doInstallAction = true;
}
// if package action is set, we have to create the pear package
if (clp.isInArgsList(PACKAGE_ACTION_PARAM)) {
doPackageAction = true;
}
// if both actions are not set, we have to create the installation descriptor and the pear
// package
if ((!clp.isInArgsList(INSTALL_ACTION_PARAM)) && (!clp.isInArgsList(PACKAGE_ACTION_PARAM))) {
doInstallAction = true;
doPackageAction = true;
}
// do install action
if (doInstallAction) {
// check envVars properties file
String filename = null;
Properties properties = null;
if ((filename = clp.getParamArgument(ENV_VAR_PARAM)) != null) {
properties = new Properties();
properties.load(new FileInputStream(filename));
}
// create installation descriptor
installDesc = PackageCreator.createInstallDescriptor(clp
.getParamArgument(COMPONENT_ID_PARAM), clp
.getParamArgument(MAIN_COMPONENT_DESC_PARAM),
clp.getParamArgument(CLASSPATH_PARAM), clp.getParamArgument(DATAPATH_PARAM), clp
.getParamArgument(MAIN_COMPONENT_DIR_PARAM), properties);
}
// do package action
if (doPackageAction) {
pearFile = PackageCreator
.createPearPackage(clp.getParamArgument(COMPONENT_ID_PARAM), clp
.getParamArgument(MAIN_COMPONENT_DIR_PARAM), clp
.getParamArgument(TARGET_DIR_PARAM));
}
} catch (Exception ex) {
ex.printStackTrace();