Search in sources :

Example 1 with Parser

use of com.ibm.uma.om.parser.Parser in project openj9 by eclipse.

the class UMA method generate.

public void generate() throws UMAException {
    Parser parser = new Parser(this);
    if (!parser.parse()) {
        return;
    }
    modules = parser.getModules();
    platform.decorateModules(modules);
    try {
        Map<String, TemplateModel> map = new HashMap<String, TemplateModel>();
        map.put(FREEMARKER_UMA, new com.ibm.uma.freemarker.UMA());
        for (String tmp : templateLoader.getTemplates()) {
            Template template = freemarkerConfig.getTemplate(tmp);
            String filename = tmp.substring(0, tmp.lastIndexOf(".ftl"));
            StringWriter writer = new StringWriter();
            template.process(map, writer);
            new FileAssistant(this.rootDirectory + filename, writer.getBuffer()).writeToDisk();
        }
    } catch (IOException e) {
        throw new UMAException(e);
    } catch (TemplateException e) {
        throw new UMAException(e);
    }
    writeTargetInformationMacrosFile();
    // top level module is the first in the list.
    Module rootModule = null;
    for (Module module : modules) {
        if (module.isTopLevel()) {
            if (rootModule != null) {
                throw new UMAException("Error: more than one root module " + rootModule.getFullName() + " and " + module.getFullName());
            }
            rootModule = module;
        }
    }
    if (rootModule == null) {
        throw new UMAException("Error: no " + configuration.getMetadataFilename() + " found in the root directory " + getRootDirectory());
    }
    writeDirectoryMakefile(rootModule);
    Logger.getLogger().println(Logger.InformationL1Log, "Complete");
}
Also used : HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) TemplateModel(freemarker.template.TemplateModel) IOException(java.io.IOException) Parser(com.ibm.uma.om.parser.Parser) Template(freemarker.template.Template) FileAssistant(com.ibm.uma.util.FileAssistant) StringWriter(java.io.StringWriter) Module(com.ibm.uma.om.Module)

Aggregations

Module (com.ibm.uma.om.Module)1 Parser (com.ibm.uma.om.parser.Parser)1 FileAssistant (com.ibm.uma.util.FileAssistant)1 Template (freemarker.template.Template)1 TemplateException (freemarker.template.TemplateException)1 TemplateModel (freemarker.template.TemplateModel)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1