< prev index next >

modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java

Print this page




 231             Log.info("Exception: "+ex);
 232             Log.debug(ex);
 233             return null;
 234         }
 235     }
 236 
 237     private void createLauncherForEntryPoint(Map<String, ? super Object> p, File rootDir) throws IOException {
 238         // Copy executable to Linux folder
 239         File executableFile = new File(rootDir, getLauncherName(p));
 240         IOUtils.copyFromURL(
 241                 RAW_EXECUTABLE_URL.fetchFrom(p),
 242                 executableFile);
 243 
 244         executableFile.setExecutable(true, false);
 245         executableFile.setWritable(true, true); //for str
 246 
 247         // Generate launcher .cfg file
 248         if (LAUNCHER_CFG_FORMAT.fetchFrom(p).equals(CFG_FORMAT_PROPERTIES)) {
 249             writeCfgFile(p, rootDir);
 250         } else {
 251             writeCfgFile(p, new File(rootDir, getLauncherCfgName(p)), "$APPDIR/runtime");
 252         }
 253     }
 254 
 255     private void copyApplication(Map<String, ? super Object> params, File appDirectory) throws IOException {
 256         List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
 257         if (appResourcesList == null) {
 258             throw new RuntimeException("Null app resources?");
 259         }
 260         for (RelativeFileSet appResources : appResourcesList) {
 261             if (appResources == null) {
 262                 throw new RuntimeException("Null app resources?");
 263             }
 264             File srcdir = appResources.getBaseDirectory();
 265             for (String fname : appResources.getIncludedFiles()) {
 266                 IOUtils.copyFile(
 267                         new File(srcdir, fname), new File(appDirectory, fname));
 268             }
 269         }
 270     }
 271 








 272     private void writeCfgFile(Map<String, ? super Object> params, File rootDir) throws FileNotFoundException {
 273         File cfgFile = new File(rootDir, getLauncherCfgName(params));
 274 
 275         cfgFile.delete();
 276         PrintStream out = new PrintStream(cfgFile);
 277         if (LINUX_RUNTIME.fetchFrom(params) == null) {
 278             out.println("app.runtime=");                    
 279         } else {
 280             out.println("app.runtime=$APPDIR/runtime");
 281         }
 282         out.println("app.mainjar=" + MAIN_JAR.fetchFrom(params).getIncludedFiles().iterator().next());
 283         out.println("app.version=" + VERSION.fetchFrom(params));
 284 
 285         //use '/' in the class name (instead of '.' to simplify native code
 286         out.println("app.mainclass=" +
 287                 MAIN_CLASS.fetchFrom(params).replaceAll("\\.", "/"));
 288 
 289         StringBuilder macroedPath = new StringBuilder();
 290         for (String s : CLASSPATH.fetchFrom(params).split("[ ;:]+")) {
 291             macroedPath.append(s);
 292             macroedPath.append(":");
 293         }
 294         macroedPath.deleteCharAt(macroedPath.length() - 1);
 295         out.println("app.classpath=" + macroedPath.toString());
 296 
 297         List<String> jvmargs = JVM_OPTIONS.fetchFrom(params);
 298         int idx = 1;
 299         for (String a : jvmargs) {
 300             out.println("jvmarg."+idx+"="+a);
 301             idx++;




 231             Log.info("Exception: "+ex);
 232             Log.debug(ex);
 233             return null;
 234         }
 235     }
 236 
 237     private void createLauncherForEntryPoint(Map<String, ? super Object> p, File rootDir) throws IOException {
 238         // Copy executable to Linux folder
 239         File executableFile = new File(rootDir, getLauncherName(p));
 240         IOUtils.copyFromURL(
 241                 RAW_EXECUTABLE_URL.fetchFrom(p),
 242                 executableFile);
 243 
 244         executableFile.setExecutable(true, false);
 245         executableFile.setWritable(true, true); //for str
 246 
 247         // Generate launcher .cfg file
 248         if (LAUNCHER_CFG_FORMAT.fetchFrom(p).equals(CFG_FORMAT_PROPERTIES)) {
 249             writeCfgFile(p, rootDir);
 250         } else {
 251             writeCfgFile(p, new File(rootDir, getLauncherCfgName(p)), getRuntimeLocation(p));
 252         }
 253     }
 254 
 255     private void copyApplication(Map<String, ? super Object> params, File appDirectory) throws IOException {
 256         List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
 257         if (appResourcesList == null) {
 258             throw new RuntimeException("Null app resources?");
 259         }
 260         for (RelativeFileSet appResources : appResourcesList) {
 261             if (appResources == null) {
 262                 throw new RuntimeException("Null app resources?");
 263             }
 264             File srcdir = appResources.getBaseDirectory();
 265             for (String fname : appResources.getIncludedFiles()) {
 266                 IOUtils.copyFile(
 267                         new File(srcdir, fname), new File(appDirectory, fname));
 268             }
 269         }
 270     }
 271 
 272     private String getRuntimeLocation(Map<String, ? super Object> params) {
 273         if (LINUX_RUNTIME.fetchFrom(params) == null) {
 274             return "";
 275         } else {
 276             return "$APPDIR/runtime";
 277         }
 278     }
 279 
 280     private void writeCfgFile(Map<String, ? super Object> params, File rootDir) throws FileNotFoundException {
 281         File cfgFile = new File(rootDir, getLauncherCfgName(params));
 282 
 283         cfgFile.delete();
 284         PrintStream out = new PrintStream(cfgFile);
 285         out.println("app.runtime=" + getRuntimeLocation(params));




 286         out.println("app.mainjar=" + MAIN_JAR.fetchFrom(params).getIncludedFiles().iterator().next());
 287         out.println("app.version=" + VERSION.fetchFrom(params));
 288 
 289         //use '/' in the class name (instead of '.' to simplify native code
 290         out.println("app.mainclass=" +
 291                 MAIN_CLASS.fetchFrom(params).replaceAll("\\.", "/"));
 292 
 293         StringBuilder macroedPath = new StringBuilder();
 294         for (String s : CLASSPATH.fetchFrom(params).split("[ ;:]+")) {
 295             macroedPath.append(s);
 296             macroedPath.append(":");
 297         }
 298         macroedPath.deleteCharAt(macroedPath.length() - 1);
 299         out.println("app.classpath=" + macroedPath.toString());
 300 
 301         List<String> jvmargs = JVM_OPTIONS.fetchFrom(params);
 302         int idx = 1;
 303         for (String a : jvmargs) {
 304             out.println("jvmarg."+idx+"="+a);
 305             idx++;


< prev index next >