in flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java [442:529]
protected File generateThemeSwc(File themeDirectory) throws ConverterException {
final File fdkLibDir = new File(rootSourceDirectory, "lib");
List<String> processCmd = new ArrayList<String>(10);
if(fdkLibDir.exists() && fdkLibDir.isDirectory()) {
try {
final File compcLibrary = new File(fdkLibDir, "compc.jar");
final File frameworkDir = new File(rootSourceDirectory, "frameworks");
final String targetPlayer = getTargetPlayer(new File(frameworkDir, "libs/player"));
if(targetPlayer == null) {
System.out.println("Skipping theme compilation due to missing playerglobl.swc");
return null;
}
processCmd.add("java");
processCmd.add("-Xmx384m");
processCmd.add("-Dsun.io.useCanonCaches=false");
processCmd.add("-jar");
processCmd.add(compcLibrary.getCanonicalPath());
processCmd.add("+flexlib=" + frameworkDir.getCanonicalPath());
processCmd.add("-target-player=" + targetPlayer);
if (themeDirectory.isDirectory()) {
// Add all the content files.
final File contents[] = themeDirectory.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return !(pathname.isDirectory() && "src".equals(pathname.getName())) &&
!"preview.jpg".equals(pathname.getName()) && !pathname.getName().endsWith(".fla");
}
});
if (contents.length == 0) {
return null;
}
for (final File resource : contents) {
processCmd.add("-include-file");
processCmd.add(resource.getName());
processCmd.add(resource.getCanonicalPath());
}
} else {
processCmd.add("-include-file");
processCmd.add(themeDirectory.getName());
processCmd.add(themeDirectory.getCanonicalPath());
}
// Create a temp file.
final File targetFile = File.createTempFile(themeDirectory.getName(), "swc");
// Define the output file.
processCmd.add("-o");
processCmd.add(targetFile.getCanonicalPath());
final File targetDirectory = targetFile.getParentFile();
if (!targetDirectory.exists()) {
if (!targetDirectory.mkdirs()) {
throw new ConverterException("Could not create directory: " + targetDirectory.getCanonicalPath());
}
}
// Execute the command.
try {
System.out.println("Generating theme '" + themeDirectory.getName() + "'");
//final Process child = Runtime.getRuntime().exec(cmd.toString(), envps);
ProcessBuilder processBuilder = new ProcessBuilder(processCmd);
processBuilder.environment().put("PLAYERGLOBAL_HOME",
new File(new File(frameworkDir, "libs"), "player").getCanonicalPath());
int exitValue = exec(processBuilder.start());
if (exitValue != 0) {
System.out.println("Couldn't create theme swc");
System.out.println("----------------------------------------------------------------");
System.out.println("Env: '" + processBuilder.environment().get("PLAYERGLOBAL_HOME") + "'");
System.out.println(processBuilder.command());
System.out.println("----------------------------------------------------------------");
}
} catch (Exception e) {
e.printStackTrace();
}
// Return a reference on the theme swc.
return targetFile;
} catch(IOException e) {
throw new ConverterException("Error generating theme swc.", e);
}
}
return null;
}