Search in sources :

Example 11 with ExmlcException

use of net.jangaroo.exml.api.ExmlcException in project jangaroo-tools by CoreMedia.

the class ExmlSourceFile method generateConfigClass.

public File generateConfigClass() {
    if (generatedConfigClassFile == null) {
        ConfigClass configClass = getConfigClass();
        generatedConfigClassFile = configClassRegistry.getConfig().computeConfigClassTarget(configClass.getName());
        // only recreate file if result file is older than the source file
        if (mustGenerate(generatedConfigClassFile)) {
            // generate the new config class ActionScript file
            try {
                new ExmlConfigClassGenerator().generateClass(configClass, generatedConfigClassFile);
            } catch (Exception e) {
                throw new ExmlcException("unable to generate config class: " + e.getMessage(), generatedConfigClassFile, e);
            }
        }
    }
    return generatedConfigClassFile;
}
Also used : ExmlcException(net.jangaroo.exml.api.ExmlcException) ExmlConfigClassGenerator(net.jangaroo.exml.generator.ExmlConfigClassGenerator) ExmlcException(net.jangaroo.exml.api.ExmlcException) IOException(java.io.IOException)

Example 12 with ExmlcException

use of net.jangaroo.exml.api.ExmlcException in project jangaroo-tools by CoreMedia.

the class AbstractExmlCompileMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    File gSourcesDirectory = getGeneratedSourcesDirectory();
    if (!gSourcesDirectory.exists()) {
        getLog().info("generating sources into: " + gSourcesDirectory.getPath());
        getLog().debug("created " + gSourcesDirectory.mkdirs());
    }
    if (!generatedResourcesDirectory.exists()) {
        getLog().info("generating resources into: " + generatedResourcesDirectory.getPath());
        getLog().debug("created " + generatedResourcesDirectory.mkdirs());
    }
    List<File> sourcePath = getSourcePath();
    ExmlConfiguration exmlConfiguration = createExmlConfiguration(getActionScriptClassPath(), sourcePath, gSourcesDirectory);
    exmlConfiguration.setResourceOutputDirectory(generatedResourcesDirectory);
    exmlConfiguration.setSourceFiles(getMavenPluginHelper().computeStaleSources(sourcePath, includes, excludes, gSourcesDirectory, Exmlc.EXML_SUFFIX, Jooc.AS_SUFFIX, staleMillis));
    if (StringUtils.isNotEmpty(validationMode)) {
        try {
            exmlConfiguration.setValidationMode(ValidationMode.valueOf(validationMode.toUpperCase()));
        } catch (IllegalArgumentException e) {
            throw new MojoFailureException("The specified EXML validation mode '" + validationMode + "' is unsupported. " + "Legal values are 'error', 'warn', and 'off'.");
        }
    }
    CompileLog compileLog = new MavenCompileLog();
    exmlConfiguration.setLog(compileLog);
    Exmlc exmlc;
    try {
        getLog().debug("Exmlc configuration: " + exmlConfiguration);
        exmlc = new Exmlc(exmlConfiguration);
        executeExmlc(exmlc);
    } catch (ExmlcException e) {
        throw new MojoFailureException(e.toString(), e);
    }
    if (compileLog.hasErrors()) {
        throw new MojoFailureException("There were EXML compiler errors, see log for details.");
    }
    getProject().addCompileSourceRoot(gSourcesDirectory.getPath());
}
Also used : Exmlc(net.jangaroo.exml.compiler.Exmlc) ExmlcException(net.jangaroo.exml.api.ExmlcException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ExmlConfiguration(net.jangaroo.exml.config.ExmlConfiguration) File(java.io.File) CompileLog(net.jangaroo.jooc.api.CompileLog)

Aggregations

ExmlcException (net.jangaroo.exml.api.ExmlcException)12 IOException (java.io.IOException)6 File (java.io.File)5 Element (org.w3c.dom.Element)3 InputStream (java.io.InputStream)2 JsonObject (net.jangaroo.exml.json.JsonObject)2 ConfigClass (net.jangaroo.exml.model.ConfigClass)2 Declaration (net.jangaroo.exml.model.Declaration)2 NodeList (org.w3c.dom.NodeList)2 Environment (freemarker.core.Environment)1 Configuration (freemarker.template.Configuration)1 DefaultObjectWrapper (freemarker.template.DefaultObjectWrapper)1 Template (freemarker.template.Template)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 Exmlc (net.jangaroo.exml.compiler.Exmlc)1