use of net.jangaroo.exml.generator.MxmlLibraryManifestGenerator in project jangaroo-tools by CoreMedia.
the class ExmlToMxml method convert.
public File[] convert() {
InputStream migrationMapStream = resourceClassLoader.getResourceAsStream("ext-as-3.4-migration-map.properties");
if (migrationMapStream == null) {
throw new ExmlcException("Could not find migration map 'ext-as-3.4-migration-map.properties' in classpath.");
}
try {
this.migrationMap.load(migrationMapStream);
} catch (IOException e) {
throw new ExmlcException("Unable to load migration map", e);
}
new CatalogComponentsParser(mxmlComponentRegistry).parse(resourceClassLoader.getResourceAsStream("catalog.xml"));
try {
new MxmlLibraryManifestGenerator(configClassRegistry).createManifestFile();
} catch (IOException e) {
throw new ExmlcException("Unable to create manifest.xml file: " + e.getMessage(), e);
}
Map<String, ExmlSourceFile> exmlSourceFilesByConfigClassName = configClassRegistry.getExmlSourceFilesByConfigClassName();
List<File> mxmlFiles = new ArrayList<File>();
Collection<ExmlSourceFile> exmlSourceFiles;
List<File> sourceFiles = configClassRegistry.getConfig().getSourceFiles();
if (sourceFiles.isEmpty()) {
exmlSourceFiles = exmlSourceFilesByConfigClassName.values();
} else {
exmlSourceFiles = new ArrayList<ExmlSourceFile>();
for (File exmlFile : sourceFiles) {
exmlSourceFiles.add(configClassRegistry.getExmlSourceFile(exmlFile));
}
}
for (ExmlSourceFile exmlSourceFile : exmlSourceFiles) {
System.out.printf("Converting EXML file %s...%n", exmlSourceFile.getSourceFile());
if (exmlSourceFile.hasSourceTargetClass()) {
System.out.printf(" Target class %s is implemented in ActionScript: no need to generate MXML target class.", exmlSourceFile.getTargetClassName());
} else {
try {
File mxmlFile = exmlToMxml(exmlSourceFile);
mxmlFiles.add(mxmlFile);
System.out.printf(" Generated MXML target class %s into file %s.%n", exmlSourceFile.getTargetClassName(), mxmlFile.getPath());
} catch (Exception e) {
throw new ExmlcException("Unable to convert to MXML: " + e.getMessage(), exmlSourceFile.getSourceFile(), e);
}
}
}
if (!configClassRegistry.getConfig().isKeepExmlFiles()) {
// clean up EXML files:
for (ExmlSourceFile exmlSourceFile : exmlSourceFiles) {
if (!exmlSourceFile.getSourceFile().delete()) {
System.err.println("Failed to delete EXML source file " + exmlSourceFile.getSourceFile().getPath());
}
}
}
return mxmlFiles.toArray(new File[mxmlFiles.size()]);
}
Aggregations